Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthServer ¶
type AuthServer struct {
// contains filtered or unexported fields
}
AuthServer is the token authentication server
func NewAuthServer ¶
func NewAuthServer(opt *Option) (*AuthServer, error)
NewAuthServer creates a new AuthServer
func (*AuthServer) Run ¶
func (srv *AuthServer) Run(addr string) error
func (*AuthServer) ServeHTTP ¶
func (srv *AuthServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Authenticator ¶
Authenticator should be implemented to perform authentication. An implementation should return a non-nil error when authentication is not successful, otherwise a nil error should be returned
type AuthorizationRequest ¶
type AuthorizationRequest struct { Account string Service string Type string Name string IP string Actions []string }
AuthorizationRequest is the authorization request data
type Authorizer ¶
type Authorizer interface {
Authorize(req *AuthorizationRequest) ([]string, error)
}
Authorizer should be implemented to perform authorization. req.Actions should be checked against the user's authorized action on the repository, this function should return the list of authorized actions and a nil error. an empty list must be returned if requesting user is unauthorized
type DefaultAuthenticator ¶
type DefaultAuthenticator struct{}
DefaultAuthenticator makes authentication successful by default
func (*DefaultAuthenticator) Authenticate ¶
func (d *DefaultAuthenticator) Authenticate(username, password string) error
type DefaultAuthorizer ¶
type DefaultAuthorizer struct{}
DefaultAuthorizer makes authorization successful by default
func (*DefaultAuthorizer) Authorize ¶
func (d *DefaultAuthorizer) Authorize(req *AuthorizationRequest) ([]string, error)
type Option ¶
type Option struct { // an Authorizer implementation to authorize registry users Authorizer Authorizer // an Authenticator implementation to authenticate registry users Authenticator Authenticator // a pluggable tokenGenerator TokenGenerator TokenGenerator // .crt & .key file to sign JWT tokens Certfile string Keyfile string // token expiration time TokenExpiration int64 // token issuer specified in docker registry configuration file TokenIssuer string }
Option is the registry token authorization server configuration options
type TokenGenerator ¶
type TokenGenerator interface {
Generate(req *AuthorizationRequest, actions []string) (*Token, error)
}
TokenGenerator: an implementation should create a valid JWT according to the spec here https://github.com/docker/distribution/blob/1b9ab303a477ded9bdd3fc97e9119fa8f9e58fca/docs/spec/auth/jwt.md a default implementation that follows the spec is used when it is not provided