Versions in this module Expand all Collapse all v2 v2.9.3 Mar 12, 2021 v2.9.2 Mar 12, 2021 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 + 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) + Grant func(rule *Rule) error + Init func(opts ...Option) + Inspect func(token string) (*Account, error) + Options func() Options + Revoke func(rule *Rule) error + Rules func(...RulesOption) ([]*Rule, error) + String func() string + Token func(opts ...TokenOption) (*Token, error) + Verify func(acc *Account, res *Resource, opts ...VerifyOption) 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 Option func(o *Options) + func Addrs(addrs ...string) Option + func ClientToken(token *Token) Option + func Credentials(id, secret string) Option + func LoginURL(url string) Option + func Namespace(n string) Option + func PrivateKey(key string) Option + func Provider(p provider.Provider) Option + func PublicKey(key string) Option + func Store(s store.Store) Option + func WithClient(c client.Client) Option + type Options struct + Addrs []string + Client client.Client + ID string + LoginURL string + Namespace string + PrivateKey string + Provider provider.Provider + PublicKey string + Secret string + Store store.Store + 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 RulesOption func(o *RulesOptions) + func RulesContext(ctx context.Context) RulesOption + type RulesOptions struct + Context context.Context + 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