Documentation ¶
Index ¶
- Constants
- func Extract(prefixedpwd string) (string, string, error)
- func IsValidScope(scope APITokenScope) bool
- type APIToken
- type APITokenScope
- type DbProvider
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) Create(ctx context.Context, tokenLine *APIToken) error
- func (m *Manager) Delete(ctx context.Context, username, prefix string) error
- func (m *Manager) Get(ctx context.Context, username, prefix string) (*APIToken, error)
- func (m *Manager) GetAll(ctx context.Context, username string) ([]*APIToken, error)
- func (m *Manager) Save(ctx context.Context, tokenLine *APIToken) error
- type SqliteProvider
- func (p *SqliteProvider) Close() error
- func (p *SqliteProvider) Delete(ctx context.Context, username, prefix string) error
- func (p *SqliteProvider) Get(ctx context.Context, username, prefix string) (*APIToken, error)
- func (p *SqliteProvider) GetAll(ctx context.Context, username string) ([]*APIToken, error)
- func (p *SqliteProvider) GetByName(ctx context.Context, username, name string) (*APIToken, error)
- func (p *SqliteProvider) Save(ctx context.Context, tokenLine *APIToken) (err error)
Constants ¶
View Source
const APITokenPrefixLength = 8
Variables ¶
This section is empty.
Functions ¶
func IsValidScope ¶
func IsValidScope(scope APITokenScope) bool
Types ¶
type APIToken ¶
type APIToken struct { Username string `json:"username,omitempty" db:"username"` Prefix string `json:"prefix,omitempty" db:"prefix"` Name string `json:"name,omitempty" db:"name"` CreatedAt *time.Time `json:"created_at,omitempty" db:"created_at"` ExpiresAt *time.Time `json:"expires_at,omitempty" db:"expires_at"` Scope APITokenScope `json:"scope,omitempty" db:"scope"` Token string `json:"token,omitempty" db:"token"` }
type APITokenScope ¶
type APITokenScope string
const ( APITokenRead APITokenScope = "read" APITokenReadWrite APITokenScope = "read+write" APITokenClientsAuth APITokenScope = "clients-auth" )
type DbProvider ¶
type DbProvider interface { Get(ctx context.Context, username, prefix string) (*APIToken, error) GetByName(ctx context.Context, username, name string) (*APIToken, error) GetAll(ctx context.Context, username string) ([]*APIToken, error) Save(ctx context.Context, tokenLine *APIToken) error Delete(ctx context.Context, username, prefix string) error io.Closer }
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(db DbProvider) *Manager
type SqliteProvider ¶
type SqliteProvider struct {
// contains filtered or unexported fields
}
func NewSqliteProvider ¶
func NewSqliteProvider(db *sqlx.DB) *SqliteProvider
func (*SqliteProvider) Close ¶
func (p *SqliteProvider) Close() error
func (*SqliteProvider) Delete ¶
func (p *SqliteProvider) Delete(ctx context.Context, username, prefix string) error
Click to show internal directories.
Click to hide internal directories.