Versions in this module Expand all Collapse all v3 v3.13.1 Sep 21, 2022 Changes in this version + const ScopeAccount + const ScopeAnyNamespaceAccount + const ScopePublic + var DefaultAuth Auth + var ErrForbidden = errors.New("resource forbidden") + var ErrInvalidToken = errors.New("invalid token provided") + func ContextWithAccount(ctx context.Context, account *Account) context.Context + func Grant(rule *Rule) error + func Revoke(rule *Rule) error + func Verify(acc *Account, res *Resource, opts ...VerifyOption) error + type Access int + const AccessDenied + const AccessGranted + type Account struct + ID string + Issuer string + Metadata map[string]string + Name string + Scopes []string + Secret string + Type string + func AccountFromContext(ctx context.Context) (*Account, bool) + func Generate(id string, opts ...GenerateOption) (*Account, error) + func Inspect(token string) (*Account, error) + type AccountToken struct + AccessToken string + Created time.Time + Expiry time.Time + RefreshToken string + func Token(opts ...TokenOption) (*AccountToken, error) + func (t *AccountToken) Expired() 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) (*AccountToken, error) + Verify func(acc *Account, res *Resource, opts ...VerifyOption) error + type GenerateOption func(o *GenerateOptions) + func WithIssuer(i string) GenerateOption + func WithMetadata(md map[string]string) GenerateOption + func WithName(n 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 + Issuer string + Metadata map[string]string + Name 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 *AccountToken) Option + func Credentials(id, secret string) Option + func Issuer(i string) Option + func LoginURL(url string) Option + func PrivateKey(key string) Option + func PublicKey(key string) Option + func Store(s store.Store) Option + type Options struct + Addrs []string + Context context.Context + ID string + Issuer string + LoginURL string + PrivateKey string + PublicKey string + Secret string + Store store.Store + Token *AccountToken + 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 + func Rules(...RulesOption) ([]*Rule, error) + type RulesOption func(o *RulesOptions) + func RulesContext(ctx context.Context) RulesOption + func RulesNamespace(ns string) RulesOption + type RulesOptions struct + Context context.Context + Namespace string + type TokenOption func(o *TokenOptions) + func WithCredentials(id, secret string) TokenOption + func WithExpiry(ex time.Duration) TokenOption + func WithToken(rt string) TokenOption + func WithTokenIssuer(iss string) TokenOption + type TokenOptions struct + Expiry time.Duration + ID string + Issuer string + RefreshToken string + Secret string + func NewTokenOptions(opts ...TokenOption) TokenOptions + type VerifyOption func(o *VerifyOptions) + func VerifyContext(ctx context.Context) VerifyOption + func VerifyNamespace(ns string) VerifyOption + type VerifyOptions struct + Context context.Context + Namespace string