Documentation
¶
Overview ¶
Package auth implements authentication and authorization functionality.
Index ¶
Constants ¶
View Source
const ( // Roles a user can have for a board. // These roles are shared across features/components/bounded contexts of this app, since most of them require authorization relative to boards. // E.g. whether or not a user is authorized to invite other users, add/delete links or // post/delete comments to a board depends on the roles the user has for a particular board. BoardRoleOwner = "owner" BoardRoleEditor = "editor" BoardRoleViewer = "viewer" )
A role comprises a set of scopes.
Variables ¶
View Source
var BoardRoles = []string{BoardRoleOwner, BoardRoleEditor, BoardRoleViewer}
Functions ¶
func ContextWithUser ¶
Used to add a user to context, from which it can be retrieved by an application service. E.g. a transport or endpoint middleware could decode a JWT token contained in an http request header and use it to create a User instance.
func IsBoardRoleValid ¶
Returns true if the given string denotes a valid board role.
Types ¶
type Authorization ¶
Authorization represents the set of scopes a user has access to.
func (Authorization) HasScope ¶
func (a Authorization) HasScope(scope Scope) bool
type AuthorizationStore ¶
type AuthorizationStore interface {
Roles(ctx context.Context, boardId string, userId string) ([]string, error)
}
AuthorizationStore can be used to get the roles a user has for a board.
type BoardAuthorizationChecker ¶
type BoardAuthorizationChecker struct {
// contains filtered or unexported fields
}
BoardAuthorizationChecker can be used to obtain the set of scopes a user has access to for a given board.
func NewAuthorizationChecker ¶
func NewAuthorizationChecker(roleToScopes map[string][]Scope, store AuthorizationStore) *BoardAuthorizationChecker
func (*BoardAuthorizationChecker) GetAuthorization ¶
func (ac *BoardAuthorizationChecker) GetAuthorization(ctx context.Context, boardId string, userId string) (Authorization, error)
Click to show internal directories.
Click to hide internal directories.