Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package auth holds the identity module's authentication-method entities: the stored configuration of each sign-in method and the purposes of verification codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbosendConfig

type AbosendConfig struct {
	ApiDomain string `json:"api_domain"`
	Access    string `json:"access"`
	Secret    string `json:"secret"`
	Template  string `json:"template"`
}

func (*AbosendConfig) Marshal

func (l *AbosendConfig) Marshal() string

func (*AbosendConfig) Unmarshal

func (l *AbosendConfig) Unmarshal(data string) error

type AlibabaCloudConfig

type AlibabaCloudConfig struct {
	Access       string `json:"access"`
	Secret       string `json:"secret"`
	SignName     string `json:"sign_name"`
	Endpoint     string `json:"endpoint"`
	TemplateCode string `json:"template_code"`
}

func (*AlibabaCloudConfig) Marshal

func (l *AlibabaCloudConfig) Marshal() string

func (*AlibabaCloudConfig) Unmarshal

func (l *AlibabaCloudConfig) Unmarshal(data string) error

type AppleAuthConfig

type AppleAuthConfig struct {
	TeamID       string `json:"team_id"`
	KeyID        string `json:"key_id"`
	ClientId     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	RedirectURL  string `json:"redirect_url"`
}

func (*AppleAuthConfig) Marshal

func (l *AppleAuthConfig) Marshal() string

func (*AppleAuthConfig) Unmarshal

func (l *AppleAuthConfig) Unmarshal(data string) error

type Auth

type Auth struct {
	Id        int64     `gorm:"primaryKey"`
	Method    string    `gorm:"unique;type:varchar(255);not null;default:'';comment:platform"`
	Config    string    `gorm:"type:text;not null;comment:Auth Configuration"`
	Enabled   *bool     `gorm:"type:tinyint(1);not null;default:false;comment:Is Enabled"`
	CreatedAt time.Time `gorm:"<-:create;comment:Create Time"`
	UpdatedAt time.Time `gorm:"comment:Update Time"`
}

Auth is the stored configuration of one authentication method: email, mobile, device or an OAuth provider.

func (Auth) TableName

func (Auth) TableName() string

type DeviceConfig

type DeviceConfig struct {
	ShowAds bool `json:"show_ads"`
	// OnlyRealDevice is the legacy flag requiring authenticated device transport.
	// It is not hardware or application attestation.
	OnlyRealDevice bool   `json:"only_real_device"`
	EnableSecurity bool   `json:"enable_security"`
	SecuritySecret string `json:"security_secret"`
}

func (*DeviceConfig) Marshal

func (l *DeviceConfig) Marshal() string

func (*DeviceConfig) Unmarshal

func (l *DeviceConfig) Unmarshal(data string) error

type EmailAuthConfig

type EmailAuthConfig struct {
	Platform                   string `json:"platform"`
	PlatformConfig             any    `json:"platform_config"`
	EnableVerify               bool   `json:"enable_verify"`
	EnableNotify               bool   `json:"enable_notify"`
	EnableDomainSuffix         bool   `json:"enable_domain_suffix"`
	DomainSuffixList           string `json:"domain_suffix_list"`
	VerifyEmailTemplate        string `json:"verify_email_template"`
	ExpirationEmailTemplate    string `json:"expiration_email_template"`
	MaintenanceEmailTemplate   string `json:"maintenance_email_template"`
	TrafficExceedEmailTemplate string `json:"traffic_exceed_email_template"`
	// Subjects pair with the templates above; an empty subject falls back to
	// the delivery-time default, so pre-existing configs keep sending the
	// original English subjects.
	VerifyEmailSubject        string `json:"verify_email_subject"`
	ExpirationEmailSubject    string `json:"expiration_email_subject"`
	MaintenanceEmailSubject   string `json:"maintenance_email_subject"`
	TrafficExceedEmailSubject string `json:"traffic_exceed_email_subject"`
}

func (*EmailAuthConfig) Marshal

func (l *EmailAuthConfig) Marshal() string

func (*EmailAuthConfig) Unmarshal

func (l *EmailAuthConfig) Unmarshal(data string) error

Unmarshal decodes data into l. When data does not parse it returns the error and leaves l at the defaults, so a caller that has to keep running still holds a usable configuration.

type FacebookAuthConfig

type FacebookAuthConfig struct {
	ClientId     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	RedirectURL  string `json:"redirect_url"`
}

func (*FacebookAuthConfig) Marshal

func (l *FacebookAuthConfig) Marshal() string

func (*FacebookAuthConfig) Unmarshal

func (l *FacebookAuthConfig) Unmarshal(data string) error

type Filter

type Filter struct {
	Show   *bool
	Pinned *bool
	Popup  *bool
	Search string
}

Filter filters the auth method list.

type GithubAuthConfig

type GithubAuthConfig struct {
	ClientId     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	RedirectURL  string `json:"redirect_url"`
}

func (*GithubAuthConfig) Marshal

func (l *GithubAuthConfig) Marshal() string

func (*GithubAuthConfig) Unmarshal

func (l *GithubAuthConfig) Unmarshal(data string) error

type GoogleAuthConfig

type GoogleAuthConfig struct {
	ClientId     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	RedirectURL  string `json:"redirect_url"`
}

func (*GoogleAuthConfig) Marshal

func (l *GoogleAuthConfig) Marshal() string

func (*GoogleAuthConfig) Unmarshal

func (l *GoogleAuthConfig) Unmarshal(data string) error

type MobileAuthConfig

type MobileAuthConfig struct {
	Platform        string   `json:"platform"`
	PlatformConfig  any      `json:"platform_config"`
	EnableWhitelist bool     `json:"enable_whitelist"`
	Whitelist       []string `json:"whitelist"`
}

func (*MobileAuthConfig) Marshal

func (l *MobileAuthConfig) Marshal() string

func (*MobileAuthConfig) Unmarshal

func (l *MobileAuthConfig) Unmarshal(data string) error

Unmarshal decodes data into l. When data does not parse it returns the error and leaves l at the defaults, so a caller that has to keep running still holds a usable configuration.

type SMTPConfig

type SMTPConfig struct {
	Host string `json:"host"`
	Port int    `json:"port"`
	User string `json:"user"`
	Pass string `json:"pass"`
	From string `json:"from"`
	SSL  bool   `json:"ssl"`
}

SMTPConfig Email SMTP configuration

func (*SMTPConfig) Marshal

func (l *SMTPConfig) Marshal() string

func (*SMTPConfig) Unmarshal

func (l *SMTPConfig) Unmarshal(data string) error

type SmsbaoConfig

type SmsbaoConfig struct {
	Access   string `json:"access"`
	Secret   string `json:"secret"`
	Template string `json:"template"`
}

func (*SmsbaoConfig) Marshal

func (l *SmsbaoConfig) Marshal() string

func (*SmsbaoConfig) Unmarshal

func (l *SmsbaoConfig) Unmarshal(data string) error

type TelegramAuthConfig

type TelegramAuthConfig struct {
	BotToken      string `json:"bot_token"`
	EnableNotify  bool   `json:"enable_notify"`
	WebHookDomain string `json:"webhook_domain"`
	// GroupChatID is the administrators' forum-enabled supergroup (e.g.
	// "-1001234567890"). It is a string because the admin panel round-trips
	// this config as JSON text. Empty disables every group feature.
	GroupChatID string `json:"group_chat_id"`
}

func (*TelegramAuthConfig) Marshal

func (l *TelegramAuthConfig) Marshal() string

func (*TelegramAuthConfig) Unmarshal

func (l *TelegramAuthConfig) Unmarshal(data string) error

type TwilioConfig

type TwilioConfig struct {
	Access      string `json:"access"`
	Secret      string `json:"secret"`
	PhoneNumber string `json:"phone_number"`
	Template    string `json:"template"`
}

func (*TwilioConfig) Marshal

func (l *TwilioConfig) Marshal() string

func (*TwilioConfig) Unmarshal

func (l *TwilioConfig) Unmarshal(data string) error

type VerifyType added in v1.20.3

type VerifyType uint8

VerifyType identifies the purpose shared by identity's verification codes and the corresponding notification task.

const (
	// Register codes prove an identifier no account holds yet.
	Register VerifyType = iota + 1
	// Security codes prove an identifier an account holds.
	Security
)

func ParseVerifyType added in v1.20.3

func ParseVerifyType(i uint8) VerifyType

ParseVerifyType converts the type number of a request into its purpose.

func (VerifyType) String added in v1.20.3

func (v VerifyType) String() string

Jump to

Keyboard shortcuts

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