Documentation ¶
Index ¶
- func FormatProvider(provider string) string
- func GetUser(w http.ResponseWriter) user.User
- func HRAuthorize(perm Permission, userRequired bool, l Logger, f Formatter, ...) httprouter.Handle
- func HRHydrateUser(userRepo usecase.UserRepo, l Logger, f Formatter, required bool, ...) httprouter.Handle
- func HydrateUser(userRepo usecase.UserRepo, l Logger, f Formatter, required bool, ...) http.Handler
- type Auth
- type Auth0
- type Auth0Config
- type Authenticator
- type Context
- type Formatter
- type Logger
- type Permission
- type ResponseContext
- type UserContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatProvider ¶
FormatProvider formats a provider string from a request to the DB and issuer format
func GetUser ¶
func GetUser(w http.ResponseWriter) user.User
GetUser gets a domain user from a hydrated userContext will return an empty domain user if not found
func HRAuthorize ¶
func HRAuthorize(perm Permission, userRequired bool, l Logger, f Formatter, next httprouter.Handle) httprouter.Handle
HRAuthorize wraps authorization logic in httprouter middleware
func HRHydrateUser ¶
func HRHydrateUser(userRepo usecase.UserRepo, l Logger, f Formatter, required bool, next httprouter.Handle) httprouter.Handle
HRHydrateUser wraps HydrateUser in httprouter middleware
Types ¶
type Auth ¶
type Auth struct { Authenticator // contains filtered or unexported fields }
Auth base struct for auth implementations
func (*Auth) Authenticate ¶
Authenticate stub authentication method
func (*Auth) SetFormatter ¶
SetFormatter sets the formatter on the Auth struct
type Auth0 ¶
type Auth0 struct { Auth // contains filtered or unexported fields }
Auth0 contains dependencies for the Auth0 handler
type Auth0Config ¶
Auth0Config contains configuration options for Auth0 handler
type Authenticator ¶
type Authenticator interface { SetFormatter(f Formatter) Authenticate(next http.Handler) http.Handler }
Authenticator interface for authorization
type Context ¶
type Context struct { Issuer string Subject string Permissions []Permission }
Context contains relevant auth data from request
func (*Context) HasPerm ¶
func (c *Context) HasPerm(permission Permission) bool
HasPerm returns true if the request token has the specified permission
type Formatter ¶
type Formatter interface { WriteResponse(w http.ResponseWriter, res []byte, statusCode int) Error(a interface{}) []byte }
Formatter defines the formatter interface for output responses
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger interface needed for log messages
type Permission ¶
type Permission int64
Permission type
const ( PermNone Permission = 0 PermUpsertUserSelf Permission = 1 << iota PermUpsertTask Permission = 1 << iota PermReadTask Permission = 1 << iota PermDeleteTask Permission = 1 << iota PermUpsertSchedule Permission = 1 << iota PermReadSchedule Permission = 1 << iota PermDeleteSchedule Permission = 1 << iota )
Application permissions, string must match exactly what is sent in access tokens from auth provider
func GetAnonymousUserPerms ¶
func GetAnonymousUserPerms() []Permission
GetAnonymousUserPerms returns the permissions needed for the anonymous app user
func GetDefaultUserPerms ¶
func GetDefaultUserPerms() []Permission
GetDefaultUserPerms returns the default list of permissions for a standard app user
func (Permission) String ¶
func (p Permission) String() string
type ResponseContext ¶
type ResponseContext struct { http.ResponseWriter Auth Context }
ResponseContext wraps http.ResponseWriter in a context that provides authorization details to other handlers
type UserContext ¶
type UserContext struct { http.ResponseWriter User *user.User Auth Context }
UserContext wraps http.ResponseWriter in a context that provides a hydrated domain user to other handlers