import "go.chromium.org/goma/server/auth"
Package auth provides authentication service.
client.go doc.go local.go service.go token.go
ErrExpired represents expiration of access token.
ErrInternal represents internal error.
ErrNoAuthHeader represents authentication failure due to lack of Authorization header in an HTTP request.
ErrOverQuota represents the user used up the quota.
type Auth struct { Client authpb.AuthServiceClient Retry rpc.Retry // contains filtered or unexported fields }
Auth authenticates the requests and returns new context with enduser info.
Check checks authorization header in an HTTP request. The function returns error if authentication failed. ErrNoAuthHeader is returned if no authorization header is in the request.
func (c LocalClient) Auth(ctx context.Context, in *pb.AuthReq, opts ...grpc.CallOption) (*pb.AuthResp, error)
type Service struct { // CheckToken optionally checks access token with token info. // If it is not set, all access will be rejected. // If it returns grpc's codes.PermissionDenied error, // error message will be used as ErrorDescription for user. CheckToken func(context.Context, *oauth2.Token, *TokenInfo) (string, *oauth2.Token, error) // contains filtered or unexported fields }
Service implements goma auth service.
Auth checks authorization header of incoming request, and replies end user information.
TODO: find answers to following questions. 1. can auth server return expired token? (currently yes) 2. should auth server refresh expired token? (currently no) 3. should grpc status code represent status of request or access token? 4. how error description should be handled?
currently, it is stored in cache but not used by anybody.
5. should auth server create go routine for each token to expire the entry?
(currently yes)
6. how do we implement quota? 7. how do we integrate auth server with chrome-infra-auth?
type TokenInfo struct { // Email is email address associated with the access token. Email string // Audience is OAuth2 client_id of the access token. Audience string // ExpiresAt is expirary timestamp of the access token. ExpiresAt time.Time // Err represents error of access token. Err error }
TokenInfo represents access token's info.
Path | Synopsis |
---|---|
account | Package account manages service account. |
acl | Package acl performs access control with ACL. |
authdb | Package authdb provides access to authentication database. |
enduser | Package enduser manages end user information with context. |
Package auth imports 23 packages (graph) and is imported by 5 packages. Updated 2020-10-27. Refresh now. Tools for package owners.