Documentation ¶
Index ¶
- Variables
- func ScopesMap(token Token) map[Scope]struct{}
- func StringScopes(scopes []Scope) []string
- func ValidateScopes(token Token, scopes []Scope) error
- type ContextProvisioner
- type Controller
- type CreateOptions
- type ExchangeOptions
- type LocalController
- func (c LocalController) Create(ctx context.Context, options *CreateOptions) (string, error)
- func (c LocalController) Exchange(ctx context.Context, id string, nonce string) (string, error)
- func (c LocalController) List(ctx context.Context) ([]Token, error)
- func (c LocalController) Read(ctx context.Context, id string) (Token, error)
- func (c LocalController) Refresh(ctx context.Context) (string, error)
- func (c LocalController) Validate(ctx context.Context, tokenString string, scopes []Scope) (Token, error)
- type Operator
- type Options
- type Provisioner
- type ReadOptions
- type RefreshOptions
- type Scope
- type Store
- type Token
- type TokenKey
- type Transaction
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorContextTokenNotFound error = errors.New("token not in context") ErrorContextTokenNotValid error = errors.New("token not not valid") )
View Source
var ( ScopesDashboard []Scope = []Scope{ ScopeUserEmail, ScopeUserRead, ScopeTokenReadSelf, ScopeTokenRefresh, ScopeTokenCreate, ScopeTokenList, ScopeChatRead, ScopeResponsesCreate, ScopeResponsesRead, ScopeResponsesUpdate, ScopeResponsesDelete, ScopeResponsesList, ScopeWebhooksCreate, ScopeWebhooksRead, ScopeWebhooksUpdate, ScopeWebhooksDelete, ScopeWebhooksList, } )
Functions ¶
func StringScopes ¶
func ValidateScopes ¶
Types ¶
type ContextProvisioner ¶
type ContextProvisioner struct { Provisioner Scopes []Scope }
type Controller ¶
type CreateOptions ¶
type ExchangeOptions ¶
type LocalController ¶
type LocalController struct {
// contains filtered or unexported fields
}
Controller implements our core logic for managing token lifecycles
func NewController ¶
func NewController(ctx context.Context, store Store, provisioner Provisioner) *LocalController
Create a NewController with the given store and provisioner
func (LocalController) Create ¶
func (c LocalController) Create(ctx context.Context, options *CreateOptions) (string, error)
Create a token and return it's ID
func (LocalController) List ¶
func (c LocalController) List(ctx context.Context) ([]Token, error)
List tokens
type Operator ¶
type Operator interface { Controller Validator }
type Provisioner ¶
type ReadOptions ¶
type ReadOptions struct {
ID string
}
type RefreshOptions ¶
type Scope ¶
type Scope string
const ( // User scopes ScopeUserEmail Scope = "user_email" ScopeUserRead Scope = "user_read" ScopeUserImpersonate Scope = "user_impersonate" // Token scopes ScopeTokenReadSelf Scope = "token_read_self" ScopeTokenRefresh Scope = "token_refresh" ScopeTokenCreate Scope = "token_create" ScopeTokenList Scope = "token_list" // Chat scopes ScopeChatRead Scope = "chat_read" ScopeChatWrite Scope = "chat_write" // Responses scopes ScopeResponsesCreate Scope = "responses_create" ScopeResponsesRead Scope = "responses_read" ScopeResponsesUpdate Scope = "responses_update" ScopeResponsesDelete Scope = "responses_delete" ScopeResponsesList Scope = "responses_list" // Webhooks scopes ScopeWebhooksCreate Scope = "webhooks_create" ScopeWebhooksRead Scope = "webhooks_read" ScopeWebhooksUpdate Scope = "webhooks_update" ScopeWebhooksDelete Scope = "webhooks_delete" ScopeWebhooksList Scope = "webhooks_list" )
type Store ¶
type Store interface { List(context.Context) ([]Token, error) Create(context.Context, *CreateOptions) (string, error) Read(context.Context, *ReadOptions) (Token, error) Exchange(context.Context, *ExchangeOptions) (Transaction, error) Refresh(context.Context, *RefreshOptions) (Transaction, error) }
type Token ¶
type Token interface { GetTokenID() string GetCreatedAt() time.Time GetLastUsedAt() time.Time GetNonce() string GetUserID() string // Time the token expires // // This is mainly for book-keeping and clean up rather than if // the token is actually valid GetExpiry() time.Time // The time that new versions of the token should live GetLifetime() time.Duration // Has the token been exchanged, we shouldn't be able to // exchange more than once GetExchanged() bool GetExchangeBy() time.Time // Token name GetName() string GetComment() string GetScopes() []string }
type Transaction ¶
Click to show internal directories.
Click to hide internal directories.