db

package
v0.0.0-...-1c52440 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangePassword

func ChangePassword(db *gorm.DB, email string, passwordHash []byte) error

func ConfirmUser

func ConfirmUser(db *gorm.DB, confirmation *UserConfirmation) error

func CreateClient

func CreateClient(db *gorm.DB, client *Client) error

func CreateClientScope

func CreateClientScope(db *gorm.DB, clientID string, scope string) error

func CreateConfirmation

func CreateConfirmation(db *gorm.DB, confirmation *UserConfirmation) error

func CreateCredential

func CreateCredential(db *gorm.DB, credential *UserCredential) error

func CreateOIDCClient

func CreateOIDCClient(db *gorm.DB, client *OidcClient) error

func CreateRole

func CreateRole(db *gorm.DB, role *Role) error

func CreateScope

func CreateScope(db *gorm.DB, scope string) error

func CreateUser

func CreateUser(db *gorm.DB, user *User) error

func DeleteClientScope

func DeleteClientScope(db *gorm.DB, clientID string, scope string) error

func DeleteCredential

func DeleteCredential(db *gorm.DB, email string, id []byte) error

func DeleteOIDCClient

func DeleteOIDCClient(db *gorm.DB, name string) error

func DeleteScope

func DeleteScope(db *gorm.DB, scope string) error

func ExpireAllConfirmation

func ExpireAllConfirmation(db *gorm.DB, email string) error

func GetCredentialDescriptors

func GetCredentialDescriptors(db *gorm.DB, email string) ([]protocol.CredentialDescriptor, error)

func GetCredentialNames

func GetCredentialNames(db *gorm.DB, email string) ([]string, error)

func HasRole

func HasRole(db *gorm.DB, email string, name string) bool

func HasUsers

func HasUsers(db *gorm.DB) (bool, error)

func IsScopeExist

func IsScopeExist(db *gorm.DB, scope string) (bool, error)

func IsScopeInUse

func IsScopeInUse(db *gorm.DB, scope string) (bool, error)

func ListClientScopes

func ListClientScopes(db *gorm.DB, clientID string) ([]string, error)

func ListScopes

func ListScopes(db *gorm.DB) ([]string, error)

func Migrate

func Migrate(db *gorm.DB)

func UpdateClient

func UpdateClient(db *gorm.DB, client *Client) error

func UpdateCredential

func UpdateCredential(db *gorm.DB, email string, id []byte, friendlyName string) error

func UpdateOIDCClient

func UpdateOIDCClient(db *gorm.DB, client *OidcClient) error

Types

type Client

type Client struct {
	ClientID     string `gorm:"primary_key;unique;not null"`
	ClientSecret string `gorm:"not null"`
	RedirectURI  string
	IsPublic     bool
	UserEmail    string `gorm:"not null"`
	User         User   `gorm:"foreignKey:UserEmail"`
}

func GetClient

func GetClient(db *gorm.DB, clientID string) (*Client, error)

func GetClients

func GetClients(db *gorm.DB) ([]Client, error)

type ClientScope

type ClientScope struct {
	ClientID  string `gorm:"uniqueIndex:idx_uniq_client_scope,priority:1;not null"`
	ScopeName string `gorm:"uniqueIndex:idx_uniq_client_scope,priority:2;not null"`
	Client    Client `gorm:"foreignKey:ClientID"`
	Scope     Scope  `gorm:"foreignKey:ScopeName"`
}

type OidcClient

type OidcClient struct {
	Name         string `gorm:"primary_key;unique;not null"`
	ClientID     string `gorm:"not null"`
	ClientSecret string `gorm:"not null"`
	RedirectURI  string `gorm:"not null"`
	ButtonName   string `gorm:"not null"`
}

func GetOIDCClient

func GetOIDCClient(db *gorm.DB, name string) (*OidcClient, error)

func ListOIDCClients

func ListOIDCClients(db *gorm.DB) ([]OidcClient, error)

type Role

type Role struct {
	Name string `gorm:"primary_key;unique;not null"`
}

type Scope

type Scope struct {
	Name string `gorm:"primary_key;unique;not null"`
}

type User

type User struct {
	Email          string    `gorm:"primary_key;unique;not null"`
	PasswordHash   []byte    `gorm:"not null"`
	DisplayName    string    `gorm:""`
	WebAuthnUserID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4()"`
	Credentials    []UserCredential
	Roles          []Role `gorm:"many2many:user_roles;"`
	IsEnabled      bool   `gorm:"default:false;not null"`
}

func GetUser

func GetUser(db *gorm.DB, email string) (*User, error)

func ListUsers

func ListUsers(db *gorm.DB) ([]User, error)

func (*User) WebAuthnCredentials

func (user *User) WebAuthnCredentials() []webauthn.Credential

func (*User) WebAuthnDisplayName

func (user *User) WebAuthnDisplayName() string

func (*User) WebAuthnID

func (user *User) WebAuthnID() []byte

func (*User) WebAuthnIcon

func (user *User) WebAuthnIcon() string

func (*User) WebAuthnName

func (user *User) WebAuthnName() string

type UserConfirmation

type UserConfirmation struct {
	UserEmail       string `gorm:"primary_key;unique;not null"`
	OneTimePassword string `gorm:"not null"`
	ExpiryTime      int64  `gorm:"not null"`
	ConfirmedTime   int64  `gorm:"not null"`
	User            User   `gorm:"foreignKey:UserEmail"`
}

func GetConfirmation

func GetConfirmation(db *gorm.DB, otp string) (*UserConfirmation, error)

type UserCredential

type UserCredential struct {
	ID              []byte                            `gorm:"primary_key;unique;not null"`
	PublicKey       []byte                            `gorm:"unique;not null"`
	AttestationType string                            `gorm:"not null"`
	Transport       []protocol.AuthenticatorTransport `gorm:"type:text[]"`
	UserPresent     bool                              `gorm:"not null"`
	UserVerified    bool                              `gorm:"not null"`
	BackupEligible  bool                              `gorm:"not null"`
	BackupState     bool                              `gorm:"not null"`
	AAGUID          []byte                            `gorm:"not null"`
	SignCount       uint32                            `gorm:"not null"`
	CloneWarning    bool                              `gorm:"not null"`
	Attachment      protocol.AuthenticatorAttachment  `gorm:"not null"`
	UserEmail       string                            `gorm:"uniqueIndex:idx_uniq_credential_name,priority:1;not null"`
	FriendlyName    string                            `gorm:"uniqueIndex:idx_uniq_credential_name,priority:2;not null"`
	User            User                              `gorm:"foreignKey:UserEmail"`
}

func GetCredentials

func GetCredentials(db *gorm.DB, email string) ([]UserCredential, error)

func NewUserCredential

func NewUserCredential(email string, friendlyName string, cred *webauthn.Credential) *UserCredential

type UserRole

type UserRole struct {
	UserEmail string `gorm:"uniqueIndex:idx_uniq_user_role,priority:1;not null"`
	RoleName  string `gorm:"uniqueIndex:idx_uniq_user_role,priority:2;not null"`
	User      User   `gorm:"foreignKey:UserEmail"`
	Role      Role   `gorm:"foreignKey:RoleName"`
}

Jump to

Keyboard shortcuts

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