models

package
v4.34.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationAttempt

type AuthenticationAttempt struct {
	ID            int       `db:"id"`
	Time          time.Time `db:"time"`
	Successful    bool      `db:"successful"`
	Banned        bool      `db:"banned"`
	Username      string    `db:"username"`
	Type          string    `db:"auth_type"`
	RemoteIP      NullIP    `db:"remote_ip"`
	RequestURI    string    `db:"request_uri"`
	RequestMethod string    `db:"request_method"`
}

AuthenticationAttempt represents an authentication attempt row in the database.

type Base64 added in v4.34.0

type Base64 struct {
	// contains filtered or unexported fields
}

Base64 saves bytes to the database as a base64 encoded string.

func NewBase64 added in v4.34.0

func NewBase64(data []byte) Base64

NewBase64 returns a new Base64.

func (Base64) Bytes added in v4.34.0

func (b Base64) Bytes() []byte

Bytes returns the Base64 string encoded as bytes.

func (*Base64) Scan added in v4.34.0

func (b *Base64) Scan(src interface{}) (err error)

Scan is the Base64 implementation of the sql.Scanner.

func (Base64) String added in v4.34.0

func (b Base64) String() string

String returns the Base64 string encoded as base64.

func (Base64) Value added in v4.34.0

func (b Base64) Value() (value driver.Value, err error)

Value is the Base64 implementation of the databases/sql driver.Valuer.

type DuoDevice added in v4.33.0

type DuoDevice struct {
	ID       int    `db:"id"`
	Username string `db:"username"`
	Device   string `db:"device"`
	Method   string `db:"method"`
}

DuoDevice represents a DUO Device.

type IP added in v4.33.0

type IP struct {
	IP net.IP
}

IP is a type specific for storage of a net.IP in the database which can't be NULL.

func NewIP added in v4.33.0

func NewIP(value net.IP) (ip IP)

NewIP easily constructs a new IP.

func (*IP) Scan added in v4.33.0

func (ip *IP) Scan(src interface{}) (err error)

Scan is the IP implementation of the sql.Scanner.

func (IP) Value added in v4.33.0

func (ip IP) Value() (value driver.Value, err error)

Value is the IP implementation of the databases/sql driver.Valuer.

type IdentityVerification added in v4.33.0

type IdentityVerification struct {
	ID         int        `db:"id"`
	JTI        uuid.UUID  `db:"jti"`
	IssuedAt   time.Time  `db:"iat"`
	IssuedIP   IP         `db:"issued_ip"`
	ExpiresAt  time.Time  `db:"exp"`
	Action     string     `db:"action"`
	Username   string     `db:"username"`
	Consumed   *time.Time `db:"consumed"`
	ConsumedIP NullIP     `db:"consumed_ip"`
}

IdentityVerification represents an identity verification row in the database.

func NewIdentityVerification added in v4.33.0

func NewIdentityVerification(jti uuid.UUID, username, action string, ip net.IP) (verification IdentityVerification)

NewIdentityVerification creates a new IdentityVerification from a given username and action.

func (IdentityVerification) ToIdentityVerificationClaim added in v4.33.0

func (v IdentityVerification) ToIdentityVerificationClaim() (claim *IdentityVerificationClaim)

ToIdentityVerificationClaim converts the IdentityVerification into a IdentityVerificationClaim.

type IdentityVerificationClaim added in v4.33.0

type IdentityVerificationClaim struct {
	jwt.RegisteredClaims

	// The action this token has been crafted for.
	Action string `json:"action"`
	// The user this token has been crafted for.
	Username string `json:"username"`
}

IdentityVerificationClaim custom claim for specifying the action claim. The action can be to register a TOTP device, a U2F device or reset one's password.

func (IdentityVerificationClaim) ToIdentityVerification added in v4.33.0

func (v IdentityVerificationClaim) ToIdentityVerification() (verification *IdentityVerification, err error)

ToIdentityVerification converts the IdentityVerificationClaim into a IdentityVerification.

type Migration added in v4.33.0

type Migration struct {
	ID      int       `db:"id"`
	Applied time.Time `db:"applied"`
	Before  int       `db:"version_before"`
	After   int       `db:"version_after"`
	Version string    `db:"application_version"`
}

Migration represents a migration row in the database.

type NullIP added in v4.33.0

type NullIP struct {
	IP net.IP
}

NullIP is a type specific for storage of a net.IP in the database which can also be NULL.

func NewNullIP added in v4.33.0

func NewNullIP(value net.IP) (ip NullIP)

NewNullIP easily constructs a new NullIP.

func NewNullIPFromString added in v4.33.0

func NewNullIPFromString(value string) (ip NullIP)

NewNullIPFromString easily constructs a new NullIP from a string.

func (*NullIP) Scan added in v4.33.0

func (ip *NullIP) Scan(src interface{}) (err error)

Scan is the NullIP implementation of the sql.Scanner.

func (NullIP) Value added in v4.33.0

func (ip NullIP) Value() (value driver.Value, err error)

Value is the NullIP implementation of the databases/sql driver.Valuer.

type SchemaMigration added in v4.33.0

type SchemaMigration struct {
	Version  int
	Name     string
	Provider string
	Up       bool
	Query    string
}

SchemaMigration represents an intended migration.

func (SchemaMigration) After added in v4.33.0

func (m SchemaMigration) After() (after int)

After returns the version the schema will be at After the migration is applied.

func (SchemaMigration) Before added in v4.33.0

func (m SchemaMigration) Before() (before int)

Before returns the version the schema should be at Before the migration is applied.

type StartupCheck added in v4.33.0

type StartupCheck interface {
	StartupCheck() (err error)
}

StartupCheck represents a provider that has a startup check.

type TOTPConfiguration added in v4.33.0

type TOTPConfiguration struct {
	ID         int        `db:"id" json:"-"`
	CreatedAt  time.Time  `db:"created_at" json:"-"`
	LastUsedAt *time.Time `db:"last_used_at" json:"-"`
	Username   string     `db:"username" json:"-"`
	Issuer     string     `db:"issuer" json:"-"`
	Algorithm  string     `db:"algorithm" json:"-"`
	Digits     uint       `db:"digits" json:"digits"`
	Period     uint       `db:"period" json:"period"`
	Secret     []byte     `db:"secret" json:"-"`
}

TOTPConfiguration represents a users TOTP configuration row in the database.

func (TOTPConfiguration) Image added in v4.34.0

func (c TOTPConfiguration) Image(width, height int) (img image.Image, err error)

Image returns the image.Image of the TOTPConfiguration using the Image func from the return of TOTPConfiguration.Key.

func (TOTPConfiguration) Key added in v4.34.0

func (c TOTPConfiguration) Key() (key *otp.Key, err error)

Key returns the *otp.Key using TOTPConfiguration.URI with otp.NewKeyFromURL.

func (TOTPConfiguration) URI added in v4.33.0

func (c TOTPConfiguration) URI() (uri string)

URI shows the configuration in the URI representation.

func (*TOTPConfiguration) UpdateSignInInfo added in v4.34.0

func (c *TOTPConfiguration) UpdateSignInInfo(now time.Time)

UpdateSignInInfo adjusts the values of the TOTPConfiguration after a sign in.

type U2FDevice added in v4.33.0

type U2FDevice struct {
	ID          int    `db:"id"`
	Username    string `db:"username"`
	Description string `db:"description"`
	KeyHandle   []byte `db:"key_handle"`
	PublicKey   []byte `db:"public_key"`
}

U2FDevice represents a users U2F device row in the database.

type UserInfo added in v4.33.0

type UserInfo struct {
	// The users display name.
	DisplayName string `db:"-" json:"display_name"`

	// The preferred 2FA method.
	Method string `db:"second_factor_method" json:"method" valid:"required"`

	// True if a TOTP device has been registered.
	HasTOTP bool `db:"has_totp" json:"has_totp" valid:"required"`

	// True if a Webauthn device has been registered.
	HasWebauthn bool `db:"has_webauthn" json:"has_webauthn" valid:"required"`

	// True if a duo device has been configured as the preferred.
	HasDuo bool `db:"has_duo" json:"has_duo" valid:"required"`
}

UserInfo represents the user information required by the web UI.

type WebauthnDevice added in v4.34.0

type WebauthnDevice struct {
	ID              int        `db:"id"`
	CreatedAt       time.Time  `db:"created_at"`
	LastUsedAt      *time.Time `db:"last_used_at"`
	RPID            string     `db:"rpid"`
	Username        string     `db:"username"`
	Description     string     `db:"description"`
	KID             Base64     `db:"kid"`
	PublicKey       []byte     `db:"public_key"`
	AttestationType string     `db:"attestation_type"`
	Transport       string     `db:"transport"`
	AAGUID          uuid.UUID  `db:"aaguid"`
	SignCount       uint32     `db:"sign_count"`
	CloneWarning    bool       `db:"clone_warning"`
}

WebauthnDevice represents a Webauthn Device in the database storage.

func NewWebauthnDeviceFromCredential added in v4.34.0

func NewWebauthnDeviceFromCredential(rpid, username, description string, credential *webauthn.Credential) (device WebauthnDevice)

NewWebauthnDeviceFromCredential creates a WebauthnDevice from a webauthn.Credential.

func (*WebauthnDevice) UpdateSignInInfo added in v4.34.0

func (w *WebauthnDevice) UpdateSignInInfo(config *webauthn.Config, now time.Time, signCount uint32)

UpdateSignInInfo adjusts the values of the WebauthnDevice after a sign in.

type WebauthnUser added in v4.34.0

type WebauthnUser struct {
	Username    string
	DisplayName string
	Devices     []WebauthnDevice
}

WebauthnUser is an object to represent a user for the Webauthn lib.

func (WebauthnUser) HasFIDOU2F added in v4.34.0

func (w WebauthnUser) HasFIDOU2F() bool

HasFIDOU2F returns true if the user has any attestation type `fido-u2f` devices.

func (WebauthnUser) WebAuthnCredentialDescriptors added in v4.34.0

func (w WebauthnUser) WebAuthnCredentialDescriptors() (descriptors []protocol.CredentialDescriptor)

WebAuthnCredentialDescriptors decodes the users credentials into protocol.CredentialDescriptor's.

func (WebauthnUser) WebAuthnCredentials added in v4.34.0

func (w WebauthnUser) WebAuthnCredentials() (credentials []webauthn.Credential)

WebAuthnCredentials implements the webauthn.User interface.

func (WebauthnUser) WebAuthnDisplayName added in v4.34.0

func (w WebauthnUser) WebAuthnDisplayName() string

WebAuthnDisplayName implements the webauthn.User interface.

func (WebauthnUser) WebAuthnID added in v4.34.0

func (w WebauthnUser) WebAuthnID() []byte

WebAuthnID implements the webauthn.User interface.

func (WebauthnUser) WebAuthnIcon added in v4.34.0

func (w WebauthnUser) WebAuthnIcon() string

WebAuthnIcon implements the webauthn.User interface.

func (WebauthnUser) WebAuthnName added in v4.34.0

func (w WebauthnUser) WebAuthnName() string

WebAuthnName implements the webauthn.User interface.

Jump to

Keyboard shortcuts

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