Documentation
¶
Index ¶
- Constants
- func GroupName(id string) string
- func IsNoCredentials(err error) bool
- func JWTSign(secret []byte, claims core.Map) (string, error)
- func Provider() runaprovider.Provider
- func ShortName(id string) string
- type AuthFunc
- type Authenticator
- type Context
- type ErrNoCredentials
- type Info
- type PermissionChecker
- type PermissionFunc
- type PermissionInfo
- type Registry
- func (registry *Registry) Auth(name string, authenticator Authenticator)
- func (registry *Registry) Checker() PermissionChecker
- func (registry *Registry) MustOf(name string) Authenticator
- func (registry *Registry) Names() []string
- func (registry *Registry) Of(name string) Authenticator
- func (registry *Registry) Permission(checker PermissionChecker)
- type TokenSource
Constants ¶
const ( MethodSession = "session" MethodAPIKey = "api_key" MethodJWT = "jwt" )
Variables ¶
This section is empty.
Functions ¶
func IsNoCredentials ¶
Types ¶
type Authenticator ¶
Authenticator resolves request identity.
func APIKeyAuth ¶
func APIKeyAuth(verify func(string) (core.Map, bool, error), sources ...TokenSource) Authenticator
APIKeyAuth authenticates a request token with a verifier callback.
func AuthMux ¶
func AuthMux(items ...Authenticator) Authenticator
AuthMux tries multiple authenticators in order.
func JWTAuth ¶
func JWTAuth(secret []byte, sources ...TokenSource) Authenticator
JWTAuth authenticates HS256 JWT tokens without forcing a large dependency.
func SessionAuth ¶
func SessionAuth(name string) Authenticator
SessionAuth authenticates when a named session contains auth data.
type Context ¶
type Context interface {
Context() context.Context
Request() *http.Request
CookieValue(string) (string, bool)
Session(...string) *session.Session
}
Context is the minimal request context needed by authenticators.
type ErrNoCredentials ¶
type ErrNoCredentials struct{}
ErrNoCredentials marks missing credentials.
func (ErrNoCredentials) Error ¶
func (ErrNoCredentials) Error() string
type PermissionChecker ¶
PermissionChecker checks one permission id.
func DefaultPermissionChecker ¶
func DefaultPermissionChecker() PermissionChecker
DefaultPermissionChecker checks Info.Data permission collections.
type PermissionFunc ¶
PermissionFunc adapts a function to PermissionChecker.
type PermissionInfo ¶
type PermissionInfo struct {
ID string
Name string
Label string
Group string
GroupLabel string
Method string
Path string
Tags []string
Description string
Meta core.Map
}
PermissionInfo describes one route permission.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores named authenticators and default permission checker.
func (*Registry) Auth ¶
func (registry *Registry) Auth(name string, authenticator Authenticator)
func (*Registry) Checker ¶
func (registry *Registry) Checker() PermissionChecker
func (*Registry) MustOf ¶
func (registry *Registry) MustOf(name string) Authenticator
func (*Registry) Of ¶
func (registry *Registry) Of(name string) Authenticator
func (*Registry) Permission ¶
func (registry *Registry) Permission(checker PermissionChecker)
type TokenSource ¶
TokenSource resolves token from a request context.
func Header ¶
func Header(name string) TokenSource
Header reads token from a header. Authorization removes Bearer prefix.