Documentation ¶
Index ¶
- Variables
- func Append(s Strategy, key interface{}, info Info) error
- func CtxWithUser(ctx context.Context, info Info) context.Context
- func NewTypeError(prefix string, want, got interface{}) error
- func RequestWithUser(info Info, r *http.Request) *http.Request
- func Revoke(s Strategy, key interface{}) error
- func SetInfoConstructor(c InfoConstructor)
- type Cache
- type DefaultUser
- func (d *DefaultUser) GetExtensions() Extensions
- func (d *DefaultUser) GetGroups() []string
- func (d *DefaultUser) GetID() string
- func (d *DefaultUser) GetUserName() string
- func (d *DefaultUser) SetExtensions(exts Extensions)
- func (d *DefaultUser) SetGroups(groups []string)
- func (d *DefaultUser) SetID(id string)
- func (d *DefaultUser) SetUserName(name string)
- type Extensions
- func (exts Extensions) Add(key, value string)
- func (exts Extensions) Clone() Extensions
- func (exts Extensions) Del(key string)
- func (exts Extensions) Get(key string) string
- func (exts Extensions) Has(key string) bool
- func (exts Extensions) Set(key, value string)
- func (exts Extensions) Values(key string) []string
- type Info
- type InfoConstructor
- type Option
- type OptionFunc
- type Strategy
- type TypeError
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidStrategy = errors.New("auth: Invalid strategy")
ErrInvalidStrategy is returned by Append/Revoke functions, when passed strategy does not implement Append/Revoke.
Functions ¶
func Append ¶
Append new Info to a strategy store. if passed strategy does not implement Append type ErrInvalidStrategy returned, Otherwise, nil.
WARNING: Append function does not guarantee safe concurrency, It's natively depends on strategy store.
func CtxWithUser ¶
CtxWithUser Save user information in context.
func NewTypeError ¶
NewTypeError returns InvalidType error
func RequestWithUser ¶
RequestWithUser Save user information in request context.
func Revoke ¶
Revoke delete Info from strategy store. if passed strategy does not implement Revoke type ErrInvalidStrategy returned, Otherwise, nil.
WARNING: Revoke function does not guarantee safe concurrency, It's natively depends on strategy store.
func SetInfoConstructor ¶
func SetInfoConstructor(c InfoConstructor)
SetInfoConstructor replace the default InfoConstructor with any function that has the appropriate signature. This allows the developers to create custom user info from their own struct instead of using the DefaultUser that go-guardian expose.
Default is NewDefaultUser
Types ¶
type Cache ¶
type Cache interface { // Load returns key value. Load(key interface{}) (interface{}, bool) // Store sets the key value. Store(key interface{}, value interface{}) // StoreWithTTL sets the key value with TTL overrides the default. StoreWithTTL(key interface{}, value interface{}, ttl time.Duration) // Delete deletes the key value. Delete(key interface{}) }
Cache type describes the requirements for authentication strategies, that cache the authentication decisions.
type DefaultUser ¶
type DefaultUser struct { Name string ID string Groups []string Extensions Extensions }
DefaultUser implement Info interface and provides a simple user information.
func NewDefaultUser ¶
func NewDefaultUser(name, id string, groups []string, extensions Extensions) *DefaultUser
NewDefaultUser return new default user
func (*DefaultUser) GetExtensions ¶
func (d *DefaultUser) GetExtensions() Extensions
GetExtensions return additional information.
func (*DefaultUser) GetGroups ¶
func (d *DefaultUser) GetGroups() []string
GetGroups returns the names of the groups the user is a member of
func (*DefaultUser) GetID ¶
func (d *DefaultUser) GetID() string
GetID returns a unique value identify a particular user
func (*DefaultUser) GetUserName ¶
func (d *DefaultUser) GetUserName() string
GetUserName returns the name that uniquely identifies this user among all other active users.
func (*DefaultUser) SetExtensions ¶
func (d *DefaultUser) SetExtensions(exts Extensions)
SetExtensions to contain additional information.
func (*DefaultUser) SetGroups ¶
func (d *DefaultUser) SetGroups(groups []string)
SetGroups set the names of the groups the user is a member of.
func (*DefaultUser) SetID ¶
func (d *DefaultUser) SetID(id string)
SetID set a unique value identify a particular user.
func (*DefaultUser) SetUserName ¶
func (d *DefaultUser) SetUserName(name string)
SetUserName set the name that uniquely identifies this user among all other active users.
type Extensions ¶
Extensions represents additional information to a user.
func (Extensions) Add ¶
func (exts Extensions) Add(key, value string)
Add adds the key, value pair to the extensions. It appends to any existing values associated with key. The key is case sensitive.
func (Extensions) Clone ¶
func (exts Extensions) Clone() Extensions
Clone returns a copy of extensions or nil if extensions is nil.
func (Extensions) Del ¶
func (exts Extensions) Del(key string)
Del deletes the values associated with key.
func (Extensions) Get ¶
func (exts Extensions) Get(key string) string
Get gets the first value associated with the given key. It is case sensitive; If there are no values associated with the key, Get returns "".
func (Extensions) Has ¶
func (exts Extensions) Has(key string) bool
Has reports whether extensions has the provided key defined.
func (Extensions) Set ¶
func (exts Extensions) Set(key, value string)
Set sets the extensions entries associated with key to the single element value. It replaces any existing values associated with key.
func (Extensions) Values ¶
func (exts Extensions) Values(key string) []string
Values returns all values associated with the given key. It is case sensitive; The returned slice is not a copy.
type Info ¶
type Info interface { // GetUserName returns the name that uniquely identifies this user among all // other active users. GetUserName() string // SetUserName set the name that uniquely identifies this user among all // other active users. SetUserName(string) // GetID returns a unique value identify a particular user. GetID() string // SetID set a unique value identify a particular user. SetID(string) // GetGroups returns the names of the groups the user is a member of GetGroups() []string // SetGroups set the names of the groups the user is a member of. SetGroups(groups []string) // Extensions can contain any additional information. GetExtensions() Extensions // SetExtensions to contain additional information. SetExtensions(exts Extensions) }
Info describes a user that has been authenticated to the system.
func NewUserInfo ¶
func NewUserInfo(name, id string, groups []string, extensions Extensions) Info
NewUserInfo implements InfoConstructor and return Info object. Typically called from strategies to create a new user object when its authenticated.
func UserFromCtx ¶
UserFromCtx return user information from context.
type InfoConstructor ¶
type InfoConstructor func(name, id string, groups []string, extensions Extensions) Info
InfoConstructor define function signature to create new Info object.
type Option ¶
type Option interface {
Apply(v interface{})
}
Option configures Strategy using the functional options paradigm popularized by Rob Pike and Dave Cheney. If you're unfamiliar with this style, see https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html and https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis.
type OptionFunc ¶
type OptionFunc func(v interface{})
OptionFunc implements Option interface.
func (OptionFunc) Apply ¶
func (fn OptionFunc) Apply(v interface{})
Apply the configuration to the provided strategy.
Directories ¶
Path | Synopsis |
---|---|
Package claims collects common jwt types.
|
Package claims collects common jwt types. |
Package internal contains support & helpers for go-guardian packages.
|
Package internal contains support & helpers for go-guardian packages. |
strategies
|
|
basic
Package basic provides authentication strategy, to authenticate HTTP requests using the standard basic scheme.
|
Package basic provides authentication strategy, to authenticate HTTP requests using the standard basic scheme. |
digest
Package digest provides authentication strategy, to authenticate HTTP requests using the standard digest scheme as described in RFC 7616.
|
Package digest provides authentication strategy, to authenticate HTTP requests using the standard digest scheme as described in RFC 7616. |
jwt
Package jwt provides authentication strategy, to authenticate HTTP requests based on jwt token.
|
Package jwt provides authentication strategy, to authenticate HTTP requests based on jwt token. |
kubernetes
Package kubernetes provide auth strategy to authenticate, incoming HTTP requests using a Kubernetes Service Account Token.
|
Package kubernetes provide auth strategy to authenticate, incoming HTTP requests using a Kubernetes Service Account Token. |
ldap
Package ldap provides authentication strategy, to authenticate HTTP requests and builds, extracts user informations from LDAP Server.
|
Package ldap provides authentication strategy, to authenticate HTTP requests and builds, extracts user informations from LDAP Server. |
oauth2/introspection
Package introspection provide auth strategy to authenticate, incoming HTTP requests using the oauth2 token introspection endpoint, as defined in RFC 7662.
|
Package introspection provide auth strategy to authenticate, incoming HTTP requests using the oauth2 token introspection endpoint, as defined in RFC 7662. |
oauth2/jwt
Package jwt provides authentication strategy, incoming HTTP requests using the oauth2 jwt access token or openid IDToken.
|
Package jwt provides authentication strategy, incoming HTTP requests using the oauth2 jwt access token or openid IDToken. |
oauth2/userinfo
Package userinfo provide auth strategy to authenticate, incoming HTTP requests using the oauth2/openid userinfo endpoint, as defined in OpenID Connect https://openid.net/specs/openid-connect-core-1_0.html#UserInfo.
|
Package userinfo provide auth strategy to authenticate, incoming HTTP requests using the oauth2/openid userinfo endpoint, as defined in OpenID Connect https://openid.net/specs/openid-connect-core-1_0.html#UserInfo. |
opaque
Package opaque provides server-side consistent tokens.
|
Package opaque provides server-side consistent tokens. |
token
Package token provides authentication strategy, to authenticate HTTP requests based on token.
|
Package token provides authentication strategy, to authenticate HTTP requests based on token. |
twofactor
Package twofactor provides authentication strategy, to authenticate HTTP requests based on one time password(otp).
|
Package twofactor provides authentication strategy, to authenticate HTTP requests based on one time password(otp). |
x509
Package x509 provides authentication strategy, to authenticate HTTPS requests and builds, extracts user informations from client certificates.
|
Package x509 provides authentication strategy, to authenticate HTTPS requests and builds, extracts user informations from client certificates. |