object

package
v0.0.0-...-20a8e94 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxPagination = Pagination{
	Limit: math.MaxInt,
	Page:  1,
}

Functions

func CodeChallengeToOIDC

func CodeChallengeToOIDC(challenge *OIDCCodeChallenge) *oidc.CodeChallenge

func RefreshTokenRequestFromBusiness

func RefreshTokenRequestFromBusiness(token *RefreshToken) op.RefreshTokenRequest

RefreshTokenRequestFromBusiness will simply wrap the storage RefreshToken to implement the op.RefreshTokenRequest interface

Types

type AccessToken

type AccessToken struct {
	ID             string
	ApplicationID  string
	Subject        string
	RefreshTokenID string
	Audience       []string
	Expiration     time.Time
	Scopes         []string
}

type Adapter

type Adapter struct {
	ID       string `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID string `json:"tenant_id" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	DisplayName string `json:"display_name"`
	TableName   string `json:"table_name"`
	ExternalDB  bool   `json:"external_db"`

	Driver string `json:"driver"`

	Host         string `json:"host"`
	Port         string `json:"port"`
	Username     string `json:"username"`
	Password     string `json:"password"`
	DatabaseName string `json:"database_name"`
}

func (*Adapter) BeforeCreate

func (base *Adapter) BeforeCreate(db *gorm.DB) error

type AllowView

type AllowView string
const (
	AllowViewPublic AllowView = "public"
	AllowViewSelf   AllowView = "self"
)

type Application

type Application struct {
	ID       string `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID string `json:"tenant_id" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	CreatedAt time.Time `json:"createdAt" format:"date-time"`
	UpdatedAt time.Time `json:"updatedAt" format:"date-time"`

	ClientSecret string `json:"client_secret"`

	DisplayName string `json:"display_name" gorm:"type:varchar(100)" example:"Frontend Application"`

	SignInURL string `json:"sign_in_url" gorm:"type:varchar(255)"`
	SignUpURL string `json:"sign_up_url" gorm:"type:varchar(255)"`
	ForgetURL string `json:"forget_url" gorm:"type:varchar(255)"`
	TermsURL  string `json:"terms_url" gorm:"type:varchar(255)"`

	RedirectURLs []string `json:"redirect_urls" gorm:"serializer:json"`

	Tokens       []Token    `json:"-" swaggerignore:"true"`
	AuthProvider []Provider `json:"auth_provider" gorm:"many2many:auth_application_provider;"`
}

func (*Application) AccessTokenType

func (base *Application) AccessTokenType() op.AccessTokenType

AccessTokenType must return the type of access token the client uses (Bearer (opaque) or JWT)

func (*Application) ApplicationType

func (base *Application) ApplicationType() op.ApplicationType

ApplicationType must return the type of the client (app, native, user agent)

func (*Application) AuthMethod

func (base *Application) AuthMethod() oidc.AuthMethod

AuthMethod must return the authentication method (client_secret_basic, client_secret_post, none, private_key_jwt)

func (*Application) BeforeCreate

func (base *Application) BeforeCreate(db *gorm.DB) error

BeforeCreate is a GORM hook that is called before a new group record is inserted into the database. It generates a unique ID for the group if it is not already set.

Parameters:

  • db: a gorm.DB instance representing the database connection.

Returns:

  • An error if there is any issue generating the unique ID.

func (*Application) ClockSkew

func (base *Application) ClockSkew() time.Duration

ClockSkew enables clients to instruct the OP to apply a clock skew on the various times and expirations (subtract from issued_at, add to expiration, ...)

func (*Application) DevMode

func (base *Application) DevMode() bool

DevMode enables the use of non-compliant configs such as redirect_uris (e.g. http schema for user agent client)

func (*Application) GetID

func (base *Application) GetID() string

GetID must return the client_id

func (*Application) GrantTypes

func (base *Application) GrantTypes() []oidc.GrantType

GrantTypes must return all allowed grant types (authorization_code, refresh_token, urn:ietf:params:oauth:grant-type:jwt-bearer)

func (*Application) IDTokenLifetime

func (base *Application) IDTokenLifetime() time.Duration

IDTokenLifetime must return the lifetime of the client's id_tokens

func (*Application) IDTokenUserinfoClaimsAssertion

func (base *Application) IDTokenUserinfoClaimsAssertion() bool

IDTokenUserinfoClaimsAssertion allows specifying if claims of scope profile, email, phone and address are asserted into the id_token even if an access token if issued which violates the OIDC Core spec (5.4. Requesting Claims using Scope Values: https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims) some clients though require that e.g. email is always in the id_token when requested even if an access_token is issued

func (*Application) IsScopeAllowed

func (base *Application) IsScopeAllowed(scope string) bool

IsScopeAllowed enables Client specific custom scopes validation in this example we allow the CustomScope for all clients

func (*Application) LoginURL

func (base *Application) LoginURL(requestID string) string

LoginURL will be called to redirect the user (agent) to the login UI you could implement some logic here to redirect the users to different login UIs depending on the client

func (*Application) PostLogoutRedirectURIs

func (base *Application) PostLogoutRedirectURIs() []string

PostLogoutRedirectURIs must return the registered post_logout_redirect_uris for sign-outs

func (*Application) RedirectURIs

func (base *Application) RedirectURIs() []string

RedirectURIs must return the registered redirect_uris for Code and Implicit Flow

func (*Application) ResponseTypes

func (base *Application) ResponseTypes() []oidc.ResponseType

ResponseTypes must return all allowed response types (code, id_token token, id_token) these must match with the allowed grant types

func (*Application) RestrictAdditionalAccessTokenScopes

func (base *Application) RestrictAdditionalAccessTokenScopes() func(scopes []string) []string

RestrictAdditionalAccessTokenScopes allows specifying which custom scopes shall be asserted into the JWT access_token

func (*Application) RestrictAdditionalIdTokenScopes

func (base *Application) RestrictAdditionalIdTokenScopes() func(scopes []string) []string

RestrictAdditionalIdTokenScopes allows specifying which custom scopes shall be asserted into the id_token

type AuthRequest

type AuthRequest struct {
	ID            string         `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID      string         `json:"tenant_id" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	ApplicationID string         `json:"application_id" maxLength:"25" minLength:"25" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	UserID        sql.NullString `json:"user_id" maxLength:"25" gorm:"type:char(25)" `

	CreatedAt time.Time `json:"created_at" format:"date-time"`

	CallbackURI   string             `json:"callback_uri"`
	TransferState string             `json:"transfer_state"`
	Prompt        []string           `json:"prompt" gorm:"type:text[]; serializer:json"`
	LoginHint     string             `json:"login_hint"`
	MaxAuthAge    *time.Duration     `json:"max_auth_age"`
	Scopes        []string           `json:"scopes" gorm:"type:text[]; serializer:json"`
	ResponseType  oidc.ResponseType  `json:"response_type"`
	ResponseMode  oidc.ResponseMode  `json:"response_mode"`
	Nonce         string             `json:"nonce"`
	CodeChallenge *OIDCCodeChallenge `json:"code_challenge" gorm:"type:text; serializer:json"`

	Authenticated   bool      `json:"authenticated" format:"date-time"`
	AuthenticatedAt time.Time `json:"authenticated_at" format:"date-time"`
}

func (*AuthRequest) BeforeCreate

func (a *AuthRequest) BeforeCreate(db *gorm.DB) error

BeforeCreate is a GORM hook that is called before a new group record is inserted into the database. It generates a unique ID for the group if it is not already set.

Parameters:

  • db: a gorm.DB instance representing the database connection.

Returns:

  • An error if there is any issue generating the unique ID.

func (AuthRequest) Done

func (a AuthRequest) Done() bool

func (AuthRequest) GetACR

func (a AuthRequest) GetACR() string

func (AuthRequest) GetAMR

func (a AuthRequest) GetAMR() []string

func (AuthRequest) GetAudience

func (a AuthRequest) GetAudience() []string

func (AuthRequest) GetAuthTime

func (a AuthRequest) GetAuthTime() time.Time

func (AuthRequest) GetClientID

func (a AuthRequest) GetClientID() string

func (AuthRequest) GetCodeChallenge

func (a AuthRequest) GetCodeChallenge() *oidc.CodeChallenge

func (AuthRequest) GetID

func (a AuthRequest) GetID() string

func (AuthRequest) GetNonce

func (a AuthRequest) GetNonce() string

func (AuthRequest) GetRedirectURI

func (a AuthRequest) GetRedirectURI() string

func (AuthRequest) GetResponseMode

func (a AuthRequest) GetResponseMode() oidc.ResponseMode

func (AuthRequest) GetResponseType

func (a AuthRequest) GetResponseType() oidc.ResponseType

func (AuthRequest) GetScopes

func (a AuthRequest) GetScopes() []string

func (AuthRequest) GetState

func (a AuthRequest) GetState() string

func (AuthRequest) GetSubject

func (a AuthRequest) GetSubject() string

type Certificate

type Certificate struct {
	IDs      string `json:"id" gorm:"column:id;primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID string `json:"tenant_id" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	CreatedAt time.Time `json:"created_at" format:"date-time"`
	UpdatedAt time.Time `json:"updated_at" format:"date-time"`

	DisplayName string    `json:"display_name" gorm:"type:varchar(100)" maxLength:"100" example:"Certification Title"`
	Algo        string    `json:"algorithm" gorm:"type:varchar(100)" maxLength:"100" example:"RS512"`
	BitSize     int       `json:"bit_size" example:"2048"`
	ExpiredAt   time.Time `json:"expired_at" format:"date-time"`

	Certificate string `json:"certificate"`
	PrivateKey  string `json:"private_key"`
}

func (Certificate) Algorithm

func (base Certificate) Algorithm() jose.SignatureAlgorithm

func (*Certificate) BeforeCreate

func (base *Certificate) BeforeCreate(db *gorm.DB) error

BeforeCreate is a GORM hook that is called before a new group record is inserted into the database. It generates a unique ID for the group if it is not already set.

Parameters:

  • db: a gorm.DB instance representing the database connection.

Returns:

  • An error if there is any issue generating the unique ID.

func (Certificate) ID

func (base Certificate) ID() string

func (Certificate) Key

func (base Certificate) Key() any

func (Certificate) ToSigningCert

func (base Certificate) ToSigningCert() SignCertificate

func (Certificate) Use

func (base Certificate) Use() string

type CreateAdapter

type CreateAdapter struct {
	DisplayName string `json:"display_name" validate:"required"`
	TableName   string `json:"table_name" validate:"required"`
	ExternalDB  bool   `json:"external_db"`

	Driver string `json:"driver"  validate:"required_if=ExternalDB true"  example:"mysql"`

	Host         string `json:"host" validate:"required_if=ExternalDB true" example:"127.0.0.1"`
	Port         string `json:"port" validate:"required_if=ExternalDB true"  example:"3306"`
	Username     string `json:"username"  validate:"required_if=ExternalDB true" example:"root"`
	Password     string `json:"password"  validate:"required_if=ExternalDB true" example:"password"`
	DatabaseName string `json:"database_name"  validate:"required_if=ExternalDB true"  example:"test"`
}

type CreateApplication

type CreateApplication struct {
	DisplayName string `json:"display_name" validate:"required,max=100" example:"Frontend Application"`

	SignInURL string `json:"sign_in_url"`
	SignUpURL string `json:"sign_up_url"`
	ForgetURL string `json:"forget_url"`
	TermsURL  string `json:"terms_url"`

	RedirectURLs []string `json:"redirect_urls"`
}

type CreateAuthRequest

type CreateAuthRequest struct {
	ApplicationID string         `json:"application_id" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	UserID        sql.NullString `json:"user_id" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	CallbackURI   string             `json:"callback_uri"`
	TransferState string             `json:"transfer_state"`
	Prompt        []string           `json:"prompt" gorm:"type:text[]; serializer:json"`
	LoginHint     string             `json:"login_hint"`
	MaxAuthAge    *time.Duration     `json:"max_auth_age"`
	Scopes        []string           `json:"scopes" gorm:"type:text[]; serializer:json"`
	ResponseType  oidc.ResponseType  `json:"response_type"`
	ResponseMode  oidc.ResponseMode  `json:"response_mode"`
	Nonce         string             `json:"nonce"`
	CodeChallenge *OIDCCodeChallenge `json:"code_challenge" gorm:"type:text; serializer:json"`
}

type CreateCertificate

type CreateCertificate struct {
	DisplayName string    `json:"display_name" validate:"required,max=100" maxLength:"100" example:"Certificate Title"`
	Algorithm   string    `json:"algorithm" validate:"required" example:"RS512"`
	BitSize     int       `json:"bit_size" example:"2048"`
	ExpiredAt   time.Time `json:"expired_at" format:"date-time"`
}

type CreateCredential

type CreateCredential struct {
	UserID string `json:"user_id" gorm:"type:char(25)"`

	Type     string         `json:"type"`
	Metadata map[string]any `json:"metadata"`
	Enabled  bool           `json:"enabled"`
}

type CreateEnforcer

type CreateEnforcer struct {
	DisplayName string `json:"display_name"`
	Description string `json:"description"`

	ModelID   string `json:"model_id"`
	AdapterID string `json:"adapter_id"`
}

type CreateGroup

type CreateGroup struct {
	DisplayName   string  `json:"display_name" validate:"required,max=100" maxLength:"100" example:"Tenant Title"`
	ParentGroupID *string `json:"parent_group_id" validate:"omitnil,len=25" maxLength:"25" minLength:"25"`
}

CreateGroup represents the data required to create a new group. It includes the display name and an optional parent group ID, both of which have validation constraints.

type CreateMFA

type CreateMFA struct {
	ProviderID    string          `json:"provider_id" validate:"required" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	DisplayName   string          `json:"display_name" validate:"required,max=100" maxLength:"100" example:"Authenticator App"`
	Type          string          `json:"type" validate:"required,max=100" maxLength:"100" example:"totp"`
	Priority      int             `json:"priority" validate:"required" example:"1"`
	RecoveryCodes []string        `json:"-" swaggerignore:"true"`
	Properties    json.RawMessage `json:"-" swaggerignore:"true"`
}

type CreateMessageTemplate

type CreateMessageTemplate struct {
	DisplayName  string `json:"display_name" validate:"required,max=100" maxLength:"100"`
	TemplateType string `json:"template_type" validate:"required"`
	Template     string `json:"template" validate:"required"`
}

type CreateModel

type CreateModel struct {
	Name        string `json:"display_name" validate:"required"`
	Description string `json:"description"`
	Model       string `json:"model" validate:"required"`
}

type CreatePermission

type CreatePermission struct {
	Name        string `json:"name" validate:"required"`
	Description string `json:"description"`

	EnforcerID string `json:"enforcer_id" validate:"required"`

	Users  []string `json:"users"`
	Groups []string `json:"groups"`

	V1 []string `json:"v1"`
	V2 []string `json:"v2"`
	V3 []string `json:"v3"`
	V4 []string `json:"v4"`
	V5 []string `json:"v5"`
}

type CreateProfilePage

type CreateProfilePage struct {
	Fields []ProfilePageField `json:"fields" validate:"required"`
}

type CreateProvider

type CreateProvider struct {
	DisplayName  string          `json:"display_name" validate:"required,max=100" maxLength:"100"`
	Category     string          `json:"category" validate:"required,max=100" maxLength:"100"`
	ProviderType string          `json:"provider_type" validate:"required,max=100" maxLength:"100"`
	Parameter    json.RawMessage `json:"parameter"`
}

type CreateResource

type CreateResource struct {
	ProviderID string `json:"provider_id" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	Tag        string `json:"tag" example:"example-tag"`
	FileName   string `json:"file_name" example:"file.png"`
	FileSize   int64  `json:"file_size" example:"1024"`
	MimeType   string `json:"mime_type" example:"image/png"`
}

type CreateTenant

type CreateTenant struct {
	DisplayName   string         `json:"display_name" validate:"required,max=100" maxLength:"100"`
	PasswordType  string         `json:"password_type" validate:"required,max=100" maxLength:"100"`
	ProfileFields []ProfileField `json:"profile_fields" validate:"required"`
}

CreateTenant represents the data required to create a new tenant. It includes the display name and password type, both of which are required and have a maximum length of 100 characters.

type CreateToken

type CreateToken struct {
	ApplicationID string    `json:"application_id" maxLength:"25" minLength:"25"`
	UserID        string    `json:"user_id"`
	Scope         string    `json:"scope"`
	Audience      string    `json:"audience"`
	ExpiredAt     time.Time `json:"expired_at" format:"date-time"`
}

type CreateUser

type CreateUser struct {
	Username    string `json:"username" validate:"required,max=100"`
	DisplayName string `json:"display_name" validate:"required,max=100"`
	Email       string `json:"email" validate:"required,max=100,email"`
	Password    string `json:"password" validate:"required,max=100"`
}

CreateUser represents the data required to create a new user. It includes the username, display name, email, and password, all of which are required and have validation constraints.

type Credentials

type Credentials struct {
	ID       string `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID string `json:"tenant_id" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	UserID   string `json:"user_id" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	CreatedAt time.Time      `json:"created_at" format:"date-time"`
	UpdatedAt time.Time      `json:"updated_at" format:"date-time"`
	DeletedAt gorm.DeletedAt `json:"deleted_at" format:"date-time" gorm:"index"`

	Type     string          `json:"type"`
	Metadata json.RawMessage `json:"metadata"`
	Enabled  bool            `json:"enabled"`
}

func (*Credentials) BeforeCreate

func (base *Credentials) BeforeCreate(db *gorm.DB) error

type Enforcer

type Enforcer struct {
	ID       string `json:"id"`
	TenantID string `json:"tenant_id"`

	DisplayName string `json:"display_name"`
	Description string `json:"description"`

	ModelID   string  `json:"model_id"`
	Model     Model   `json:"-"`
	AdapterID string  `json:"adapter_id"`
	Adapter   Adapter `json:"-"`
}

func (*Enforcer) BeforeCreate

func (base *Enforcer) BeforeCreate(db *gorm.DB) error

type FillMessageTemplate

type FillMessageTemplate struct {
	Data map[string]any `json:"data" validate:"required"`
}

type Group

type Group struct {
	ID       string `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID string `json:"tenant_id" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	CreatedAt time.Time `json:"createdAt" format:"date-time"`
	UpdatedAt time.Time `json:"updatedAt" format:"date-time"`

	ParentGroupID *string `json:"parent_group_id" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	ParentGroup   *Group  `json:"-"`

	DisplayName string `json:"display_name" gorm:"type:varchar(100)" maxLength:"100" example:"Tenant Title"`

	Users []User `json:"-" gorm:"many2many:user_groups;"`
}

Group represents a group entity in the system. It contains information about the group such as its ID, tenant ID, timestamps, parent group, display name, and status.

func (*Group) BeforeCreate

func (base *Group) BeforeCreate(db *gorm.DB) error

BeforeCreate is a GORM hook that is called before a new group record is inserted into the database. It generates a unique ID for the group if it is not already set.

Parameters:

  • db: a gorm.DB instance representing the database connection.

Returns:

  • An error if there is any issue generating the unique ID.

type ImportApplication

type ImportApplication struct {
	ID          string `json:"id"`
	DisplayName string `json:"display_name"`

	ClientSecret string `json:"client_secret"`


	SignInURL string `json:"sign_in_url"`
	SignUpURL string `json:"sign_up_url"`
	ForgetURL string `json:"forget_url"`
	TermsURL  string `json:"terms_url"`

	RedirectURLs []string `json:"redirect_urls"`
}

type ImportGroup

type ImportGroup struct {
	ID            string  `json:"id"`
	DisplayName   string  `json:"display_name"`
	ParentGroupID *string `json:"parent_group_id"`
}

type ImportProvider

type ImportProvider struct {
	ID          string          `json:"id"`
	DisplayName string          `json:"display_name"`
	Category    string          `json:"category"`
	Type        string          `json:"type"`
	Parameter   json.RawMessage `json:"parameter"`
}

type ImportTenant

type ImportTenant struct {
	ID                   string         `json:"id"`
	DisplayName          string         `json:"display_name"`
	PasswordType         string         `json:"password_type"`
	SigningCertificateID *string        `json:"signing_certificate_id"`
	ProfileFields        []ProfileField `json:"profile_fields"`
}

type ImportUser

type ImportUser struct {
	ID          string `json:"id"`
	Username    string `json:"username"`
	DisplayName string `json:"display_name"`
	Email       string `json:"email"`
	Password    string `json:"password"`
}

type MFA

type MFA struct {
	ID         string `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	UserID     string `json:"user_id" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	ProviderID string `json:"provider_id" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	CreatedAt time.Time `json:"createdAt" format:"date-time" example:"2025-01-01T00:00:00Z"`
	UpdatedAt time.Time `json:"updatedAt" format:"date-time" example:"2025-01-01T00:00:00Z"`

	DisplayName   string          `json:"display_name" validate:"required,max=100" maxLength:"100" example:"Authenticator App"`
	Type          string          `json:"type" validate:"required,max=100" maxLength:"100" example:"totp"`
	Priority      int             `json:"priority" validate:"required" example:"1"`
	Verified      bool            `json:"verified" example:"true"`
	RecoveryCodes []string        `json:"-" swaggerignore:"true" gorm:"type:text[]; serializer:json"`
	Properties    json.RawMessage `json:"-" validate:"required"`
}

func (*MFA) BeforeCreate

func (base *MFA) BeforeCreate(db *gorm.DB) error

type MFACreationResponse

type MFACreationResponse struct {
	ID         string `json:"id" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	UserID     string `json:"user_id" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	ProviderID string `json:"provider_id" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	CreatedAt time.Time `json:"createdAt" format:"date-time" example:"2025-01-01T00:00:00Z"`
	UpdatedAt time.Time `json:"updatedAt" format:"date-time" example:"2025-01-01T00:00:00Z"`

	DisplayName string          `json:"display_name" maxLength:"100" example:"Authenticator App"`
	Type        string          `json:"type" maxLength:"100" example:"totp"`
	Priority    int             `json:"priority" example:"1"`
	Verified    bool            `json:"verified" example:"true"`
	Properties  json.RawMessage `json:"properties"`
}

type MFAProviderData

type MFAProviderData struct {
	Properties json.RawMessage `json:"secret" validate:"required"`
}

type MessageTemplate

type MessageTemplate struct {
	ID       string `json:"id" gorm:"primaryKey;type:char(25)" `
	TenantID string `json:"tenant_id"`

	CreatedAt time.Time `json:"created_at" format:"date-time"`
	UpdatedAt time.Time `json:"updated_at" format:"date-time"`

	DisplayName  string `json:"display_name" validate:"required,max=100" maxLength:"100"`
	TemplateType string `json:"template_type" validate:"required"`
	Template     string `json:"template" validate:"required"`
}

func (*MessageTemplate) BeforeCreate

func (base *MessageTemplate) BeforeCreate(db *gorm.DB) error

type Model

type Model struct {
	ID       string `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID string `json:"tenant_id" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	Name        string `json:"display_name"`
	Description string `json:"description"`
	Model       string `json:"model"`
}

func (*Model) BeforeCreate

func (base *Model) BeforeCreate(db *gorm.DB) error

type ModifyType

type ModifyType string
const (
	ModifyTypeImmutable ModifyType = "immutable"
	ModifyTypeSelf      ModifyType = "self"
)

type OIDCCodeChallenge

type OIDCCodeChallenge struct {
	Challenge string
	Method    string
}

type Pagination

type Pagination struct {
	Limit int `json:"limit,omitempty;query:limit"`
	Page  int `json:"page,omitempty;query:page"`
}

type Permission

type Permission struct {
	ID         string `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID   string `json:"tenant_id" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	EnforcerID string `json:"enforcer_id" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	Name        string `json:"name"`
	Description string `json:"description"`

	Users  []string `json:"users" gorm:"serializer:json"`
	Groups []string `json:"groups" gorm:"serializer:json"`

	V1 []string `json:"v1" gorm:"serializer:json"`
	V2 []string `json:"v2" gorm:"serializer:json"`
	V3 []string `json:"v3" gorm:"serializer:json"`
	V4 []string `json:"v4" gorm:"serializer:json"`
	V5 []string `json:"v5" gorm:"serializer:json"`
}

func (*Permission) BeforeCreate

func (base *Permission) BeforeCreate(db *gorm.DB) error

type ProfileField

type ProfileField struct {
	Identifier  string     `json:"identifier" validate:"required,max=100" maxLength:"100"`
	DisplayName string     `json:"display_name"`
	Regex       string     `json:"regex"`
	Required    bool       `json:"required"`
	ModifyBy    ModifyType `json:"modify_by"`
	ViewBy      AllowView  `json:"view_by"`
}

type ProfilePage

type ProfilePage struct {
	UserID string `json:"user_id" gorm:"primaryKey;type:char(25)" validate:"required,max=100" maxLength:"100"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	Fields []ProfilePageField `json:"fields"  gorm:"serializer:json"`

	User User `json:"-"`
}

type ProfilePageField

type ProfilePageField struct {
	Identifier string `json:"identifier"`
	Value      any    `json:"value"`
}

type Provider

type Provider struct {
	ID       string `json:"id" gorm:"primaryKey;type:char(25)" `
	TenantID string `json:"tenant_id"`

	CreatedAt time.Time `json:"created_at" format:"date-time"`
	UpdatedAt time.Time `json:"updated_at" format:"date-time"`

	DisplayName  string          `json:"display_name" validate:"required,max=100" maxLength:"100"`
	Category     string          `json:"category" validate:"required,max=100" maxLength:"100"`
	ProviderType string          `json:"provider_type" validate:"required,max=100" maxLength:"100"`
	Parameter    json.RawMessage `json:"parameter"`
}

func (*Provider) BeforeCreate

func (base *Provider) BeforeCreate(db *gorm.DB) error

type ProviderConfigurationField

type ProviderConfigurationField struct {
	FieldKey  string `json:"field_key"`
	FieldType string `json:"field_type"`
}

type ProviderConfigurationFieldValue

type ProviderConfigurationFieldValue struct {
	FieldKey   string `json:"field_key"`
	FieldValue string `json:"field_value"`
}

type RefreshToken

type RefreshToken struct {
	ID            string
	Token         string
	AuthTime      time.Time
	AMR           []string
	Audience      []string
	UserID        string
	ApplicationID string
	Expiration    time.Time
	Scopes        []string
	AccessToken   string // Token.ID
}

type RefreshTokenRequest

type RefreshTokenRequest struct {
	*RefreshToken
}

func (*RefreshTokenRequest) GetAMR

func (r *RefreshTokenRequest) GetAMR() []string

func (*RefreshTokenRequest) GetAudience

func (r *RefreshTokenRequest) GetAudience() []string

func (*RefreshTokenRequest) GetAuthTime

func (r *RefreshTokenRequest) GetAuthTime() time.Time

func (*RefreshTokenRequest) GetClientID

func (r *RefreshTokenRequest) GetClientID() string

func (*RefreshTokenRequest) GetScopes

func (r *RefreshTokenRequest) GetScopes() []string

func (*RefreshTokenRequest) GetSubject

func (r *RefreshTokenRequest) GetSubject() string

func (*RefreshTokenRequest) SetCurrentScopes

func (r *RefreshTokenRequest) SetCurrentScopes(scopes []string)

type Resource

type Resource struct {
	ID       string `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID string `json:"tenant_id" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	CreatedAt time.Time `json:"createdAt" format:"date-time" example:"2025-01-01T00:00:00Z"`
	UpdatedAt time.Time `json:"updatedAt" format:"date-time" example:"2025-01-01T00:00:00Z"`

	ProviderID string `json:"provider_id" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	Tag        string `json:"tag" example:"example-tag"`
	MimeType   string `json:"mime_type" example:"image/png"`
	FilePath   string `json:"file_path" example:"/path/to/file.png"`
	FileSize   int64  `json:"file_size" example:"1024"`
	Format     string `json:"format" example:"png"`
	Url        string `json:"url" example:"https://domain.tld/files/file.png"`
	Hash       string `json:"hash" example:"d41d8cd98f00b204e9800998ecf8427e"`
}

func (*Resource) BeforeCreate

func (base *Resource) BeforeCreate(db *gorm.DB) error

type SendMailData

type SendMailData struct {
	To      string `json:"to" validate:"required,max=100,email"`
	Subject string `json:"subject" validate:"required,max=100"`
	Body    string `json:"body" validate:"required,max=5000"`
}

type SignCertificate

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

func (SignCertificate) ID

func (s SignCertificate) ID() string

func (SignCertificate) Key

func (s SignCertificate) Key() any

func (SignCertificate) SignatureAlgorithm

func (s SignCertificate) SignatureAlgorithm() jose.SignatureAlgorithm

type SignInRequest

type SignInRequest struct {
	RequestID string         `json:"request_id"`
	Username  string         `json:"username"`
	Type      string         `json:"type"`
	Metadata  map[string]any `json:"metadata"`
}

type Tenant

type Tenant struct {
	ID string `json:"id" gorm:"primaryKey;type:char(25)" maxLength:"25" minLength:"25" example:"BsOOa4igppKxYwhAQQrD3GCRZ"`

	CreatedAt time.Time `json:"created_at" format:"date-time"`
	UpdatedAt time.Time `json:"updated_at" format:"date-time"`

	DisplayName  string `json:"display_name" gorm:"type:varchar(100)" maxLength:"100" example:"Tenant Title"`
	PasswordType string `json:"password_type" gorm:"type:varchar(100)" maxLength:"100" example:"bcrypt"`

	SigningCertificateID *string `json:"signing_certificate_id" gorm:"type:char(25)" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	ProfileFields []ProfileField `json:"profile_fields" gorm:"serializer:json"`

	Groups       []Group           `json:"-" swaggerignore:"true"`
	Providers    []Provider        `json:"-" swaggerignore:"true"`
	Templates    []MessageTemplate `json:"-" swaggerignore:"true"`
	Users        []User            `json:"-" swaggerignore:"true"`
	Application  []Application     `json:"-" swaggerignore:"true"`
	Certificates []Certificate     `json:"-" swaggerignore:"true"`
	Tokens       []Token           `json:"-" swaggerignore:"true"`
}

Tenant represents a tenant entity in the system. It contains information about the tenant such as its ID, timestamps, display name, password type, and associated groups.

func (*Tenant) BeforeCreate

func (base *Tenant) BeforeCreate(db *gorm.DB) error

BeforeCreate is a GORM hook that is called before a new tenant record is inserted into the database. It generates a unique ID for the tenant if it is not already set.

Parameters:

  • db: a gorm.DB instance representing the database connection.

Returns:

  • An error if there is any issue generating the unique ID.

type Token

type Token struct {
	ID            string         `json:"id" gorm:"primaryKey;type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	TenantID      string         `json:"tenant_id" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	ApplicationID string         `json:"application_id" maxLength:"25" minLength:"25" gorm:"type:char(25)" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`
	UserID        sql.NullString `json:"user_id" maxLength:"25" gorm:"type:char(25)" `

	CreatedAt time.Time `json:"created_at" format:"date-time"`
	ExpiredAt time.Time `json:"expired_at" format:"date-time"`

	RefreshTokenID string `json:"refresh_token"`

	Scope    string `json:"scope"`
	Audience string `json:"audience"`
}

func (*Token) BeforeCreate

func (base *Token) BeforeCreate(db *gorm.DB) error

type UpdateAdapter

type UpdateAdapter struct {
	DisplayName string `json:"display_name" validate:"required"`
	TableName   string `json:"table_name" validate:"required"`
	ExternalDB  bool   `json:"external_db"`

	Driver string `json:"driver"  validate:"required_if=ExternalDB true"  example:"mysql"`

	Host         string `json:"host" validate:"required_if=ExternalDB true" example:"127.0.0.1"`
	Port         string `json:"port" validate:"required_if=ExternalDB true"  example:"3306"`
	Username     string `json:"username"  validate:"required_if=ExternalDB true" example:"root"`
	Password     string `json:"password"  validate:"required_if=ExternalDB true" example:"password"`
	DatabaseName string `json:"database_name"  validate:"required_if=ExternalDB true"  example:"test"`
}

type UpdateApplication

type UpdateApplication struct {
	DisplayName string `json:"display_name" validate:"required,max=100" example:"Frontend Application"`

	SignInURL string `json:"sign_in_url"`
	SignUpURL string `json:"sign_up_url"`
	ForgetURL string `json:"forget_url"`
	TermsURL  string `json:"terms_url"`

	RedirectURLs []string `json:"redirect_urls"`
}

type UpdateAuthRequest

type UpdateAuthRequest struct {
	UserID sql.NullString `json:"user_id" maxLength:"25" minLength:"25" example:"BsOOg4igppKxYwhAQQrD3GCRZ"`

	Authenticated   bool      `json:"authenticated" format:"date-time"`
	AuthenticatedAt time.Time `json:"authenticated_at" format:"date-time"`
}

type UpdateCertificate

type UpdateCertificate struct {
	DisplayName string `json:"display_name" validate:"required,max=100" maxLength:"100" example:"Certificate Title"`
}

type UpdateCredential

type UpdateCredential struct {
	Metadata map[string]any `json:"metadata"`
	Enabled  bool           `json:"enabled"`
}

type UpdateEmail

type UpdateEmail struct {
	Email                  string `json:"email"`
	EmailVerified          bool   `json:"email_verified"`
	EmailVerificationToken string `json:"email_verification_token"`
}

type UpdateEnforcer

type UpdateEnforcer struct {
	DisplayName string `json:"display_name"`
	Description string `json:"description"`

	ModelID   string `json:"model_id"`
	AdapterID string `json:"adapter_id"`
}

type UpdateGroup

type UpdateGroup struct {
	DisplayName   string  `json:"display_name" validate:"required,max=100" maxLength:"100" example:"Tenant Title"`
	ParentGroupID *string `json:"parent_group_id" validate:"omitnil,len=25" maxLength:"25" minLength:"25"`
}

UpdateGroup represents the data required to update an existing group. It includes the display name and an optional parent group ID, both of which have validation constraints.

type UpdateMFA

type UpdateMFA struct {
	DisplayName string `json:"display_name" validate:"required,max=100" maxLength:"100" example:"Authenticator App"`
	Priority    int    `json:"priority" validate:"required" example:"1"`
}

type UpdateMessageTemplate

type UpdateMessageTemplate struct {
	DisplayName string `json:"display_name" validate:"required,max=100" maxLength:"100"`
	Template    string `json:"template" validate:"required"`
}

type UpdateModel

type UpdateModel struct {
	Name        string `json:"display_name" validate:"required"`
	Description string `json:"description"`
	Model       string `json:"model" validate:"required"`
}

type UpdatePermission

type UpdatePermission struct {
	Name        string `json:"name" validate:"required"`
	Description string `json:"description"`

	EnforcerID string `json:"enforcer_id" validate:"required"`

	Users  []string `json:"users"`
	Groups []string `json:"groups"`

	V1 []string `json:"v1"`
	V2 []string `json:"v2"`
	V3 []string `json:"v3"`
	V4 []string `json:"v4"`
	V5 []string `json:"v5"`
}

type UpdateProfilePage

type UpdateProfilePage struct {
	Fields []ProfilePageField `json:"fields" validate:"required"`
}

type UpdateProvider

type UpdateProvider struct {
	DisplayName string          `json:"display_name" validate:"required,max=100" maxLength:"100"`
	Parameter   json.RawMessage `json:"parameter"`
}

type UpdateTenant

type UpdateTenant struct {
	DisplayName          string         `json:"display_name" validate:"required,max=100" maxLength:"100"`
	PasswordType         string         `json:"password_type" validate:"required,max=100" maxLength:"100"`
	SigningCertificateID string         `json:"signing_certificate_id" validate:"required,max=25" maxLength:"25"`
	ProfileFields        []ProfileField `json:"profile_fields" validate:"required"`
}

UpdateTenant represents the data required to update an existing tenant. It includes the display name and password type, both of which are required and have a maximum length of 100 characters.

type UpdateUser

type UpdateUser struct {
	DisplayName string `json:"display_name" validate:"required,max=100" maxLength:"100"`
}

UpdateUser represents the data required to update an existing user's display name. It includes the display name, which is required and has a maximum length of 100 characters.

type UpdateUserPassword

type UpdateUserPassword struct {
	Password string `json:"password" validate:"required,max=100"`
}

UpdateUserPassword represents the data required to update an existing user's password. It includes the password, which is required and has a maximum length of 100 characters.

type User

type User struct {
	ID       string `json:"id" gorm:"primaryKey;type:char(25)"`
	TenantID string `json:"tenant_id"`

	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"deleted_at,omitempty"`

	Username               string `json:"username"  gorm:"type:varchar(100);index"`
	DisplayName            string `json:"display_name"  gorm:"type:varchar(100)"`
	Email                  string `json:"email" gorm:"type:varchar(100);index"`
	EmailVerified          bool   `json:"email_verified"`
	EmailVerificationToken string `json:"-" gorm:"type:char(6)"`

	Groups []Group `json:"groups" gorm:"many2many:user_groups;"`
}

User represents a user entity in the system. It contains information about the user such as their ID, organisation ID, timestamps, username, display name, email, password details, and associated groups.

func (*User) BeforeCreate

func (base *User) BeforeCreate(db *gorm.DB) error

BeforeCreate is a GORM hook that is called before a new user record is inserted into the database. It generates a unique ID for the user if it is not already set.

Parameters:

  • db: a gorm.DB instance representing the database connection.

Returns:

  • An error if there is any issue generating the unique ID.

Jump to

Keyboard shortcuts

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