0

我正在开发 Go 中的授权插件,但我坚持使用它。当我向 localhost 上的 Docker 引擎发送命令时,我得到了 RequestURI 和 RequestBody,但没有得到发送请求的用户。这是一个空字符串。

func (e AuthzEntity) AuthZReq(req authorization.Request) authorization.Response {
    log.Println("RequestURI: ", req.RequestURI, " RequestBody: ", string(req.RequestBody))

    if "USER" == req.User {
        log.Println("Authorized")
    } else {
        log.Println("Unauthorized")
    }

    return authorization.Response{true, "", ""}
}

使用上面的代码,我希望日志中出现“已授权”文本,但我看到“未授权”并且用户名为空。

有人能帮我吗?

4

0 回答 0