0

I am working on an authorization plugin in Go and I am stuck with it. When I send commands to the Docker Engine on localhost, I get the RequestURI and RequestBody well but not the User who sent the request. It's an empty string.

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, "", ""}
}

With the above code I expect the text "Authorized" in the logs, but I see "Unauthorized" and the Username is empty.

Can someone help me?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
kergeodeta
  • 106
  • 4
  • 3
    It might help to include an example of what you are sending and how you are sending it exactly. – RayfenWindspear Dec 28 '18 at 20:51
  • Can you give some more information on the authorization interface? Perhaps, are you expecting the user value in a query parameter? like http://localhost/authorize?user=xxx – martwetzels Dec 28 '18 at 20:51
  • I send the commands through the docker cli, eg.: `docker container ls`. Or the cli commands don't send any information from the logged in user? I use the authorization.Request struct from the go-plugin-helpers package. The plugin run as a systemd service with a socket as described here: https://docs.docker.com/engine/extend/plugin_api/#what-plugins-are – kergeodeta Dec 29 '18 at 08:58

0 Answers0