Documentation
¶
Overview ¶
Package auth is for authorization logic
Index ¶
Constants ¶
const BearerTokenType string = "Bearer"
BearerTokenType is used in authorization to access a resource
Variables ¶
This section is empty.
Functions ¶
func CtxWithAccessToken ¶ added in v0.28.0
func CtxWithAccessToken(ctx context.Context, at AccessToken) context.Context
CtxWithAccessToken sets the Access Token to the given context
Types ¶
type AccessControlList ¶ added in v0.19.0
AccessControlList (ACL) describes permissions for a given object
type AccessToken ¶ added in v0.19.0
AccessToken represents an access token found in an HTTP header, typically a Bearer token for Oauth2
func AccessTokenFromRequest ¶ added in v0.28.0
func AccessTokenFromRequest(r *http.Request) (AccessToken, error)
AccessTokenFromRequest gets the access token from the request
func NewAccessToken ¶ added in v0.28.0
func NewAccessToken(token, tokenType string) AccessToken
NewAccessToken is an initializer for AccessToken
func (AccessToken) NewGoogleOauth2Token ¶ added in v0.19.0
func (at AccessToken) NewGoogleOauth2Token() *oauth2.Token
NewGoogleOauth2Token returns a Google Oauth2 token given an AccessToken
type AccessTokenConverter ¶ added in v0.23.0
type AccessTokenConverter interface {
Convert(ctx context.Context, token AccessToken) (user.User, error)
}
AccessTokenConverter interface is used to convert an access token to a User
type Authorizer ¶ added in v0.19.0
type Authorizer interface {
Authorize(ctx context.Context, sub user.User, obj string, act string) error
}
Authorizer interface authorizes access to a resource given a user and action
type DefaultAuthorizer ¶ added in v0.20.0
type DefaultAuthorizer struct{}
DefaultAuthorizer struct satisfies the Authorizer interface. The DefaultAuthorizer.Authorize method ensures a subject (user) can perform a particular action on an object. e.g. gilcrest can read (GET) the resource at the /ping path. This is obviously completely bogus right now, eventually need to look into something like Casbin for ACL/RBAC
func (DefaultAuthorizer) Authorize ¶ added in v0.20.0
func (a DefaultAuthorizer) Authorize(ctx context.Context, sub user.User, obj string, act string) error
Authorize authorizes a subject (user) can perform a particular action on an object. e.g. gilcrest can read (GET) the resource at the /ping path. This is obviously completely bogus right now, eventually need to look into something like Casbin for ACL/RBAC