dto

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnabledProviders

func GetEnabledProviders(providers config.ThirdPartyProviders) []string

func NewHTTPErrorHandler

func NewHTTPErrorHandler(config HTTPErrorHandlerConfig) func(err error, c echo.Context)

func ToHttpError

func ToHttpError(err error) *echo.HTTPError

func TransformValidationErrors

func TransformValidationErrors(err error) []string

func UseEnterpriseConnection

func UseEnterpriseConnection(samlConfig *samlConfig.Saml) bool

Types

type Account

type Account struct {
	AllowDeletion bool `json:"allow_deletion"`
	AllowSignup   bool `json:"allow_signup"`
}

type Claims

type Claims struct {
	Subject      uuid.UUID              `json:"subject"`
	IssuedAt     *time.Time             `json:"issued_at,omitempty"`
	Expiration   time.Time              `json:"expiration"`
	Audience     []string               `json:"audience,omitempty"`
	Issuer       *string                `json:"issuer,omitempty"`
	Email        *EmailJWT              `json:"email,omitempty"`
	Username     *string                `json:"username,omitempty"`
	SessionID    uuid.UUID              `json:"session_id"`
	CustomClaims map[string]interface{} `json:"-"`
}

func GetClaimsFromToken

func GetClaimsFromToken(token jwt.Token) (*Claims, error)

func (Claims) MarshalJSON

func (c Claims) MarshalJSON() ([]byte, error)

Custom MarshalJSON to flatten CustomClaims into the top level

type CreateUserResponse

type CreateUserResponse struct {
	ID      uuid.UUID `json:"id"` // deprecated
	UserID  uuid.UUID `json:"user_id"`
	EmailID uuid.UUID `json:"email_id"`
}

type CustomValidator

type CustomValidator struct {
	Validator *validator.Validate
}

func NewCustomValidator

func NewCustomValidator() *CustomValidator

func (*CustomValidator) Validate

func (cv *CustomValidator) Validate(i interface{}) error

type EmailCreateRequest

type EmailCreateRequest struct {
	Address string `json:"address"`
}

type EmailJWT

type EmailJWT struct {
	Address    string `json:"address"`
	IsPrimary  bool   `json:"is_primary"`
	IsVerified bool   `json:"is_verified"`
}

func EmailJWTFromEmailModel

func EmailJWTFromEmailModel(email *models.Email) *EmailJWT

func (*EmailJWT) String

func (e *EmailJWT) String() string

type EmailResponse

type EmailResponse struct {
	ID         uuid.UUID  `json:"id"`
	Address    string     `json:"address"`
	IsVerified bool       `json:"is_verified"`
	IsPrimary  bool       `json:"is_primary"`
	Identity   *Identity  `json:"identity,omitempty"` // Deprecated
	Identities Identities `json:"identities,omitempty"`
}

func FromEmailModel

func FromEmailModel(email *models.Email, cfg *config.Config) *EmailResponse

FromEmailModel Converts the DB model to a DTO object

type EmailUpdateRequest

type EmailUpdateRequest struct {
	IsPrimary *bool `json:"is_primary"`
}

type Emails

type Emails struct {
	RequireVerification bool `json:"require_verification"`
	MaxNumOfAddresses   int  `json:"max_num_of_addresses"`
}

type GetUserResponse

type GetUserResponse struct {
	ID                  uuid.UUID                   `json:"id"`
	Email               *string                     `json:"email,omitempty"`
	Username            *string                     `json:"username,omitempty"`
	WebauthnCredentials []models.WebauthnCredential `json:"webauthn_credentials"` // deprecated
	UpdatedAt           time.Time                   `json:"updated_at"`
	CreatedAt           time.Time                   `json:"created_at"`
	Metadata            *Metadata                   `json:"metadata,omitempty"`
	ProfileData         `json:",inline"`
}

type HTTPErrorHandlerConfig

type HTTPErrorHandlerConfig struct {
	Debug  bool
	Logger echo.Logger
}

type Identities

type Identities []Identity

func FromIdentitiesModel

func FromIdentitiesModel(identities models.Identities, cfg *config.Config) Identities

type Identity

type Identity struct {
	ID       string `json:"id"`
	Provider string `json:"provider"`
}

func FromIdentityModel

func FromIdentityModel(identity *models.Identity, cfg *config.Config) *Identity

type MFAConfig

type MFAConfig struct {
	AuthAppSetUp        bool `json:"auth_app_set_up"`
	TOTPEnabled         bool `json:"totp_enabled"`
	SecurityKeysEnabled bool `json:"security_keys_enabled"`
}

type Metadata

type Metadata struct {
	Public json.RawMessage `json:"public_metadata,omitempty"`
	Unsafe json.RawMessage `json:"unsafe_metadata,omitempty"`
}

Metadata represents user metadata with public and unsafe fields

func NewMetadata

func NewMetadata(metadata *models.UserMetadata) *Metadata

NewMetadata creates a new Metadata DTO from a UserMetadata model

type MetadataJWT

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

MetadataJWT represents user metadata with public and unsafe fields. This metadata representation is used for JWT template processing. Fields are private on purpose since the type provides dedicated methods with the same name for accessing the data during template processing.

func MetadataJWTFromUserModel

func MetadataJWTFromUserModel(metadata *models.UserMetadata) *MetadataJWT

MetadataJWTFromUserModel creates a new MetadataJWT DTO from a UserMetadata model

func NewMetadataJWT

func NewMetadataJWT(public, unsafe json.RawMessage) *MetadataJWT

NewMetadataJWT creates a new MetadataJWT from public and unsafe metadata JSON raw messages. Primarily used in tests to construct a MetadataJWT (due to private fields)

func (*MetadataJWT) MarshalJSON

func (m *MetadataJWT) MarshalJSON() ([]byte, error)

func (*MetadataJWT) Public

func (m *MetadataJWT) Public(path ...string) string

func (*MetadataJWT) String

func (m *MetadataJWT) String() string

func (*MetadataJWT) Unsafe

func (m *MetadataJWT) Unsafe(path ...string) string

type PasscodeFinishRequest

type PasscodeFinishRequest struct {
	Id   string `json:"id" validate:"required,uuid4"`
	Code string `json:"code" validate:"required"`
}

type PasscodeInitRequest

type PasscodeInitRequest struct {
	UserId  string  `json:"user_id" validate:"required,uuid"`
	EmailId *string `json:"email_id"`
}

type PasscodeReturn

type PasscodeReturn struct {
	Id        string    `json:"id"`
	TTL       int       `json:"ttl"`
	CreatedAt time.Time `json:"created_at"`
}

type Password

type Password struct {
	Enabled   bool `json:"enabled"`
	MinLength int  `json:"min_password_length"`
}

type ProfileData

type ProfileData struct {
	UserID       uuid.UUID                    `json:"user_id"`
	Passkeys     []WebauthnCredentialResponse `json:"passkeys,omitempty"`
	SecurityKeys []WebauthnCredentialResponse `json:"security_keys,omitempty"`
	MFAConfig    MFAConfig                    `json:"mfa_config"`
	Emails       []EmailResponse              `json:"emails,omitempty"`
	Username     *Username                    `json:"username,omitempty"`
	CreatedAt    time.Time                    `json:"created_at"`
	UpdatedAt    time.Time                    `json:"updated_at"`
	Metadata     *Metadata                    `json:"metadata,omitempty"`
}

func ProfileDataFromUserModel

func ProfileDataFromUserModel(user *models.User, cfg *config.Config) *ProfileData

type PublicConfig

type PublicConfig struct {
	Password                Password `json:"password"`
	Emails                  Emails   `json:"emails"`
	Providers               []string `json:"providers"`
	Account                 Account  `json:"account"`
	UseEnterpriseConnection bool     `json:"use_enterprise"`
}

PublicConfig is the part of the configuration that will be shared with the frontend

func FromConfig

func FromConfig(cfg config.Config) PublicConfig

FromConfig Returns a PublicConfig from the Application configuration

type SessionData

type SessionData struct {
	ID           uuid.UUID  `json:"id"`
	UserAgentRaw *string    `json:"user_agent_raw,omitempty"`
	UserAgent    *string    `json:"user_agent,omitempty"`
	IpAddress    *string    `json:"ip_address,omitempty"`
	Current      bool       `json:"current"`
	CreatedAt    time.Time  `json:"created_at"`
	ExpiresAt    *time.Time `json:"expires_at,omitempty"`
	LastUsed     time.Time  `json:"last_used"`
}

func FromSessionModel

func FromSessionModel(model models.Session, current bool) SessionData

type ThirdPartyAuthCallback

type ThirdPartyAuthCallback struct {
	AuthCode         string `query:"code"`
	State            string `query:"state" validate:"required"`
	Error            string `query:"error"`
	ErrorDescription string `query:"error_description"`
}

func (ThirdPartyAuthCallback) HasError

func (cb ThirdPartyAuthCallback) HasError() bool

type ThirdPartyAuthRequest

type ThirdPartyAuthRequest struct {
	Provider   string `query:"provider" validate:"required"`
	RedirectTo string `query:"redirect_to" validate:"required,url"`
}

type UserInfoResponse

type UserInfoResponse struct {
	ID                    uuid.UUID `json:"id"`
	EmailID               uuid.UUID `json:"email_id"`
	Verified              bool      `json:"verified"`
	HasWebauthnCredential bool      `json:"has_webauthn_credential"`
}

type UserJWT

type UserJWT struct {
	UserID   string       `json:"user_id"`
	Email    *EmailJWT    `json:"email,omitempty"`
	Username string       `json:"username"`
	Metadata *MetadataJWT `json:"metadata,omitempty"`
}

UserJWT represents an abstracted user model for session management

func UserJWTFromUserModel

func UserJWTFromUserModel(userModel *models.User) UserJWT

func (*UserJWT) String

func (u *UserJWT) String() string

type Username

type Username struct {
	ID        uuid.UUID `json:"id"`
	Username  string    `json:"username"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func FromUsernameModel

func FromUsernameModel(u *models.Username) *Username

type ValidateSessionRequest

type ValidateSessionRequest struct {
	SessionToken string `json:"session_token" validate:"required"`
}

type ValidateSessionResponse

type ValidateSessionResponse struct {
	IsValid bool    `json:"is_valid"`
	Claims  *Claims `json:"claims,omitempty"`
	// deprecated
	ExpirationTime *time.Time `json:"expiration_time,omitempty"`
	// deprecated
	UserID *uuid.UUID `json:"user_id,omitempty"`
}

type ValidationErrors

type ValidationErrors struct {
	Errors []string `json:"errors"`
}

type WebauthnCredentialResponse

type WebauthnCredentialResponse struct {
	ID              string     `json:"id"`
	Name            *string    `json:"name,omitempty"`
	PublicKey       string     `json:"public_key"`
	AttestationType string     `json:"attestation_type"`
	AAGUID          uuid.UUID  `json:"aaguid"`
	LastUsedAt      *time.Time `json:"last_used_at,omitempty"`
	CreatedAt       time.Time  `json:"created_at"`
	Transports      []string   `json:"transports"`
	BackupEligible  bool       `json:"backup_eligible"`
	BackupState     bool       `json:"backup_state"`
	MFAOnly         bool       `json:"mfa_only"`
}

func FromWebauthnCredentialModel

func FromWebauthnCredentialModel(c *models.WebauthnCredential) *WebauthnCredentialResponse

FromWebauthnCredentialModel Converts the DB model to a DTO object

type WebauthnCredentialUpdateRequest

type WebauthnCredentialUpdateRequest struct {
	Name *string `json:"name"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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