Versions in this module Expand all Collapse all v4 v4.7.1 Feb 23, 2023 Changes in this version + const BearerScheme + const ScopeAccount + const ScopePublic + var DefaultAuth = NewAuth() + var ErrForbidden = errors.New("resource forbidden") + var ErrInvalidToken = errors.New("invalid token provided") + func ContextWithAccount(ctx context.Context, account *Account) context.Context + func Verify(rules []*Rule, acc *Account, res *Resource) error + type Access int + const AccessDenied + const AccessGranted + type Account struct + ID string + Issuer string + Metadata map[string]string + Scopes []string + Secret string + Type string + func AccountFromContext(ctx context.Context) (*Account, bool) + type Auth interface + Generate func(id string, opts ...GenerateOption) (*Account, error) + Init func(opts ...Option) + Inspect func(token string) (*Account, error) + Options func() Options + String func() string + Token func(opts ...TokenOption) (*Token, error) + func NewAuth(opts ...Option) Auth + type GenerateOption func(o *GenerateOptions) + func WithMetadata(md map[string]string) GenerateOption + func WithProvider(p string) GenerateOption + func WithScopes(s ...string) GenerateOption + func WithSecret(s string) GenerateOption + func WithType(t string) GenerateOption + type GenerateOptions struct + Metadata map[string]string + Provider string + Scopes []string + Secret string + Type string + func NewGenerateOptions(opts ...GenerateOption) GenerateOptions + type ListOption func(o *ListOptions) + func RulesContext(ctx context.Context) ListOption + type ListOptions struct + Context context.Context + type Option func(o *Options) + func Addrs(addrs ...string) Option + func ClientToken(token *Token) Option + func Credentials(id, secret string) Option + func Namespace(n string) Option + func PrivateKey(key string) Option + func PublicKey(key string) Option + type Options struct + Addrs []string + ID string + Namespace string + PrivateKey string + PublicKey string + Secret string + Token *Token + func NewOptions(opts ...Option) Options + type Resource struct + Endpoint string + Name string + Type string + type Rule struct + Access Access + ID string + Priority int32 + Resource *Resource + Scope string + type Rules interface + Grant func(rule *Rule) error + List func(...ListOption) ([]*Rule, error) + Revoke func(rule *Rule) error + Verify func(acc *Account, res *Resource, opts ...VerifyOption) error + func NewRules() Rules + type Token struct + AccessToken string + Created time.Time + Expiry time.Time + RefreshToken string + func (t *Token) Expired() bool + type TokenOption func(o *TokenOptions) + func WithCredentials(id, secret string) TokenOption + func WithExpiry(ex time.Duration) TokenOption + func WithToken(rt string) TokenOption + type TokenOptions struct + Expiry time.Duration + ID string + RefreshToken string + Secret string + func NewTokenOptions(opts ...TokenOption) TokenOptions + type VerifyOption func(o *VerifyOptions) + func VerifyContext(ctx context.Context) VerifyOption + type VerifyOptions struct + Context context.Context