Documentation ¶
Index ¶
- Variables
- type ActionToken
- type AuditEvent
- type BackupToken
- type DataStore
- func (dataStore *DataStore) AddAuditEvent(userid, eventType string, eventTime time.Time, data map[string]string) (interface{}, error)
- func (dataStore *DataStore) AddBackupToken(userid, name, secret string) (interface{}, error)
- func (dataStore *DataStore) AddBackupTokens(userid string, names, secrets []string) (interface{}, error)
- func (dataStore *DataStore) AddFidoToken(userid, name, keyHandle, publicKey, certificate string, counter uint) (interface{}, error)
- func (ds *DataStore) AddTotpToken(userid, name, secret string, counter uint) (interface{}, error)
- func (dataStore *DataStore) AddUser(email, username, pass string) (interface{}, error)
- func (dataStore *DataStore) ClearPendingBackupTokens(userid string) error
- func (dataStore *DataStore) Close()
- func (ds *DataStore) CreateActionToken(userExtID, tokenID, action string, expiry time.Time) (interface{}, error)
- func (dataStore *DataStore) Drop()
- func (dataStore *DataStore) ForceSync()
- func (ds *DataStore) GetActionToken(tokenID string) (interface{}, error)
- func (ds *DataStore) GetActionTokens(userid string) ([]interface{}, error)
- func (dataStore *DataStore) GetAuditEvents(userid string) ([]interface{}, error)
- func (dataStore *DataStore) GetBackupTokenByName(userid, name string) (interface{}, error)
- func (dataStore *DataStore) GetBackupTokens(userid string) ([]interface{}, error)
- func (dataStore *DataStore) GetFidoTokens(userid string) ([]interface{}, error)
- func (dataStore *DataStore) GetTokens(user interface{}) (interface{}, error)
- func (ds *DataStore) GetTotpTokens(userid string) ([]interface{}, error)
- func (dataStore *DataStore) GetUserByEmail(email string) (interface{}, error)
- func (dataStore *DataStore) GetUserByExtID(extID string) (interface{}, error)
- func (dataStore *DataStore) GetUserByUsername(username string) (interface{}, error)
- func (dataStore *DataStore) RemoveFidoToken(token interface{}) error
- func (ds *DataStore) RemoveTotpToken(token interface{}) error
- func (dataStore *DataStore) Sync()
- func (ds *DataStore) UpdateActionToken(token interface{}) (interface{}, error)
- func (dataStore *DataStore) UpdateBackupToken(token interface{}) (interface{}, error)
- func (dataStore *DataStore) UpdateFidoToken(token interface{}) (interface{}, error)
- func (ds *DataStore) UpdateTotpToken(token interface{}) (interface{}, error)
- func (dataStore *DataStore) UpdateUser(user interface{}) (interface{}, error)
- type FidoToken
- func (token *FidoToken) GetCertificate() string
- func (token *FidoToken) GetCounter() uint
- func (token *FidoToken) GetExtID() string
- func (token *FidoToken) GetKeyHandle() string
- func (token *FidoToken) GetLastUsed() time.Time
- func (token *FidoToken) GetName() string
- func (token *FidoToken) GetPublicKey() string
- func (token *FidoToken) SetCounter(count uint)
- func (token *FidoToken) SetLastUsed(used time.Time)
- type QueryFilter
- type TotpToken
- func (token *TotpToken) GetCounter() uint
- func (token *TotpToken) GetExtID() string
- func (token *TotpToken) GetLastUsed() time.Time
- func (token *TotpToken) GetName() string
- func (token *TotpToken) GetSecret() string
- func (token *TotpToken) SetCounter(count uint)
- func (token *TotpToken) SetLastUsed(used time.Time)
- type User
- func (u *User) ClearLoginRetries()
- func (u *User) GetCreatedAt() time.Time
- func (u *User) GetEmail() string
- func (u *User) GetExtID() string
- func (u *User) GetIntID() uint
- func (u *User) GetLastLogin() time.Time
- func (u *User) GetLoginRetries() uint
- func (u *User) GetPassword() string
- func (u *User) GetPasswordChanged() time.Time
- func (u *User) GetUsername() string
- func (u *User) IsActivated() bool
- func (u *User) IsAdmin() bool
- func (u *User) IsEnabled() bool
- func (u *User) IsLocked() bool
- func (u *User) SecondFactors() bool
- func (u *User) SetActivated(activated bool)
- func (u *User) SetAdmin(admin bool)
- func (u *User) SetEnabled(enabled bool)
- func (u *User) SetLastLogin(t time.Time)
- func (u *User) SetLocked(locked bool)
- func (u *User) SetLoginRetries(retries uint)
- func (u *User) SetPassword(pass string)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidQuery = errors.New("Invalid DB Query argument")
var ErrUserNotFound = errors.New("User account not found")
Functions ¶
This section is empty.
Types ¶
type ActionToken ¶
type ActionToken struct { gorm.Model TokenID string UserExtID string UserID uint Action string Used bool UsedAt time.Time ExpiresAt time.Time }
ActionToken Time based One Time Password Token object
func (*ActionToken) GetAction ¶
func (token *ActionToken) GetAction() string
GetAction fetches the token action
func (*ActionToken) GetExpiry ¶
func (token *ActionToken) GetExpiry() time.Time
GetExpiry fetches the token expiry time
func (*ActionToken) GetTokenID ¶
func (token *ActionToken) GetTokenID() string
GetTokenID fetches the action token ID
func (*ActionToken) GetUserExtID ¶
func (token *ActionToken) GetUserExtID() string
func (*ActionToken) IsUsed ¶
func (token *ActionToken) IsUsed() bool
IsUsed checks if a token has been used
func (*ActionToken) SetUsed ¶
func (token *ActionToken) SetUsed(t time.Time)
SetUsed sets the used state for the action token
type AuditEvent ¶
AuditEvent for a user account
func (*AuditEvent) GetData ¶
func (ae *AuditEvent) GetData() (map[string]string, error)
GetData fetches a map of the associated data
func (*AuditEvent) GetTime ¶
func (ae *AuditEvent) GetTime() time.Time
GetTime fetches the time at which the event occured
func (*AuditEvent) GetType ¶
func (ae *AuditEvent) GetType() string
GetType fetches the type of the event
type BackupToken ¶
type BackupToken struct { gorm.Model UserID uint Name string Secret string Used bool UsedAt time.Time }
BackupToken 2fa backup code object
func (*BackupToken) GetCreatedAt ¶
func (token *BackupToken) GetCreatedAt() time.Time
func (*BackupToken) GetHashedSecret ¶
func (token *BackupToken) GetHashedSecret() string
GetHashedSecret fetches the hashed token secret
func (*BackupToken) GetName ¶
func (token *BackupToken) GetName() string
GetName fetches the token Name
func (*BackupToken) GetUsedAt ¶
func (token *BackupToken) GetUsedAt() time.Time
func (*BackupToken) IsUsed ¶
func (token *BackupToken) IsUsed() bool
IsUsed checks if a token has been used
type DataStore ¶
type DataStore struct { *oauthstore.OauthStore // contains filtered or unexported fields }
DataStore instance storage
func NewDataStore ¶
NewDataStore Create a datastore instance
func (*DataStore) AddAuditEvent ¶
func (dataStore *DataStore) AddAuditEvent(userid, eventType string, eventTime time.Time, data map[string]string) (interface{}, error)
AddAuditEvent creates an audit event in the database
func (*DataStore) AddBackupToken ¶
AddBackupToken creates a backupt token token instance to a user in the database
func (*DataStore) AddBackupTokens ¶
func (dataStore *DataStore) AddBackupTokens(userid string, names, secrets []string) (interface{}, error)
AddBackupToken creates a backupt token token instance to a user in the database
func (*DataStore) AddFidoToken ¶
func (dataStore *DataStore) AddFidoToken(userid, name, keyHandle, publicKey, certificate string, counter uint) (interface{}, error)
AddFidoToken creates a fido token instance in the database
func (*DataStore) AddTotpToken ¶
AddTotpToken adds a TOTP token to the provided user
func (*DataStore) ClearPendingBackupTokens ¶
ClearPendingBackupTokens removes any unused backup tokens
func (*DataStore) CreateActionToken ¶
func (ds *DataStore) CreateActionToken(userExtID, tokenID, action string, expiry time.Time) (interface{}, error)
CreateActionToken adds an action token to the provided user account
func (*DataStore) ForceSync ¶
func (dataStore *DataStore) ForceSync()
ForceSync Drop and create existing tables to match required schema WARNING: do not run this on a live database...
func (*DataStore) GetActionToken ¶
GetActionToken fetches an action token by token id
func (*DataStore) GetActionTokens ¶
GetActionTokens fetches tokens attached to a given user
func (*DataStore) GetAuditEvents ¶
GetAuditEvents fetches a list of audit events for a given userr
func (*DataStore) GetBackupTokenByName ¶
GetBackupTokenByName fetches the named backup token for a specified user
func (*DataStore) GetBackupTokens ¶
GetBackupTokens fetches the backup tokens for the specified user
func (*DataStore) GetFidoTokens ¶
GetFidoTokens fetches the fido tokens for a provided user
func (*DataStore) GetTotpTokens ¶
GetTotpTokens fetches tokens attached to a given user
func (*DataStore) GetUserByEmail ¶
GetUserByEmail Fetches a user account by email
func (*DataStore) GetUserByExtID ¶
GetUserByExtID Fetch a user account by external id
func (*DataStore) GetUserByUsername ¶
GetUserByUsername Fetches a user account by username
func (*DataStore) RemoveFidoToken ¶
RemoveFidoToken deletes a totp token
func (*DataStore) RemoveTotpToken ¶
RemoveTotpToken deletes a totp token
func (*DataStore) UpdateActionToken ¶
UpdateActionToken updates a TOTP token instance in the database
func (*DataStore) UpdateBackupToken ¶
UpdateBackupToken updates a backup token instance
func (*DataStore) UpdateFidoToken ¶
UpdateFidoToken updates a fido token instance
func (*DataStore) UpdateTotpToken ¶
UpdateTotpToken updates a TOTP token instance in the database
func (*DataStore) UpdateUser ¶
UpdateUser Update a user object
type FidoToken ¶
type FidoToken struct { gorm.Model ExtID string UserID uint Name string KeyHandle string PublicKey string Certificate string Counter uint LastUsed time.Time }
FidoToken Fido/U2F token object
func (*FidoToken) GetCertificate ¶
GetCertificate fetches the token Certificate
func (*FidoToken) GetCounter ¶
GetCounter fetches the token usage counter
func (*FidoToken) GetKeyHandle ¶
GetKeyHandle fetches the token KeyHandle
func (*FidoToken) GetLastUsed ¶
GetLastUsed fetches the token LastUsed time
func (*FidoToken) GetPublicKey ¶
GetPublicKey fetches the token PublicKey
func (*FidoToken) SetCounter ¶
SetCounter Sets the token usage counter
func (*FidoToken) SetLastUsed ¶
SetLastUsed sets the token LastUsed time
type QueryFilter ¶
type QueryFilter struct { Limit uint // Number of objects to return Offset uint // Offset of objects to return }
QueryFilter filter types
type TotpToken ¶
type TotpToken struct { gorm.Model ExtID string UserID uint Name string Secret string UsageCount uint LastUsed time.Time }
TotpToken Time based One Time Password Token object
func (*TotpToken) GetCounter ¶
GetCounter fetches the fido token Counter
func (*TotpToken) GetLastUsed ¶
GetLastUsed fetches the fido token LastUsed time
func (*TotpToken) SetCounter ¶
SetCounter sets the fido token usage counter
func (*TotpToken) SetLastUsed ¶
SetLastUsed sets the fido token LastUsed time
type User ¶
type User struct { ID uint `gorm:"primary_key" description:"External user ID"` CreatedAt time.Time `description:"Creation time"` UpdatedAt time.Time `description:"Last update time"` DeletedAt *time.Time ExtID string `gorm:"not null;unique"` Email string `gorm:"not null;unique"` Username string `gorm:"not null;unique"` Password string `gorm:"not null"` PasswordChanged time.Time Activated bool `gorm:"not null; default:false"` Enabled bool `gorm:"not null; default:false"` Locked bool `gorm:"not null; default:false"` Admin bool `gorm:"not null; default:false"` LoginRetries uint `gorm:"not null; default:0"` LastLogin time.Time ActionTokens []ActionToken FidoTokens []FidoToken TotpTokens []TotpToken BackupTokens []BackupToken AuditEvents []AuditEvent OauthClients []oauthstore.OauthClient OauthAccessTokenSessions []oauthstore.OauthAccessToken OauthAuthorizeCodeSessions []oauthstore.OauthAuthorizeCode OauthRefreshTokenSessions []oauthstore.OauthRefreshToken }
User represents the user for this application
func (*User) ClearLoginRetries ¶
func (u *User) ClearLoginRetries()
ClearLoginRetries clears a users login retry count
func (*User) GetCreatedAt ¶
GetCreatedAt fetches a users account creation time
func (*User) GetLastLogin ¶
GetLastLogin fetches a users LastLogin time
func (*User) GetLoginRetries ¶
GetLoginRetries fetches a users login retry count
func (*User) GetPasswordChanged ¶
GetPasswordChanged fetches a users PasswordChanged time
func (*User) IsActivated ¶
IsActivated checks if a user is activated
func (*User) SecondFactors ¶
SecondFactors Checks if a user has attached second factors
func (*User) SetActivated ¶
SetActivated sets a users activated status
func (*User) SetEnabled ¶
SetEnabled sets a users enabled status
func (*User) SetLastLogin ¶
SetLastLogin sets a users LastLogin time
func (*User) SetLoginRetries ¶
SetLoginRetries sets a users login retry count