model

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MigrationsTable = "`migrations`"

MigrationsTable is the name of the table in the DB.

View Source
const UserAuthTable = "`user_auth`"

UserAuthTable is the name of the table in the DB.

View Source
const UserGroupMemberTable = "`user_group_member`"

UserGroupMemberTable is the name of the table in the DB.

View Source
const UserGroupTable = "`user_group`"

UserGroupTable is the name of the table in the DB.

View Source
const UserPasskeyTable = "`user_passkey`"

UserPasskeyTable is the name of the table in the DB.

View Source
const UserSessionTable = "`user_session`"

UserSessionTable is the name of the table in the DB.

View Source
const UserTable = "`user`"

UserTable is the name of the table in the DB.

View Source
const UserTokenRevokedTable = "`user_token_revoked`"

UserTokenRevokedTable is the name of the table in the DB.

Variables

View Source
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.

View Source
var MigrationsFields = []string{"project", "filename", "statement_index", "status"}

MigrationsFields is a list of all columns in the DB table.

View Source
var MigrationsPrimaryFields = []string{"project", "filename"}

MigrationsPrimaryFields are the primary key fields in the DB table.

View Source
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.

View Source
var UserAuthPrimaryFields = []string{"user_id"}

UserAuthPrimaryFields are the primary key fields in the DB table.

View Source
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.

View Source
var UserGroupFields = []string{"id", "title", "created_at", "updated_at"}

UserGroupFields is a list of all columns in the DB table.

View Source
var UserGroupMemberFields = []string{"user_group_id", "user_id", "joined_at"}

UserGroupMemberFields is a list of all columns in the DB table.

View Source
var UserGroupMemberPrimaryFields = []string{"user_group_id", "user_id"}

UserGroupMemberPrimaryFields are the primary key fields in the DB table.

View Source
var UserGroupPrimaryFields = []string{"id"}

UserGroupPrimaryFields are the primary key fields in the DB table.

View Source
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.

View Source
var UserPasskeyPrimaryFields = []string{"id"}

UserPasskeyPrimaryFields are the primary key fields in the DB table.

View Source
var UserPrimaryFields = []string{"id"}

UserPrimaryFields are the primary key fields in the DB table.

View Source
var UserSessionFields = []string{"id", "user_id", "expires_at", "created_at"}

UserSessionFields is a list of all columns in the DB table.

View Source
var UserSessionPrimaryFields = []string{"id"}

UserSessionPrimaryFields are the primary key fields in the DB table.

View Source
var UserTokenRevokedFields = []string{"jti", "user_id", "expires_at", "created_at"}

UserTokenRevokedFields is a list of all columns in the DB table.

View Source
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 NewUser

func NewUser() *User

NewUser creates a new empty User.

func (*User) Delete

func (u *User) Delete(opts ...QueryOption) string

Delete starts building a DELETE query.

func (*User) GetCreatedAt

func (u *User) GetCreatedAt() *time.Time

GetCreatedAt will return the value of CreatedAt.

func (*User) GetDeletedAt

func (u *User) GetDeletedAt() *time.Time

GetDeletedAt will return the value of DeletedAt.

func (*User) GetFullName

func (u *User) GetFullName() string

GetFullName will return the value of FullName.

func (*User) GetID

func (u *User) GetID() string

GetID will return the value of ID.

func (*User) GetSlug

func (u *User) GetSlug() string

GetSlug will return the value of Slug.

func (*User) GetUpdatedAt

func (u *User) GetUpdatedAt() *time.Time

GetUpdatedAt will return the value of UpdatedAt.

func (*User) GetUsername

func (u *User) GetUsername() string

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) Ok

func (u *User) Ok() bool

Ok reports whether the User is valid.

func (*User) Select

func (u *User) Select(opts ...QueryOption) string

Select starts building a SELECT query.

func (*User) SetCreatedAt

func (u *User) SetCreatedAt(stamp time.Time)

SetCreatedAt sets CreatedAt to the provided value.

func (*User) SetDeletedAt

func (u *User) SetDeletedAt(stamp time.Time)

SetDeletedAt sets DeletedAt to the provided value.

func (*User) SetFullName

func (u *User) SetFullName(val string)

SetFullName sets FullName to the provided value.

func (*User) SetID

func (u *User) SetID(val string)

SetID sets ID to the provided value.

func (*User) SetSlug

func (u *User) SetSlug(val string)

SetSlug sets Slug to the provided value.

func (*User) SetUpdatedAt

func (u *User) SetUpdatedAt(stamp time.Time)

SetUpdatedAt sets UpdatedAt to the provided value.

func (*User) SetUsername

func (u *User) SetUsername(val string)

SetUsername sets Username to the provided value.

func (*User) String

func (u *User) String() string

String returns a string representation of the User.

func (*User) Update

func (u *User) Update(opts ...QueryOption) string

Update starts building a UPDATE query.

func (*User) Validate

func (u *User) Validate() error

Validate checks that the User is non-nil, has an ID, and is not deleted.

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

func (u *UserAuth) GetActivatedAt() *time.Time

GetActivatedAt will return the value of ActivatedAt.

func (*UserAuth) GetActivationSentAt

func (u *UserAuth) GetActivationSentAt() *time.Time

GetActivationSentAt will return the value of ActivationSentAt.

func (*UserAuth) GetActivationToken

func (u *UserAuth) GetActivationToken() string

GetActivationToken will return the value of ActivationToken.

func (*UserAuth) GetCreatedAt

func (u *UserAuth) GetCreatedAt() *time.Time

GetCreatedAt will return the value of CreatedAt.

func (*UserAuth) GetEmail

func (u *UserAuth) GetEmail() string

GetEmail will return the value of Email.

func (*UserAuth) GetPassword

func (u *UserAuth) GetPassword() string

GetPassword will return the value of Password.

func (*UserAuth) GetUpdatedAt

func (u *UserAuth) GetUpdatedAt() *time.Time

GetUpdatedAt will return the value of UpdatedAt.

func (*UserAuth) GetUserID

func (u *UserAuth) GetUserID() string

GetUserID will return the value of UserID.

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

func (u *UserAuth) SetActivatedAt(stamp time.Time)

SetActivatedAt sets ActivatedAt to the provided value.

func (*UserAuth) SetActivationSentAt

func (u *UserAuth) SetActivationSentAt(stamp time.Time)

SetActivationSentAt sets ActivationSentAt to the provided value.

func (*UserAuth) SetActivationToken

func (u *UserAuth) SetActivationToken(val string)

SetActivationToken sets ActivationToken to the provided value.

func (*UserAuth) SetCreatedAt

func (u *UserAuth) SetCreatedAt(stamp time.Time)

SetCreatedAt sets CreatedAt to the provided value.

func (*UserAuth) SetEmail

func (u *UserAuth) SetEmail(val string)

SetEmail sets Email to the provided value.

func (*UserAuth) SetPassword

func (u *UserAuth) SetPassword(val string)

SetPassword sets Password to the provided value.

func (*UserAuth) SetUpdatedAt

func (u *UserAuth) SetUpdatedAt(stamp time.Time)

SetUpdatedAt sets UpdatedAt to the provided value.

func (*UserAuth) SetUserID

func (u *UserAuth) SetUserID(val string)

SetUserID sets UserID to the provided value.

func (*UserAuth) Update

func (u *UserAuth) Update(opts ...QueryOption) string

Update starts building a UPDATE query.

func (*UserAuth) Valid

func (u *UserAuth) Valid() bool

Valid reports whether the UserAuth has an email and password.

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 NewUserGroup

func NewUserGroup() *UserGroup

NewUserGroup creates a new empty UserGroup.

func (*UserGroup) Delete

func (u *UserGroup) Delete(opts ...QueryOption) string

Delete starts building a DELETE query.

func (*UserGroup) GetCreatedAt

func (u *UserGroup) GetCreatedAt() *time.Time

GetCreatedAt will return the value of CreatedAt.

func (*UserGroup) GetID

func (u *UserGroup) GetID() string

GetID will return the value of ID.

func (*UserGroup) GetTitle

func (u *UserGroup) GetTitle() string

GetTitle will return the value of Title.

func (*UserGroup) GetUpdatedAt

func (u *UserGroup) GetUpdatedAt() *time.Time

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

func (u *UserGroup) SetCreatedAt(stamp time.Time)

SetCreatedAt sets CreatedAt to the provided value.

func (*UserGroup) SetID

func (u *UserGroup) SetID(val string)

SetID sets ID to the provided value.

func (*UserGroup) SetTitle

func (u *UserGroup) SetTitle(val string)

SetTitle sets Title to the provided value.

func (*UserGroup) SetUpdatedAt

func (u *UserGroup) SetUpdatedAt(stamp time.Time)

SetUpdatedAt sets UpdatedAt to the provided value.

func (*UserGroup) String

func (u *UserGroup) String() string

String returns the title of the UserGroup.

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) GetID

func (u *UserPasskey) GetID() string

GetID will return the value of ID.

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) GetID

func (u *UserSession) GetID() string

GetID will return the value of ID.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL