settings

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 11 Imported by: 72

Documentation

Index

Constants

View Source
const (
	EmailPlaceholderAppName   string = "{APP_NAME}"
	EmailPlaceholderAppUrl    string = "{APP_URL}"
	EmailPlaceholderToken     string = "{TOKEN}"
	EmailPlaceholderActionUrl string = "{ACTION_URL}"
)

Common settings placeholder tokens

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProviderConfig

type AuthProviderConfig struct {
	Enabled      bool   `form:"enabled" json:"enabled"`
	ClientId     string `form:"clientId" json:"clientId,omitempty"`
	ClientSecret string `form:"clientSecret" json:"clientSecret,omitempty"`
	AuthUrl      string `form:"authUrl" json:"authUrl,omitempty"`
	TokenUrl     string `form:"tokenUrl" json:"tokenUrl,omitempty"`
	UserApiUrl   string `form:"userApiUrl" json:"userApiUrl,omitempty"`
}

func (AuthProviderConfig) SetupProvider

func (c AuthProviderConfig) SetupProvider(provider auth.Provider) error

SetupProvider loads the current AuthProviderConfig into the specified provider.

func (AuthProviderConfig) Validate

func (c AuthProviderConfig) Validate() error

Validate makes `ProviderConfig` validatable by implementing validation.Validatable interface.

type EmailAuthConfig deprecated

type EmailAuthConfig struct {
	Enabled           bool     `form:"enabled" json:"enabled"`
	ExceptDomains     []string `form:"exceptDomains" json:"exceptDomains"`
	OnlyDomains       []string `form:"onlyDomains" json:"onlyDomains"`
	MinPasswordLength int      `form:"minPasswordLength" json:"minPasswordLength"`
}

Deprecated: Will be removed in v0.9+

func (EmailAuthConfig) Validate deprecated

func (c EmailAuthConfig) Validate() error

Deprecated: Will be removed in v0.9+

type EmailTemplate

type EmailTemplate struct {
	Body      string `form:"body" json:"body"`
	Subject   string `form:"subject" json:"subject"`
	ActionUrl string `form:"actionUrl" json:"actionUrl"`
}

func (EmailTemplate) Resolve

func (t EmailTemplate) Resolve(
	appName string,
	appUrl,
	token string,
) (subject, body, actionUrl string)

Resolve replaces the placeholder parameters in the current email template and returns its components as ready-to-use strings.

func (EmailTemplate) Validate

func (t EmailTemplate) Validate() error

Validate makes EmailTemplate validatable by implementing validation.Validatable interface.

type LogsConfig

type LogsConfig struct {
	MaxDays int `form:"maxDays" json:"maxDays"`
}

func (LogsConfig) Validate

func (c LogsConfig) Validate() error

Validate makes LogsConfig validatable by implementing validation.Validatable interface.

type MetaConfig

type MetaConfig struct {
	AppName                    string        `form:"appName" json:"appName"`
	AppUrl                     string        `form:"appUrl" json:"appUrl"`
	HideControls               bool          `form:"hideControls" json:"hideControls"`
	SenderName                 string        `form:"senderName" json:"senderName"`
	SenderAddress              string        `form:"senderAddress" json:"senderAddress"`
	VerificationTemplate       EmailTemplate `form:"verificationTemplate" json:"verificationTemplate"`
	ResetPasswordTemplate      EmailTemplate `form:"resetPasswordTemplate" json:"resetPasswordTemplate"`
	ConfirmEmailChangeTemplate EmailTemplate `form:"confirmEmailChangeTemplate" json:"confirmEmailChangeTemplate"`
}

func (MetaConfig) Validate

func (c MetaConfig) Validate() error

Validate makes MetaConfig validatable by implementing validation.Validatable interface.

type S3Config

type S3Config struct {
	Enabled        bool   `form:"enabled" json:"enabled"`
	Bucket         string `form:"bucket" json:"bucket"`
	Region         string `form:"region" json:"region"`
	Endpoint       string `form:"endpoint" json:"endpoint"`
	AccessKey      string `form:"accessKey" json:"accessKey"`
	Secret         string `form:"secret" json:"secret"`
	ForcePathStyle bool   `form:"forcePathStyle" json:"forcePathStyle"`
}

func (S3Config) Validate

func (c S3Config) Validate() error

Validate makes S3Config validatable by implementing validation.Validatable interface.

type Settings

type Settings struct {
	Meta MetaConfig `form:"meta" json:"meta"`
	Logs LogsConfig `form:"logs" json:"logs"`
	Smtp SmtpConfig `form:"smtp" json:"smtp"`
	S3   S3Config   `form:"s3" json:"s3"`

	AdminAuthToken           TokenConfig `form:"adminAuthToken" json:"adminAuthToken"`
	AdminPasswordResetToken  TokenConfig `form:"adminPasswordResetToken" json:"adminPasswordResetToken"`
	RecordAuthToken          TokenConfig `form:"recordAuthToken" json:"recordAuthToken"`
	RecordPasswordResetToken TokenConfig `form:"recordPasswordResetToken" json:"recordPasswordResetToken"`
	RecordEmailChangeToken   TokenConfig `form:"recordEmailChangeToken" json:"recordEmailChangeToken"`
	RecordVerificationToken  TokenConfig `form:"recordVerificationToken" json:"recordVerificationToken"`

	// Deprecated: Will be removed in v0.9+
	EmailAuth EmailAuthConfig `form:"emailAuth" json:"emailAuth"`

	GoogleAuth    AuthProviderConfig `form:"googleAuth" json:"googleAuth"`
	FacebookAuth  AuthProviderConfig `form:"facebookAuth" json:"facebookAuth"`
	GithubAuth    AuthProviderConfig `form:"githubAuth" json:"githubAuth"`
	GitlabAuth    AuthProviderConfig `form:"gitlabAuth" json:"gitlabAuth"`
	DiscordAuth   AuthProviderConfig `form:"discordAuth" json:"discordAuth"`
	TwitterAuth   AuthProviderConfig `form:"twitterAuth" json:"twitterAuth"`
	MicrosoftAuth AuthProviderConfig `form:"microsoftAuth" json:"microsoftAuth"`
	SpotifyAuth   AuthProviderConfig `form:"spotifyAuth" json:"spotifyAuth"`
	KakaoAuth     AuthProviderConfig `form:"kakaoAuth" json:"kakaoAuth"`
	TwitchAuth    AuthProviderConfig `form:"twitchAuth" json:"twitchAuth"`
	StravaAuth    AuthProviderConfig `form:"stravaAuth" json:"stravaAuth"`
	GiteeAuth     AuthProviderConfig `form:"giteeAuth" json:"giteeAuth"`
	LivechatAuth  AuthProviderConfig `form:"livechatAuth" json:"livechatAuth"`
	AuthentikAuth AuthProviderConfig `form:"authentikAuth" json:"authentikAuth"`
	GiteaAuth     AuthProviderConfig `form:"giteaAuth" json:"giteaAuth"`
	// contains filtered or unexported fields
}

Settings defines common app configuration options.

func New

func New() *Settings

New creates and returns a new default Settings instance.

func (*Settings) Clone

func (s *Settings) Clone() (*Settings, error)

Clone creates a new deep copy of the current settings.

func (*Settings) Merge

func (s *Settings) Merge(other *Settings) error

Merge merges `other` settings into the current one.

func (*Settings) NamedAuthProviderConfigs

func (s *Settings) NamedAuthProviderConfigs() map[string]AuthProviderConfig

NamedAuthProviderConfigs returns a map with all registered OAuth2 provider configurations (indexed by their name identifier).

func (*Settings) RedactClone

func (s *Settings) RedactClone() (*Settings, error)

RedactClone creates a new deep copy of the current settings, while replacing the secret values with `******`.

func (*Settings) Validate

func (s *Settings) Validate() error

Validate makes Settings validatable by implementing validation.Validatable interface.

type SmtpConfig

type SmtpConfig struct {
	Enabled  bool   `form:"enabled" json:"enabled"`
	Host     string `form:"host" json:"host"`
	Port     int    `form:"port" json:"port"`
	Username string `form:"username" json:"username"`
	Password string `form:"password" json:"password"`

	// SMTP AUTH - PLAIN (default) or LOGIN
	AuthMethod string `form:"authMethod" json:"authMethod"`

	// Whether to enforce TLS encryption for the mail server connection.
	//
	// When set to false StartTLS command is send, leaving the server
	// to decide whether to upgrade the connection or not.
	Tls bool `form:"tls" json:"tls"`
}

func (SmtpConfig) Validate

func (c SmtpConfig) Validate() error

Validate makes SmtpConfig validatable by implementing validation.Validatable interface.

type TokenConfig

type TokenConfig struct {
	Secret   string `form:"secret" json:"secret"`
	Duration int64  `form:"duration" json:"duration"`
}

func (TokenConfig) Validate

func (c TokenConfig) Validate() error

Validate makes TokenConfig validatable by implementing validation.Validatable interface.

Jump to

Keyboard shortcuts

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