Documentation ¶
Index ¶
- type AuthKey
- func (a *AuthKey) AddHandler() http.HandlerFunc
- func (a *AuthKey) Admin(name string) *AuthKey
- func (a *AuthKey) Configure(path *string) *AuthKey
- func (a *AuthKey) DeleteHandler() http.HandlerFunc
- func (a *AuthKey) GetUser(r *http.Request) string
- func (a *AuthKey) HKey(key string) *AuthKey
- func (a *AuthKey) IsAdmin(next http.Handler) http.Handler
- func (a *AuthKey) IsValid(next http.Handler) http.Handler
- func (a *AuthKey) RefreshHandler() http.HandlerFunc
- func (a *AuthKey) Silent() *AuthKey
- func (a *AuthKey) Start(ctx context.Context, refresh *time.Duration)
- func (a *AuthKey) UpdateHandler() http.HandlerFunc
- func (a *AuthKey) User(user, key string) *AuthKey
- func (a *AuthKey) UserHandler() http.HandlerFunc
- type Authentication
- type Client
- type PassKey
- func (pk *PassKey) Configure(secret interface{}) *PassKey
- func (pk *PassKey) Current() uint32
- func (pk *PassKey) HKey(key string) *PassKey
- func (pk *PassKey) Interval(interval interface{}) *PassKey
- func (pk *PassKey) IsValid(next http.Handler) http.Handler
- func (pk *PassKey) Secret() string
- func (pk *PassKey) Start(ctx context.Context)
- func (pk *PassKey) Tokens() []uint32
- func (pk *PassKey) Validate(token uint32) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthKey ¶ added in v1.0.8
type AuthKey struct {
// contains filtered or unexported fields
}
AuthKey structure for authentication and credential management for authorized user acces to restricted content.
The package supports path base (eg. /api/{apikey}/action) requests, however the admin management routes require a header token:{apikey} value be set to access the user management routes.
func NewAuthKey ¶ added in v1.0.8
NewAuthKey configurator will initialize an *auth.Auth and populate the uMap from the disk when path is provided or will use a memory uMap when nil is passed for path; configues the admin routes on a chi.Router
func (*AuthKey) AddHandler ¶ added in v1.0.8
func (a *AuthKey) AddHandler() http.HandlerFunc
AddHandler will add a new user to the ApiKey.uMap authority
.../add/{user}
func (*AuthKey) Configure ¶ added in v1.0.8
Configure will populate uMap from disk and create a default admin user when no current file exists (or path is file)
func (*AuthKey) DeleteHandler ¶ added in v1.0.8
func (a *AuthKey) DeleteHandler() http.HandlerFunc
DeleteHandler removes a user from the ApiKey.uMap authority
.../remove/{user}
func (*AuthKey) GetUser ¶ added in v1.0.8
GetUser retreives the user from the r.Context middleware transport chain using the specific mwUser key type
func (*AuthKey) IsAdmin ¶ added in v1.0.8
IsAdmin middleware is restricted to admin and requries that {a.hKey}:{apikey} be set in the request header for access
eg. r.Header [a.hKey:{apikey}]
func (*AuthKey) IsValid ¶ added in v1.0.8
IsValid middleware is restriced to valid users and requires the http header have [a.hKey:{apikey}] set in the header however it will failover and support /api/{key}/action formatting within the url string in r.URL.Path
func (*AuthKey) RefreshHandler ¶ added in v1.0.8
func (a *AuthKey) RefreshHandler() http.HandlerFunc
RefreshHandler reloads the ApiKey.uMap from disk
.../refresh
func (*AuthKey) Start ¶ added in v1.0.8
Start automated authorization refreshing; useful on clusters which share a common file or sync'd file system
func (*AuthKey) UpdateHandler ¶ added in v1.0.8
func (a *AuthKey) UpdateHandler() http.HandlerFunc
UpdateHandler reloads the ApiKey.uMap from disk
.../update/{user}
func (*AuthKey) User ¶ added in v1.0.8
User will set a manual user,key combination; key must 6 or more characters
func (*AuthKey) UserHandler ¶ added in v1.0.8
func (a *AuthKey) UserHandler() http.HandlerFunc
UserHandler provides the current ApiKey.uMap
.../users
type Authentication ¶ added in v1.0.8
Authentication interface for middleware using authKey and passKey protected endpoint routes
type Client ¶
type Client interface { Configure(interface{}) *PassKey Interval(interface{}) *PassKey Start(context.Context) Current() uint32 }
Client interface that exposes the minimal PassKey methods that a client needs to access for authentication
type PassKey ¶
type PassKey struct {
// contains filtered or unexported fields
}
PassKey structure to generate a time based token set based on a shared secret for system-to-system machine communication with rolling authentication
func NewPassKey ¶
func NewPassKey(secret interface{}) *PassKey
NewPassKey configurator used the provided secret or generates a secret on initilization that can be exported and then shared
default: generate new secret with default one-minute interval accepts: nil, [20]byte slice, or a base32(A..Z,2...7) 32-character string eg. AW6TJVTYMAYJXLWFW2WWJ6D3Q5B2AY25
func (*PassKey) Configure ¶
User will Configure applies the provided secret or generates a new one and generates a new token set based off the current pk.interval
default: generate new accepts: nil, [20]byte slice, or a base32(A..Z,2...7) 32-character string eg. AW6TJVTYMAYJXLWFW2WWJ6D3Q5B2AY25
func (*PassKey) Interval ¶
Interval sets the time duration and generates a token set
default: one-minute accepts: nil, time.Duration, or int value of seconds
func (*PassKey) IsValid ¶
IsValid middleware is restructed to valid tokens set as token:{passkey} in the http header