Documentation
¶
Index ¶
- Constants
- Variables
- func TransportJSON(transports []protocol.AuthenticatorTransport) string
- type AuthOptions
- type Migrations
- func (m *Migrations) Delete(opts ...QueryOption) string
- func (m *Migrations) GetFilename() string
- func (m *Migrations) GetProject() string
- func (m *Migrations) GetStatementIndex() int64
- func (m *Migrations) GetStatus() string
- func (m *Migrations) Insert(opts ...QueryOption) string
- func (m *Migrations) Select(opts ...QueryOption) string
- func (m *Migrations) SetFilename(val string)
- func (m *Migrations) SetProject(val string)
- func (m *Migrations) SetStatementIndex(val int64)
- func (m *Migrations) SetStatus(val string)
- func (m *Migrations) Update(opts ...QueryOption) string
- type PasskeyStorage
- type QueryConfig
- func (q *QueryConfig) Apply(opts ...QueryOption) *QueryConfig
- func (q *QueryConfig) WithColumns(cols []string) QueryOption
- func (q *QueryConfig) WithLimit(start, offset int) QueryOption
- func (q *QueryConfig) WithOrderBy(clause string) QueryOption
- func (q *QueryConfig) WithStatement(stmt string) QueryOption
- func (q *QueryConfig) WithTable(name string) QueryOption
- func (q *QueryConfig) WithWhere(clause string) QueryOption
- type QueryOption
- type SessionStorage
- type User
- func (u *User) Delete(opts ...QueryOption) string
- func (u *User) GetCreatedAt() *time.Time
- func (u *User) GetDeletedAt() *time.Time
- func (u *User) GetFullName() string
- func (u *User) GetID() string
- func (u *User) GetSlug() string
- func (u *User) GetUpdatedAt() *time.Time
- func (u *User) GetUsername() string
- func (u *User) Insert(opts ...QueryOption) string
- func (u *User) Ok() bool
- func (u *User) Select(opts ...QueryOption) string
- func (u *User) SetCreatedAt(stamp time.Time)
- func (u *User) SetDeletedAt(stamp time.Time)
- func (u *User) SetFullName(val string)
- func (u *User) SetID(val string)
- func (u *User) SetSlug(val string)
- func (u *User) SetUpdatedAt(stamp time.Time)
- func (u *User) SetUsername(val string)
- func (u *User) String() string
- func (u *User) Update(opts ...QueryOption) string
- func (u *User) Validate() error
- type UserAuth
- func (u *UserAuth) Delete(opts ...QueryOption) string
- func (u *UserAuth) GetActivatedAt() *time.Time
- func (u *UserAuth) GetActivationSentAt() *time.Time
- func (u *UserAuth) GetActivationToken() string
- func (u *UserAuth) GetCreatedAt() *time.Time
- func (u *UserAuth) GetEmail() string
- func (u *UserAuth) GetPassword() string
- func (u *UserAuth) GetUpdatedAt() *time.Time
- func (u *UserAuth) GetUserID() string
- func (u *UserAuth) Insert(opts ...QueryOption) string
- func (u *UserAuth) Select(opts ...QueryOption) string
- func (u *UserAuth) SetActivatedAt(stamp time.Time)
- func (u *UserAuth) SetActivationSentAt(stamp time.Time)
- func (u *UserAuth) SetActivationToken(val string)
- func (u *UserAuth) SetCreatedAt(stamp time.Time)
- func (u *UserAuth) SetEmail(val string)
- func (u *UserAuth) SetPassword(val string)
- func (u *UserAuth) SetUpdatedAt(stamp time.Time)
- func (u *UserAuth) SetUserID(val string)
- func (u *UserAuth) Update(opts ...QueryOption) string
- func (u *UserAuth) Valid() bool
- type UserCreateRequest
- type UserGroup
- func (u *UserGroup) Delete(opts ...QueryOption) string
- func (u *UserGroup) GetCreatedAt() *time.Time
- func (u *UserGroup) GetID() string
- func (u *UserGroup) GetTitle() string
- func (u *UserGroup) GetUpdatedAt() *time.Time
- func (u *UserGroup) Insert(opts ...QueryOption) string
- func (u *UserGroup) Select(opts ...QueryOption) string
- func (u *UserGroup) SetCreatedAt(stamp time.Time)
- func (u *UserGroup) SetID(val string)
- func (u *UserGroup) SetTitle(val string)
- func (u *UserGroup) SetUpdatedAt(stamp time.Time)
- func (u *UserGroup) String() string
- func (u *UserGroup) Update(opts ...QueryOption) string
- type UserGroupMember
- func (u *UserGroupMember) Delete(opts ...QueryOption) string
- func (u *UserGroupMember) GetJoinedAt() *time.Time
- func (u *UserGroupMember) GetUserGroupID() string
- func (u *UserGroupMember) GetUserID() string
- func (u *UserGroupMember) Insert(opts ...QueryOption) string
- func (u *UserGroupMember) Select(opts ...QueryOption) string
- func (u *UserGroupMember) SetJoinedAt(stamp time.Time)
- func (u *UserGroupMember) SetUserGroupID(val string)
- func (u *UserGroupMember) SetUserID(val string)
- func (u *UserGroupMember) Update(opts ...QueryOption) string
- type UserPasskey
- func (u *UserPasskey) Delete(opts ...QueryOption) string
- func (u *UserPasskey) GetAttestationType() string
- func (u *UserPasskey) GetCreatedAt() *time.Time
- func (u *UserPasskey) GetCredentialID() []byte
- func (u *UserPasskey) GetID() string
- func (u *UserPasskey) GetPublicKey() []byte
- func (u *UserPasskey) GetSignCount() int64
- func (u *UserPasskey) GetTransport() string
- func (u *UserPasskey) GetUserID() string
- func (u *UserPasskey) Insert(opts ...QueryOption) string
- func (u *UserPasskey) Select(opts ...QueryOption) string
- func (u *UserPasskey) SetAttestationType(val string)
- func (u *UserPasskey) SetCreatedAt(stamp time.Time)
- func (u *UserPasskey) SetCredentialID(val []byte)
- func (u *UserPasskey) SetID(val string)
- func (u *UserPasskey) SetPublicKey(val []byte)
- func (u *UserPasskey) SetSignCount(val int64)
- func (u *UserPasskey) SetTransport(val string)
- func (u *UserPasskey) SetUserID(val string)
- func (p *UserPasskey) ToCredential() webauthn.Credential
- func (u *UserPasskey) Update(opts ...QueryOption) string
- type UserSession
- func (u *UserSession) Delete(opts ...QueryOption) string
- func (u *UserSession) GetCreatedAt() *time.Time
- func (u *UserSession) GetExpiresAt() *time.Time
- func (u *UserSession) GetID() string
- func (u *UserSession) GetUserID() string
- func (u *UserSession) Insert(opts ...QueryOption) string
- func (u *UserSession) Ok() bool
- func (u *UserSession) Select(opts ...QueryOption) string
- func (u *UserSession) SetCreatedAt(stamp time.Time)
- func (u *UserSession) SetExpiresAt(stamp time.Time)
- func (u *UserSession) SetID(val string)
- func (u *UserSession) SetUserID(val string)
- func (u *UserSession) Update(opts ...QueryOption) string
- func (u *UserSession) Validate() error
- type UserStorage
- type UserTokenRevoked
- func (u *UserTokenRevoked) Delete(opts ...QueryOption) string
- func (u *UserTokenRevoked) GetCreatedAt() *time.Time
- func (u *UserTokenRevoked) GetExpiresAt() *time.Time
- func (u *UserTokenRevoked) GetJti() string
- func (u *UserTokenRevoked) GetUserID() string
- func (u *UserTokenRevoked) Insert(opts ...QueryOption) string
- func (u *UserTokenRevoked) Select(opts ...QueryOption) string
- func (u *UserTokenRevoked) SetCreatedAt(stamp time.Time)
- func (u *UserTokenRevoked) SetExpiresAt(stamp time.Time)
- func (u *UserTokenRevoked) SetJti(val string)
- func (u *UserTokenRevoked) SetUserID(val string)
- func (u *UserTokenRevoked) Update(opts ...QueryOption) string
- type WebAuthnUser
Constants ¶
const MigrationsTable = "`migrations`"
MigrationsTable is the name of the table in the DB.
const UserAuthTable = "`user_auth`"
UserAuthTable is the name of the table in the DB.
const UserGroupMemberTable = "`user_group_member`"
UserGroupMemberTable is the name of the table in the DB.
const UserGroupTable = "`user_group`"
UserGroupTable is the name of the table in the DB.
const UserPasskeyTable = "`user_passkey`"
UserPasskeyTable is the name of the table in the DB.
const UserSessionTable = "`user_session`"
UserSessionTable is the name of the table in the DB.
const UserTable = "`user`"
UserTable is the name of the table in the DB.
const UserTokenRevokedTable = "`user_token_revoked`"
UserTokenRevokedTable is the name of the table in the DB.
Variables ¶
var ( ErrSessionExpired = errors.New("Your session has expired") ErrUsernameMissing = errors.New("username is required") ErrUsernameMinLength = errors.New("username must be more than 3 characters") ErrUsernameInvalid = errors.New("username must contain only lowercase letters, numbers, underscores and dashes, and must not begin or end with underscore or dash") ErrUsernameMaxLength = errors.New("username must be 20 characters or less") ErrUsernameTaken = errors.New("username is already taken") // ErrInvalidActivationToken is returned by UserStorage.Activate when // the supplied token does not match any pending activation row. ErrInvalidActivationToken = errors.New("invalid activation token") // ErrUserAlreadyActivated is returned when a resend or activate // operation finds the user is already past the activation gate. ErrUserAlreadyActivated = errors.New("user already activated") // ErrUserNotActivated is the error surfaced by API handlers when // EmailActivationEnabled is on and a user attempts to log in or // otherwise act on an account that has not been activated yet. ErrUserNotActivated = errors.New("user has not activated their account") )
Errors returned by user validation and storage operations.
var MigrationsFields = []string{"project", "filename", "statement_index", "status"}
MigrationsFields is a list of all columns in the DB table.
var MigrationsPrimaryFields = []string{"project", "filename"}
MigrationsPrimaryFields are the primary key fields in the DB table.
var UserAuthFields = []string{"user_id", "email", "password", "created_at", "updated_at", "activated_at", "activation_token", "activation_sent_at"}
UserAuthFields is a list of all columns in the DB table.
var UserAuthPrimaryFields = []string{"user_id"}
UserAuthPrimaryFields are the primary key fields in the DB table.
var UserFields = []string{"id", "full_name", "username", "slug", "deleted_at", "created_at", "updated_at"}
UserFields is a list of all columns in the DB table.
var UserGroupFields = []string{"id", "title", "created_at", "updated_at"}
UserGroupFields is a list of all columns in the DB table.
var UserGroupMemberFields = []string{"user_group_id", "user_id", "joined_at"}
UserGroupMemberFields is a list of all columns in the DB table.
var UserGroupMemberPrimaryFields = []string{"user_group_id", "user_id"}
UserGroupMemberPrimaryFields are the primary key fields in the DB table.
var UserGroupPrimaryFields = []string{"id"}
UserGroupPrimaryFields are the primary key fields in the DB table.
var UserPasskeyFields = []string{"id", "user_id", "credential_id", "public_key", "attestation_type", "transport", "sign_count", "created_at"}
UserPasskeyFields is a list of all columns in the DB table.
var UserPasskeyPrimaryFields = []string{"id"}
UserPasskeyPrimaryFields are the primary key fields in the DB table.
var UserPrimaryFields = []string{"id"}
UserPrimaryFields are the primary key fields in the DB table.
var UserSessionFields = []string{"id", "user_id", "expires_at", "created_at"}
UserSessionFields is a list of all columns in the DB table.
var UserSessionPrimaryFields = []string{"id"}
UserSessionPrimaryFields are the primary key fields in the DB table.
var UserTokenRevokedFields = []string{"jti", "user_id", "expires_at", "created_at"}
UserTokenRevokedFields is a list of all columns in the DB table.
var UserTokenRevokedPrimaryFields = []string{"jti"}
UserTokenRevokedPrimaryFields are the primary key fields in the DB table.
Functions ¶
func TransportJSON ¶
func TransportJSON(transports []protocol.AuthenticatorTransport) string
TransportJSON returns the JSON encoding of the given transports.
Types ¶
type AuthOptions ¶
type AuthOptions struct {
// Cookie if true will read in CookieName for a session ID.
Cookie bool
CookieName string
// Header if true will read in HeaderName for a request auth token.
// Authorization already produces the user ID based on JWT claims.
Header bool
HeaderName string
// Query if true will read QueryName for a JWT token from URL query params.
Query bool
QueryName string
// This is a JWT specific option.
HeaderSigningKey string
// Optional if true will not block the request on auth failure.
Optional bool
}
AuthOptions holds incoming parameters for the service. Best keep it flat, requires some field prefixing.
type Migrations ¶
type Migrations struct {
// Project
Project string `db:"project" json:"project"`
// Filename
Filename string `db:"filename" json:"filename"`
// Statement Index
StatementIndex int64 `db:"statement_index" json:"statement_index"`
// Status
Status string `db:"status" json:"status"`
}
Migrations generated for db table `migrations`.
func (*Migrations) Delete ¶
func (m *Migrations) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*Migrations) GetFilename ¶
func (m *Migrations) GetFilename() string
GetFilename will return the value of Filename.
func (*Migrations) GetProject ¶
func (m *Migrations) GetProject() string
GetProject will return the value of Project.
func (*Migrations) GetStatementIndex ¶
func (m *Migrations) GetStatementIndex() int64
GetStatementIndex will return the value of StatementIndex.
func (*Migrations) GetStatus ¶
func (m *Migrations) GetStatus() string
GetStatus will return the value of Status.
func (*Migrations) Insert ¶
func (m *Migrations) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*Migrations) Select ¶
func (m *Migrations) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*Migrations) SetFilename ¶
func (m *Migrations) SetFilename(val string)
SetFilename sets Filename to the provided value.
func (*Migrations) SetProject ¶
func (m *Migrations) SetProject(val string)
SetProject sets Project to the provided value.
func (*Migrations) SetStatementIndex ¶
func (m *Migrations) SetStatementIndex(val int64)
SetStatementIndex sets StatementIndex to the provided value.
func (*Migrations) SetStatus ¶
func (m *Migrations) SetStatus(val string)
SetStatus sets Status to the provided value.
func (*Migrations) Update ¶
func (m *Migrations) Update(opts ...QueryOption) string
Update starts building a UPDATE query.
type PasskeyStorage ¶
type PasskeyStorage interface {
Create(ctx context.Context, passkey *UserPasskey) (*UserPasskey, error)
Delete(ctx context.Context, id string) error
ListByUser(ctx context.Context, userID string) ([]UserPasskey, error)
GetByCredentialID(ctx context.Context, credentialID []byte) (*UserPasskey, error)
UpdateSignCount(ctx context.Context, id string, signCount int64) error
}
PasskeyStorage defines the storage operations for WebAuthn passkeys.
type QueryConfig ¶
type QueryConfig struct {
Table string
Columns []string
Where string
OrderBy string
LimitStart int
LimitOffset int
Statement string
}
QueryConfig is a function-chaining SQL statement type.
func (*QueryConfig) Apply ¶
func (q *QueryConfig) Apply(opts ...QueryOption) *QueryConfig
Apply will use passed query options to populate the query.
func (*QueryConfig) WithColumns ¶
func (q *QueryConfig) WithColumns(cols []string) QueryOption
WithColumns will set the columns to use for the query.
func (*QueryConfig) WithLimit ¶
func (q *QueryConfig) WithLimit(start, offset int) QueryOption
WithLimit will set the limit clause parameters for the query.
func (*QueryConfig) WithOrderBy ¶
func (q *QueryConfig) WithOrderBy(clause string) QueryOption
WithOrderBy will set the order by clause for the query.
func (*QueryConfig) WithStatement ¶
func (q *QueryConfig) WithStatement(stmt string) QueryOption
WithStatement will change the statement for the query.
func (*QueryConfig) WithTable ¶
func (q *QueryConfig) WithTable(name string) QueryOption
WithTable will set the table name for the query.
func (*QueryConfig) WithWhere ¶
func (q *QueryConfig) WithWhere(clause string) QueryOption
WithWhere will set the where condition for the query.
type QueryOption ¶
type QueryOption interface {
WithTable(name string) QueryOption
WithColumns(cols []string) QueryOption
WithWhere(clause string) QueryOption
WithOrderBy(clause string) QueryOption
WithLimit(start, offset int) QueryOption
WithStatement(stmt string) QueryOption
}
QueryOption is implemented by each data model type.
func WithColumns ¶
func WithColumns(cols []string) QueryOption
WithColumns will set the columns to use for the query.
func WithLimit ¶
func WithLimit(start, offset int) QueryOption
WithLimit will set the limit clause parameters for the query.
func WithOrderBy ¶
func WithOrderBy(clause string) QueryOption
WithOrderBy will set the order by clause for the query.
func WithStatement ¶
func WithStatement(stmt string) QueryOption
WithStatement will change the statement for the query.
func WithTable ¶
func WithTable(name string) QueryOption
WithTable will set the table name for the query.
func WithWhere ¶
func WithWhere(clause string) QueryOption
WithWhere will set the where condition for the query.
type SessionStorage ¶
type SessionStorage interface {
Create(ctx context.Context, userID string) (*UserSession, error)
Get(ctx context.Context, sessionID string) (*UserSession, error)
Delete(ctx context.Context, sessionID string) error
}
SessionStorage defines the storage operations for user sessions.
type User ¶
type User struct {
// ID
ID string `db:"id" json:"id"`
// Full Name
FullName string `db:"full_name" json:"full_name"`
// Username
Username string `db:"username" json:"username"`
// Slug
Slug string `db:"slug" json:"slug"`
// Deleted At
DeletedAt *time.Time `db:"deleted_at" json:"deleted_at"`
// Created At
CreatedAt *time.Time `db:"created_at" json:"created_at"`
// Updated At
UpdatedAt *time.Time `db:"updated_at" json:"updated_at"`
}
User generated for db table `user`.
func (*User) Delete ¶
func (u *User) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*User) GetCreatedAt ¶
GetCreatedAt will return the value of CreatedAt.
func (*User) GetDeletedAt ¶
GetDeletedAt will return the value of DeletedAt.
func (*User) GetFullName ¶
GetFullName will return the value of FullName.
func (*User) GetUpdatedAt ¶
GetUpdatedAt will return the value of UpdatedAt.
func (*User) GetUsername ¶
GetUsername will return the value of Username.
func (*User) Insert ¶
func (u *User) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*User) Select ¶
func (u *User) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*User) SetCreatedAt ¶
SetCreatedAt sets CreatedAt to the provided value.
func (*User) SetDeletedAt ¶
SetDeletedAt sets DeletedAt to the provided value.
func (*User) SetFullName ¶
SetFullName sets FullName to the provided value.
func (*User) SetUpdatedAt ¶
SetUpdatedAt sets UpdatedAt to the provided value.
func (*User) SetUsername ¶
SetUsername sets Username to the provided value.
func (*User) Update ¶
func (u *User) Update(opts ...QueryOption) string
Update starts building a UPDATE query.
type UserAuth ¶
type UserAuth struct {
// User ID
UserID string `db:"user_id" json:"user_id"`
// Email
Email string `db:"email" json:"email"`
// Password
Password string `db:"password" json:"password"`
// Created At
CreatedAt *time.Time `db:"created_at" json:"created_at"`
// Updated At
UpdatedAt *time.Time `db:"updated_at" json:"updated_at"`
// Activated At
ActivatedAt *time.Time `db:"activated_at" json:"activated_at"`
// Activation Token
ActivationToken string `db:"activation_token" json:"activation_token"`
// Activation Sent At
ActivationSentAt *time.Time `db:"activation_sent_at" json:"activation_sent_at"`
}
UserAuth generated for db table `user_auth`.
User Auth.
func (*UserAuth) Delete ¶
func (u *UserAuth) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*UserAuth) GetActivatedAt ¶
GetActivatedAt will return the value of ActivatedAt.
func (*UserAuth) GetActivationSentAt ¶
GetActivationSentAt will return the value of ActivationSentAt.
func (*UserAuth) GetActivationToken ¶
GetActivationToken will return the value of ActivationToken.
func (*UserAuth) GetCreatedAt ¶
GetCreatedAt will return the value of CreatedAt.
func (*UserAuth) GetPassword ¶
GetPassword will return the value of Password.
func (*UserAuth) GetUpdatedAt ¶
GetUpdatedAt will return the value of UpdatedAt.
func (*UserAuth) Insert ¶
func (u *UserAuth) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*UserAuth) Select ¶
func (u *UserAuth) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*UserAuth) SetActivatedAt ¶
SetActivatedAt sets ActivatedAt to the provided value.
func (*UserAuth) SetActivationSentAt ¶
SetActivationSentAt sets ActivationSentAt to the provided value.
func (*UserAuth) SetActivationToken ¶
SetActivationToken sets ActivationToken to the provided value.
func (*UserAuth) SetCreatedAt ¶
SetCreatedAt sets CreatedAt to the provided value.
func (*UserAuth) SetPassword ¶
SetPassword sets Password to the provided value.
func (*UserAuth) SetUpdatedAt ¶
SetUpdatedAt sets UpdatedAt to the provided value.
func (*UserAuth) Update ¶
func (u *UserAuth) Update(opts ...QueryOption) string
Update starts building a UPDATE query.
type UserCreateRequest ¶
type UserCreateRequest struct {
FullName string `json:"full_name"`
Email string `json:"email"`
Password string `json:"password"`
Username string `json:"username,omitempty"`
}
UserCreateRequest holds the fields required to create a new user.
func (*UserCreateRequest) User ¶
func (r *UserCreateRequest) User() *User
User converts the UserCreateRequest into a User.
func (*UserCreateRequest) UserAuth ¶
func (r *UserCreateRequest) UserAuth() *UserAuth
UserAuth converts the UserCreateRequest into a UserAuth.
func (*UserCreateRequest) Valid ¶
func (r *UserCreateRequest) Valid() bool
Valid reports whether the UserCreateRequest has all required fields.
func (*UserCreateRequest) ValidateUsername ¶
func (r *UserCreateRequest) ValidateUsername() error
ValidateUsername checks that the username meets length and format requirements.
type UserGroup ¶
type UserGroup struct {
// ID
ID string `db:"id" json:"id"`
// Title
Title string `db:"title" json:"title"`
// Created At
CreatedAt *time.Time `db:"created_at" json:"created_at"`
// Updated At
UpdatedAt *time.Time `db:"updated_at" json:"updated_at"`
}
UserGroup generated for db table `user_group`.
User Group.
func (*UserGroup) Delete ¶
func (u *UserGroup) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*UserGroup) GetCreatedAt ¶
GetCreatedAt will return the value of CreatedAt.
func (*UserGroup) GetUpdatedAt ¶
GetUpdatedAt will return the value of UpdatedAt.
func (*UserGroup) Insert ¶
func (u *UserGroup) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*UserGroup) Select ¶
func (u *UserGroup) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*UserGroup) SetCreatedAt ¶
SetCreatedAt sets CreatedAt to the provided value.
func (*UserGroup) SetUpdatedAt ¶
SetUpdatedAt sets UpdatedAt to the provided value.
func (*UserGroup) Update ¶
func (u *UserGroup) Update(opts ...QueryOption) string
Update starts building a UPDATE query.
type UserGroupMember ¶
type UserGroupMember struct {
// User Group ID
UserGroupID string `db:"user_group_id" json:"user_group_id"`
// User ID
UserID string `db:"user_id" json:"user_id"`
// Joined At
JoinedAt *time.Time `db:"joined_at" json:"joined_at"`
}
UserGroupMember generated for db table `user_group_member`.
User Group Member.
func (*UserGroupMember) Delete ¶
func (u *UserGroupMember) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*UserGroupMember) GetJoinedAt ¶
func (u *UserGroupMember) GetJoinedAt() *time.Time
GetJoinedAt will return the value of JoinedAt.
func (*UserGroupMember) GetUserGroupID ¶
func (u *UserGroupMember) GetUserGroupID() string
GetUserGroupID will return the value of UserGroupID.
func (*UserGroupMember) GetUserID ¶
func (u *UserGroupMember) GetUserID() string
GetUserID will return the value of UserID.
func (*UserGroupMember) Insert ¶
func (u *UserGroupMember) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*UserGroupMember) Select ¶
func (u *UserGroupMember) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*UserGroupMember) SetJoinedAt ¶
func (u *UserGroupMember) SetJoinedAt(stamp time.Time)
SetJoinedAt sets JoinedAt to the provided value.
func (*UserGroupMember) SetUserGroupID ¶
func (u *UserGroupMember) SetUserGroupID(val string)
SetUserGroupID sets UserGroupID to the provided value.
func (*UserGroupMember) SetUserID ¶
func (u *UserGroupMember) SetUserID(val string)
SetUserID sets UserID to the provided value.
func (*UserGroupMember) Update ¶
func (u *UserGroupMember) Update(opts ...QueryOption) string
Update starts building a UPDATE query.
type UserPasskey ¶
type UserPasskey struct {
// ID
ID string `db:"id" json:"id"`
// User ID
UserID string `db:"user_id" json:"user_id"`
// Credential ID
CredentialID []byte `db:"credential_id" json:"credential_id"`
// Public Key
PublicKey []byte `db:"public_key" json:"public_key"`
// Attestation Type
AttestationType string `db:"attestation_type" json:"attestation_type"`
// Transport
Transport string `db:"transport" json:"transport"`
// Sign Count
SignCount int64 `db:"sign_count" json:"sign_count"`
// Created At
CreatedAt *time.Time `db:"created_at" json:"created_at"`
}
UserPasskey generated for db table `user_passkey`.
User Passkey.
func (*UserPasskey) Delete ¶
func (u *UserPasskey) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*UserPasskey) GetAttestationType ¶
func (u *UserPasskey) GetAttestationType() string
GetAttestationType will return the value of AttestationType.
func (*UserPasskey) GetCreatedAt ¶
func (u *UserPasskey) GetCreatedAt() *time.Time
GetCreatedAt will return the value of CreatedAt.
func (*UserPasskey) GetCredentialID ¶
func (u *UserPasskey) GetCredentialID() []byte
GetCredentialID will return the value of CredentialID.
func (*UserPasskey) GetPublicKey ¶
func (u *UserPasskey) GetPublicKey() []byte
GetPublicKey will return the value of PublicKey.
func (*UserPasskey) GetSignCount ¶
func (u *UserPasskey) GetSignCount() int64
GetSignCount will return the value of SignCount.
func (*UserPasskey) GetTransport ¶
func (u *UserPasskey) GetTransport() string
GetTransport will return the value of Transport.
func (*UserPasskey) GetUserID ¶
func (u *UserPasskey) GetUserID() string
GetUserID will return the value of UserID.
func (*UserPasskey) Insert ¶
func (u *UserPasskey) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*UserPasskey) Select ¶
func (u *UserPasskey) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*UserPasskey) SetAttestationType ¶
func (u *UserPasskey) SetAttestationType(val string)
SetAttestationType sets AttestationType to the provided value.
func (*UserPasskey) SetCreatedAt ¶
func (u *UserPasskey) SetCreatedAt(stamp time.Time)
SetCreatedAt sets CreatedAt to the provided value.
func (*UserPasskey) SetCredentialID ¶
func (u *UserPasskey) SetCredentialID(val []byte)
SetCredentialID sets CredentialID to the provided value.
func (*UserPasskey) SetID ¶
func (u *UserPasskey) SetID(val string)
SetID sets ID to the provided value.
func (*UserPasskey) SetPublicKey ¶
func (u *UserPasskey) SetPublicKey(val []byte)
SetPublicKey sets PublicKey to the provided value.
func (*UserPasskey) SetSignCount ¶
func (u *UserPasskey) SetSignCount(val int64)
SetSignCount sets SignCount to the provided value.
func (*UserPasskey) SetTransport ¶
func (u *UserPasskey) SetTransport(val string)
SetTransport sets Transport to the provided value.
func (*UserPasskey) SetUserID ¶
func (u *UserPasskey) SetUserID(val string)
SetUserID sets UserID to the provided value.
func (*UserPasskey) ToCredential ¶
func (p *UserPasskey) ToCredential() webauthn.Credential
ToCredential converts a stored UserPasskey to a webauthn.Credential.
func (*UserPasskey) Update ¶
func (u *UserPasskey) Update(opts ...QueryOption) string
Update starts building a UPDATE query.
type UserSession ¶
type UserSession struct {
// ID
ID string `db:"id" json:"id"`
// User ID
UserID string `db:"user_id" json:"user_id"`
// Expires At
ExpiresAt *time.Time `db:"expires_at" json:"expires_at"`
// Created At
CreatedAt *time.Time `db:"created_at" json:"created_at"`
}
UserSession generated for db table `user_session`.
User Session.
func NewUserSession ¶
func NewUserSession() *UserSession
NewUserSession creates a new empty UserSession.
func (*UserSession) Delete ¶
func (u *UserSession) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*UserSession) GetCreatedAt ¶
func (u *UserSession) GetCreatedAt() *time.Time
GetCreatedAt will return the value of CreatedAt.
func (*UserSession) GetExpiresAt ¶
func (u *UserSession) GetExpiresAt() *time.Time
GetExpiresAt will return the value of ExpiresAt.
func (*UserSession) GetUserID ¶
func (u *UserSession) GetUserID() string
GetUserID will return the value of UserID.
func (*UserSession) Insert ¶
func (u *UserSession) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*UserSession) Ok ¶
func (u *UserSession) Ok() bool
Ok reports whether the UserSession is valid.
func (*UserSession) Select ¶
func (u *UserSession) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*UserSession) SetCreatedAt ¶
func (u *UserSession) SetCreatedAt(stamp time.Time)
SetCreatedAt sets CreatedAt to the provided value.
func (*UserSession) SetExpiresAt ¶
func (u *UserSession) SetExpiresAt(stamp time.Time)
SetExpiresAt sets ExpiresAt to the provided value.
func (*UserSession) SetID ¶
func (u *UserSession) SetID(val string)
SetID sets ID to the provided value.
func (*UserSession) SetUserID ¶
func (u *UserSession) SetUserID(val string)
SetUserID sets UserID to the provided value.
func (*UserSession) Update ¶
func (u *UserSession) Update(opts ...QueryOption) string
Update starts building a UPDATE query.
func (*UserSession) Validate ¶
func (u *UserSession) Validate() error
Validate checks that the UserSession is non-nil, populated, and not expired.
type UserStorage ¶
type UserStorage interface {
Create(context.Context, *UserCreateRequest) (*User, error)
Update(context.Context, *User) (*User, error)
Get(context.Context, string) (*User, error)
GetByUsername(context.Context, string) (*User, error)
GetByStub(context.Context, string) (*User, error)
GetGroups(context.Context, string) ([]UserGroup, error)
List(context.Context) ([]User, error)
Authenticate(context.Context, UserAuth) (*User, error)
Activate(ctx context.Context, token string) (*User, error)
ResetActivation(ctx context.Context, email string) error
}
UserStorage defines the storage operations for users.
type UserTokenRevoked ¶
type UserTokenRevoked struct {
// Jti
Jti string `db:"jti" json:"jti"`
// User ID
UserID string `db:"user_id" json:"user_id"`
// Expires At
ExpiresAt *time.Time `db:"expires_at" json:"expires_at"`
// Created At
CreatedAt *time.Time `db:"created_at" json:"created_at"`
}
UserTokenRevoked generated for db table `user_token_revoked`.
User Token Revoked.
func (*UserTokenRevoked) Delete ¶
func (u *UserTokenRevoked) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*UserTokenRevoked) GetCreatedAt ¶
func (u *UserTokenRevoked) GetCreatedAt() *time.Time
GetCreatedAt will return the value of CreatedAt.
func (*UserTokenRevoked) GetExpiresAt ¶
func (u *UserTokenRevoked) GetExpiresAt() *time.Time
GetExpiresAt will return the value of ExpiresAt.
func (*UserTokenRevoked) GetJti ¶
func (u *UserTokenRevoked) GetJti() string
GetJti will return the value of Jti.
func (*UserTokenRevoked) GetUserID ¶
func (u *UserTokenRevoked) GetUserID() string
GetUserID will return the value of UserID.
func (*UserTokenRevoked) Insert ¶
func (u *UserTokenRevoked) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*UserTokenRevoked) Select ¶
func (u *UserTokenRevoked) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*UserTokenRevoked) SetCreatedAt ¶
func (u *UserTokenRevoked) SetCreatedAt(stamp time.Time)
SetCreatedAt sets CreatedAt to the provided value.
func (*UserTokenRevoked) SetExpiresAt ¶
func (u *UserTokenRevoked) SetExpiresAt(stamp time.Time)
SetExpiresAt sets ExpiresAt to the provided value.
func (*UserTokenRevoked) SetJti ¶
func (u *UserTokenRevoked) SetJti(val string)
SetJti sets Jti to the provided value.
func (*UserTokenRevoked) SetUserID ¶
func (u *UserTokenRevoked) SetUserID(val string)
SetUserID sets UserID to the provided value.
func (*UserTokenRevoked) Update ¶
func (u *UserTokenRevoked) Update(opts ...QueryOption) string
Update starts building a UPDATE query.
type WebAuthnUser ¶
type WebAuthnUser struct {
*User
Passkeys []UserPasskey
}
WebAuthnUser wraps a User with passkey credentials for the webauthn.User interface.
func (*WebAuthnUser) WebAuthnCredentials ¶
func (u *WebAuthnUser) WebAuthnCredentials() []webauthn.Credential
WebAuthnCredentials returns the user's stored passkey credentials.
func (*WebAuthnUser) WebAuthnDisplayName ¶
func (u *WebAuthnUser) WebAuthnDisplayName() string
WebAuthnDisplayName returns the full name.
func (*WebAuthnUser) WebAuthnID ¶
func (u *WebAuthnUser) WebAuthnID() []byte
WebAuthnID returns the user handle as bytes.
func (*WebAuthnUser) WebAuthnName ¶
func (u *WebAuthnUser) WebAuthnName() string
WebAuthnName returns the username.