Documentation ¶
Overview ¶
Package repository provides the APIs for making 'token' related database interactions.
Index ¶
- func ExternalTokenFilterByIdentityID(identityID uuid.UUID) func(db *gorm.DB) *gorm.DB
- func ExternalTokenFilterByProviderID(providerID uuid.UUID) func(db *gorm.DB) *gorm.DB
- func ExternalTokenWithIdentity() func(db *gorm.DB) *gorm.DB
- type ExternalToken
- type ExternalTokenRepository
- type GormExternalTokenRepository
- func (m *GormExternalTokenRepository) CheckExists(ctx context.Context, id string) error
- func (m *GormExternalTokenRepository) Create(ctx context.Context, model *ExternalToken) error
- func (m *GormExternalTokenRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (m *GormExternalTokenRepository) DeleteByIdentityID(ctx context.Context, identityID uuid.UUID) error
- func (m *GormExternalTokenRepository) Load(ctx context.Context, id uuid.UUID) (*ExternalToken, error)
- func (m *GormExternalTokenRepository) LoadByProviderIDAndIdentityID(ctx context.Context, providerID uuid.UUID, identityID uuid.UUID) ([]ExternalToken, error)
- func (m *GormExternalTokenRepository) Query(funcs ...func(*gorm.DB) *gorm.DB) ([]ExternalToken, error)
- func (m *GormExternalTokenRepository) Save(ctx context.Context, model *ExternalToken) error
- func (m *GormExternalTokenRepository) TableName() string
- type GormTokenRepository
- func (m *GormTokenRepository) CheckExists(ctx context.Context, id uuid.UUID) (bool, error)
- func (m *GormTokenRepository) CleanupExpiredTokens(ctx context.Context, retentionHours int) error
- func (m *GormTokenRepository) Create(ctx context.Context, token *Token) error
- func (m *GormTokenRepository) CreatePrivilege(ctx context.Context, privilege *TokenPrivilege) error
- func (m *GormTokenRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (m *GormTokenRepository) ListForIdentity(ctx context.Context, identityID uuid.UUID) ([]Token, error)
- func (m *GormTokenRepository) ListPrivileges(ctx context.Context, tokenID uuid.UUID) ([]permission.PrivilegeCache, error)
- func (m *GormTokenRepository) Load(ctx context.Context, id uuid.UUID) (*Token, error)
- func (m *GormTokenRepository) Save(ctx context.Context, token *Token) error
- func (m *GormTokenRepository) SetStatusFlagsForIdentity(ctx context.Context, identityID uuid.UUID, status int) error
- func (m *GormTokenRepository) TableName() string
- func (m *GormTokenRepository) TokenPrivilegeTableName() string
- type Token
- type TokenPrivilege
- type TokenRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExternalTokenFilterByIdentityID ¶
ExternalTokenFilterByIdentityID is a gorm filter for a Belongs To relationship.
func ExternalTokenFilterByProviderID ¶
ExternalTokenFilterByProviderID is a gorm filter by 'external_provider_type'
Types ¶
type ExternalToken ¶
type ExternalToken struct { gormsupport.LifecycleHardDelete ID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"` // This is the ID PK field ProviderID uuid.UUID Token string Scope string Username string IdentityID uuid.UUID `sql:"type:uuid"` // use NullUUID ? Identity account.Identity }
ExternalToken describes a single ExternalToken
func (ExternalToken) GetETagData ¶
func (m ExternalToken) GetETagData() []interface{}
GetETagData returns the field values to use to generate the ETag
func (ExternalToken) GetLastModified ¶
func (m ExternalToken) GetLastModified() time.Time
GetLastModified returns the last modification time
func (ExternalToken) TableName ¶
func (m ExternalToken) TableName() string
TableName overrides the table name settings in Gorm to force a specific table name in the database.
type ExternalTokenRepository ¶
type ExternalTokenRepository interface { repository.Exister Load(ctx context.Context, id uuid.UUID) (*ExternalToken, error) Create(ctx context.Context, ExternalToken *ExternalToken) error Save(ctx context.Context, ExternalToken *ExternalToken) error Delete(ctx context.Context, id uuid.UUID) error DeleteByIdentityID(ctx context.Context, identityID uuid.UUID) error LoadByProviderIDAndIdentityID(ctx context.Context, providerID uuid.UUID, identityID uuid.UUID) ([]ExternalToken, error) Query(funcs ...func(*gorm.DB) *gorm.DB) ([]ExternalToken, error) }
ExternalTokenRepository represents the storage interface.
type GormExternalTokenRepository ¶
type GormExternalTokenRepository struct {
// contains filtered or unexported fields
}
GormExternalTokenRepository is the implementation of the storage interface for ExternalToken.
func NewExternalTokenRepository ¶
func NewExternalTokenRepository(db *gorm.DB) *GormExternalTokenRepository
NewExternalTokenRepository creates a new storage type.
func (*GormExternalTokenRepository) CheckExists ¶
func (m *GormExternalTokenRepository) CheckExists(ctx context.Context, id string) error
CheckExists returns nil if the given ID exists otherwise returns an error
func (*GormExternalTokenRepository) Create ¶
func (m *GormExternalTokenRepository) Create(ctx context.Context, model *ExternalToken) error
Create creates a new record.
func (*GormExternalTokenRepository) DeleteByIdentityID ¶
func (m *GormExternalTokenRepository) DeleteByIdentityID(ctx context.Context, identityID uuid.UUID) error
DeleteByIdentityID removes all records associated with a given identity ID
func (*GormExternalTokenRepository) Load ¶
func (m *GormExternalTokenRepository) Load(ctx context.Context, id uuid.UUID) (*ExternalToken, error)
Load returns a single ExternalToken as a Database Model This is more for use internally, and probably not what you want in your controllers
func (*GormExternalTokenRepository) LoadByProviderIDAndIdentityID ¶
func (m *GormExternalTokenRepository) LoadByProviderIDAndIdentityID(ctx context.Context, providerID uuid.UUID, identityID uuid.UUID) ([]ExternalToken, error)
LoadByProviderIDAndIdentityID loads tokens by IdentityID and ProviderID
func (*GormExternalTokenRepository) Query ¶
func (m *GormExternalTokenRepository) Query(funcs ...func(*gorm.DB) *gorm.DB) ([]ExternalToken, error)
Query expose an open ended Query model
func (*GormExternalTokenRepository) Save ¶
func (m *GormExternalTokenRepository) Save(ctx context.Context, model *ExternalToken) error
Save modifies a single record.
func (*GormExternalTokenRepository) TableName ¶
func (m *GormExternalTokenRepository) TableName() string
TableName overrides the table name settings in Gorm to force a specific table name in the database.
type GormTokenRepository ¶
type GormTokenRepository struct {
// contains filtered or unexported fields
}
GormTokenRepository is the implementation of the storage interface for Token.
func (*GormTokenRepository) CheckExists ¶
func (m *GormTokenRepository) CheckExists(ctx context.Context, id uuid.UUID) (bool, error)
CheckExists returns true if the given ID exists otherwise returns an error
func (*GormTokenRepository) CleanupExpiredTokens ¶
func (m *GormTokenRepository) CleanupExpiredTokens(ctx context.Context, retentionHours int) error
func (*GormTokenRepository) Create ¶
func (m *GormTokenRepository) Create(ctx context.Context, token *Token) error
Create creates a new record.
func (*GormTokenRepository) CreatePrivilege ¶
func (m *GormTokenRepository) CreatePrivilege(ctx context.Context, privilege *TokenPrivilege) error
func (*GormTokenRepository) Delete ¶
func (m *GormTokenRepository) Delete(ctx context.Context, id uuid.UUID) error
Delete removes a single record.
func (*GormTokenRepository) ListForIdentity ¶
func (m *GormTokenRepository) ListForIdentity(ctx context.Context, identityID uuid.UUID) ([]Token, error)
func (*GormTokenRepository) ListPrivileges ¶
func (m *GormTokenRepository) ListPrivileges(ctx context.Context, tokenID uuid.UUID) ([]permission.PrivilegeCache, error)
func (*GormTokenRepository) Load ¶
func (m *GormTokenRepository) Load(ctx context.Context, id uuid.UUID) (*Token, error)
Load returns a single Token as a Database Model
func (*GormTokenRepository) Save ¶
func (m *GormTokenRepository) Save(ctx context.Context, token *Token) error
Save modifies a single record.
func (*GormTokenRepository) SetStatusFlagsForIdentity ¶
func (m *GormTokenRepository) SetStatusFlagsForIdentity(ctx context.Context, identityID uuid.UUID, status int) error
func (*GormTokenRepository) TableName ¶
func (m *GormTokenRepository) TableName() string
func (*GormTokenRepository) TokenPrivilegeTableName ¶
func (m *GormTokenRepository) TokenPrivilegeTableName() string
type Token ¶
type Token struct { gormsupport.Lifecycle // This is the primary key value TokenID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key;column:token_id"` IdentityID uuid.UUID Status int TokenType string // The timestamp when the token will expire ExpiryTime time.Time }
Token represents a single instance of an oauth token
type TokenPrivilege ¶
type TokenPrivilege struct { TokenID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key;column:token_id"` PrivilegeCacheID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key;column:privilege_cache_id"` }
TokenPrivilege is a simple many-to-many table used to link privileges to tokens
func (TokenPrivilege) TableName ¶
func (m TokenPrivilege) TableName() string
type TokenRepository ¶
type TokenRepository interface { CheckExists(ctx context.Context, id uuid.UUID) (bool, error) Load(ctx context.Context, id uuid.UUID) (*Token, error) Create(ctx context.Context, token *Token) error Save(ctx context.Context, token *Token) error Delete(ctx context.Context, id uuid.UUID) error ListForIdentity(ctx context.Context, id uuid.UUID) ([]Token, error) CreatePrivilege(ctx context.Context, privilege *TokenPrivilege) error ListPrivileges(ctx context.Context, tokenID uuid.UUID) ([]permission.PrivilegeCache, error) SetStatusFlagsForIdentity(ctx context.Context, identityID uuid.UUID, status int) error CleanupExpiredTokens(ctx context.Context, retentionHours int) error }
TokenRepository represents the storage interface.
func NewTokenRepository ¶
func NewTokenRepository(db *gorm.DB) TokenRepository
NewTokenRepository creates a new storage type.