models

package
v1.2.27 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: AGPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrForbidden    = errors.New("forbidden")
	ErrUnauthorized = errors.New("unauthorized")
)
View Source
var Mails = MailTemplates{
	EmailUpdate:   template.Must(template.New(LangEN.String()).Parse(emailUpdateEn)),
	PasswordReset: template.Must(template.New(LangEN.String()).Parse(passwordResetEn)),
	Register:      template.Must(template.New(LangEN.String()).Parse(registerEn)),
}

Functions

This section is empty.

Types

type AccessTokenClaims

type AccessTokenClaims struct {
	// ID of the user that created the session. Can be empty for anonymous sessions.
	UserID *uuid.UUID `json:"userID,omitempty"`
	// Roles is a list of Role attributed to the session.
	Roles []Role `json:"roles"`
	// The ID of the refresh token that created the session. If the session was created using direct login, this
	// field is empty.
	RefreshTokenID *string `json:"refreshTokenID,omitempty"`
}

AccessTokenClaims is authenticated (signed) information about a session. This data is embed in the access tokens.

type CredentialRoleImportance

type CredentialRoleImportance int
const (
	CredentialRoleImportanceUnknown    CredentialRoleImportance = 0
	CredentialRoleImportanceUser       CredentialRoleImportance = 1
	CredentialRoleImportanceAdmin      CredentialRoleImportance = 2
	CredentialRoleImportanceSuperAdmin CredentialRoleImportance = 3
)

func (CredentialRoleImportance) Int added in v1.0.0

func (importance CredentialRoleImportance) Int() int

type CredentialsRole

type CredentialsRole string
const (
	CredentialsRoleUser       CredentialsRole = "user"
	CredentialsRoleAdmin      CredentialsRole = "admin"
	CredentialsRoleSuperAdmin CredentialsRole = "super_admin"
)

func (CredentialsRole) String added in v1.0.0

func (role CredentialsRole) String() string

type CredentialsRoles added in v1.0.0

type CredentialsRoles []CredentialsRole

func (CredentialsRoles) Strings added in v1.0.0

func (roles CredentialsRoles) Strings() []string

type Lang

type Lang string
const (
	LangFR Lang = "fr"
	LangEN Lang = "en"
)

func (Lang) String

func (l Lang) String() string

type MailTemplates added in v1.0.0

type MailTemplates struct {
	EmailUpdate   *template.Template
	PasswordReset *template.Template
	Register      *template.Template
}

type Permission

type Permission string

Permission is a special attribute that grants a session access to an authenticated resource. Each service may define its own set of authorizations.

type RefreshTokenClaims

type RefreshTokenClaims struct {
	// ID of the user that created the session. Can be empty for anonymous sessions.
	Jti string `json:"jti"`
	// ID of the user that created the session.
	UserID uuid.UUID `json:"userID"`
}

type RefreshTokenClaimsInput added in v0.6.0

type RefreshTokenClaimsInput struct {
	// ID of the user that created the session.
	UserID uuid.UUID `json:"userID"`
}

type Role

type Role string

Role is a special attributes that is assigned to a session. It grants said session a given set of Permission.

const (
	// RoleAnon represents an anonymous user.
	RoleAnon Role = "auth:anon"
	// RoleUser represents a regular user.
	RoleUser Role = "auth:user"
	// RoleAdmin represents an administrator.
	RoleAdmin Role = "auth:admin"
	// RoleSuperAdmin represents a super administrator.
	RoleSuperAdmin Role = "auth:super_admin"
)

type SMTPURLsConfig added in v1.0.0

type SMTPURLsConfig struct {
	UpdateEmail    string `json:"updateEmail"    yaml:"updateEmail"`
	UpdatePassword string `json:"updatePassword" yaml:"updatePassword"`
	Register       string `json:"register"       yaml:"register"`
}

type ShortCode

type ShortCode struct {
	ID uuid.UUID

	// Information about the resource the short code grants access to.
	Usage ShortCodeUsage
	// The target that is allowed to access the resource. Only this target can retrieve the short code.
	Target string
	// Data used for the targeted resource. It can contain any information required to perform a specific action.
	Data []byte

	// Time at which the short code was created.
	CreatedAt time.Time
	// Expiration of the short code. Each short code is REQUIRED to expire past a certain time. Once the expiration date
	// is reached, the short code can no longer be used or retrieved.
	ExpiresAt time.Time

	// PlainCode is the clear password sent to the target via a secure channel.
	PlainCode string
}

ShortCode is a temporary password used to grant a user one-time access to a specific resource. Once a resource is accessed using a short code, the short code is expired.

type ShortCodeUsage

type ShortCodeUsage string

ShortCodeUsage gives information about the intended usage of a short code.

const (
	ShortCodeUsageValidateMail    ShortCodeUsage = "validateMail"
	ShortCodeUsageResetPassword   ShortCodeUsage = "resetPassword"
	ShortCodeUsageRequestRegister ShortCodeUsage = "requestRegister"
)

func (ShortCodeUsage) String added in v1.0.0

func (usage ShortCodeUsage) String() string

type Token added in v0.5.0

type Token struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken,omitempty"`
}

type User

type User struct {
	ID        uuid.UUID
	Email     string
	Role      CredentialsRole
	CreatedAt time.Time
	UpdatedAt time.Time
}

Directories

Path Synopsis
Code generated by ogen, DO NOT EDIT.
Code generated by ogen, DO NOT EDIT.
mails

Jump to

Keyboard shortcuts

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