core: Settings
import core "ganigeorgiev.com/pocketbase/pocketbase/core"
Part of core.
Types
AuthAlertConfig
type AuthAlertConfig struct {
Enabled bool `form:"enabled" json:"enabled"`
EmailTemplate EmailTemplate `form:"emailTemplate" json:"emailTemplate"`
}
AuthAlertConfig.Validate
func (c AuthAlertConfig) Validate() error
Validate makes AuthAlertConfig validatable by implementing validation.Validatable interface.
BackupsConfig
type BackupsConfig struct {
// Cron is a cron expression to schedule auto backups, eg. "* * * * *".
//
// Leave it empty to disable the auto backups functionality.
Cron string `form:"cron" json:"cron"`
// CronMaxKeep is the max number of cron generated backups to
// keep before removing older entries.
//
// This field works only when the cron config has valid cron expression.
CronMaxKeep int `form:"cronMaxKeep" json:"cronMaxKeep"`
// S3 is an optional S3 storage config specifying where to store the app backups.
S3 S3Config `form:"s3" json:"s3"`
}
BackupsConfig.Validate
func (c BackupsConfig) Validate() error
Validate makes BackupsConfig validatable by implementing validation.Validatable interface.
BaseAppConfig
type BaseAppConfig struct {
DBConnect DBConnectFunc
DataDir string
EncryptionEnv string
QueryTimeout time.Duration
DataMaxOpenConns int
DataMaxIdleConns int
AuxMaxOpenConns int
AuxMaxIdleConns int
IsDev bool
// AppMigrations, when set, is used instead of the global [AppMigrations] list by RunAppMigrations,
// RunAllMigrations, the jsvm plugin and the migrate command (see [AppMigrationsOf]).
AppMigrations *MigrationsList
// OnLog, when set, is called with every log entry the app's logger accepts (before the logs settings decide
// whether it is stored), e.g. to copy them to a host's per-app log. It must not block or log.
OnLog func(log *logger.Log)
}
BaseAppConfig defines a BaseApp configuration option
BatchConfig
type BatchConfig struct {
Enabled bool `form:"enabled" json:"enabled"`
// MaxRequests is the maximum allowed batch request to execute.
MaxRequests int `form:"maxRequests" json:"maxRequests"`
// Timeout is the max duration in seconds to wait before cancelling the batch transaction.
Timeout int64 `form:"timeout" json:"timeout"`
// MaxBodySize is the maximum allowed batch request body size in bytes.
//
// If not set, fallbacks to max ~128MB.
MaxBodySize int64 `form:"maxBodySize" json:"maxBodySize"`
}
BatchConfig.Validate
func (c BatchConfig) Validate() error
Validate makes BatchConfig validatable by implementing validation.Validatable interface.
LogsConfig
type LogsConfig struct {
// MaxDataSize specifies the maximum allowed serialized log data
// size before it gets truncated (see [Log.DBExport]).
//
// If zero, fallbacks to ~16kb by default.
MaxDataSize int64 `form:"maxDataSize" json:"maxDataSize"`
MaxDays int `form:"maxDays" json:"maxDays"`
MinLevel int `form:"minLevel" json:"minLevel"`
LogIP bool `form:"logIP" json:"logIP"`
LogAuthId bool `form:"logAuthId" json:"logAuthId"`
}
LogsConfig.Validate
func (c LogsConfig) Validate() error
Validate makes LogsConfig validatable by implementing validation.Validatable interface.
MFAConfig
type MFAConfig struct {
Enabled bool `form:"enabled" json:"enabled"`
// Duration specifies how long an issued MFA to be valid (in seconds)
Duration int64 `form:"duration" json:"duration"`
// Rule is an optional field to restrict MFA only for the records that satisfy the rule.
//
// Leave it empty to enable MFA for everyone.
Rule string `form:"rule" json:"rule"`
}
MFAConfig.DurationTime
func (c MFAConfig) DurationTime() time.Duration
DurationTime returns the current Duration as time.Duration.
MFAConfig.Validate
func (c MFAConfig) Validate() error
Validate makes MFAConfig validatable by implementing validation.Validatable interface.
MetaConfig
type MetaConfig struct {
// @todo experimental
//
// AccentColor specify the UI "accent" color (HEX).
AccentColor string `form:"accentColor" json:"accentColor"`
AppName string `form:"appName" json:"appName"`
AppURL string `form:"appURL" json:"appURL"`
SenderName string `form:"senderName" json:"senderName"`
SenderAddress string `form:"senderAddress" json:"senderAddress"`
HideControls bool `form:"hideControls" json:"hideControls"`
}
MetaConfig.Validate
func (c MetaConfig) Validate() error
Validate makes MetaConfig validatable by implementing validation.Validatable interface.
OAuth2Config
type OAuth2Config struct {
Providers []OAuth2ProviderConfig `form:"providers" json:"providers"`
MappedFields OAuth2KnownFields `form:"mappedFields" json:"mappedFields"`
Enabled bool `form:"enabled" json:"enabled"`
}
OAuth2Config.GetProviderConfig
func (c OAuth2Config) GetProviderConfig(name string) (config OAuth2ProviderConfig, exists bool)
GetProviderConfig returns the first OAuth2ProviderConfig that matches the specified name.
Returns false and zero config if no such provider is available in c.Providers.
OAuth2Config.UnmarshalJSON
func (c *OAuth2Config) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
The main difference from the standard unmarshalization is that instead of replacing the entire providers config slice, we ensure that partially submitted provider data (e.g. without clientSecret) is merged on per config level based on the provider name (https://ganigeorgiev.com/pocketbase/discussions/7815).
OAuth2Config.Validate
func (c OAuth2Config) Validate() error
Validate makes OAuth2Config validatable by implementing validation.Validatable interface.
OAuth2ProviderConfig
type OAuth2ProviderConfig struct {
// PKCE overwrites the default provider PKCE config option.
//
// This usually shouldn't be needed but some OAuth2 vendors, like the LinkedIn OIDC,
// may require manual adjustment due to returning error if extra parameters are added to the request
// (https://ganigeorgiev.com/pocketbase/discussions/3799#discussioncomment-7640312)
PKCE *bool `form:"pkce" json:"pkce"`
Name string `form:"name" json:"name"`
ClientId string `form:"clientId" json:"clientId"`
ClientSecret string `form:"clientSecret" json:"clientSecret,omitempty"`
AuthURL string `form:"authURL" json:"authURL"`
TokenURL string `form:"tokenURL" json:"tokenURL"`
UserInfoURL string `form:"userInfoURL" json:"userInfoURL"`
DisplayName string `form:"displayName" json:"displayName"`
Extra map[string]any `form:"extra" json:"extra"`
}
OAuth2ProviderConfig.InitProvider
func (c OAuth2ProviderConfig) InitProvider() (auth.Provider, error)
InitProvider returns a new auth.Provider instance loaded with the current OAuth2ProviderConfig options.
OAuth2ProviderConfig.Validate
func (c OAuth2ProviderConfig) Validate() error
Validate makes OAuth2ProviderConfig validatable by implementing validation.Validatable interface.
OTPConfig
type OTPConfig struct {
Enabled bool `form:"enabled" json:"enabled"`
// Duration specifies how long the OTP to be valid (in seconds)
Duration int64 `form:"duration" json:"duration"`
// Length specifies the auto generated password length.
Length int `form:"length" json:"length"`
// EmailTemplate is the default OTP email template that will be send to the auth record.
//
// In addition to the system placeholders you can also make use of
// [core.EmailPlaceholderOTPId] and [core.EmailPlaceholderOTP].
EmailTemplate EmailTemplate `form:"emailTemplate" json:"emailTemplate"`
}
OTPConfig.DurationTime
func (c OTPConfig) DurationTime() time.Duration
DurationTime returns the current Duration as time.Duration.
OTPConfig.Validate
func (c OTPConfig) Validate() error
Validate makes OTPConfig validatable by implementing validation.Validatable interface.
PasswordAuthConfig
type PasswordAuthConfig struct {
Enabled bool `form:"enabled" json:"enabled"`
// IdentityFields is a list of field names that could be used as
// identity during password authentication.
//
// Usually only fields that has single column UNIQUE index are accepted as values.
IdentityFields []string `form:"identityFields" json:"identityFields"`
}
PasswordAuthConfig.Validate
func (c PasswordAuthConfig) Validate() error
Validate makes PasswordAuthConfig validatable by implementing validation.Validatable interface.
RateLimitsConfig
type RateLimitsConfig struct {
Rules []RateLimitRule `form:"rules" json:"rules"`
ExcludedIPs []string `form:"excludedIPs" json:"excludedIPs"`
Enabled bool `form:"enabled" json:"enabled"`
}
RateLimitsConfig.FindRateLimitRule
func (c *RateLimitsConfig) FindRateLimitRule(searchLabels []string, optOnlyAudience ...string) (RateLimitRule, bool)
FindRateLimitRule returns the first matching rule based on the provided labels.
Optionally you can further specify a list of valid RateLimitRule.Audience values to further filter the matching rule (aka. the rule Audience will have to exist in one of the specified options).
RateLimitsConfig.Validate
func (c RateLimitsConfig) Validate() error
Validate makes RateLimitsConfig validatable by implementing validation.Validatable interface.
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,omitempty"`
ForcePathStyle bool `form:"forcePathStyle" json:"forcePathStyle"`
}
S3Config.Validate
func (c S3Config) Validate() error
Validate makes S3Config validatable by implementing validation.Validatable interface.
SMTPConfig
type SMTPConfig struct {
Enabled bool `form:"enabled" json:"enabled"`
Port int `form:"port" json:"port"`
Host string `form:"host" json:"host"`
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"`
// LocalName is optional domain name or IP address used for the
// EHLO/HELO exchange (if not explicitly set, defaults to "localhost").
//
// This is required only by some SMTP servers, such as Gmail SMTP-relay.
LocalName string `form:"localName" json:"localName"`
// contains filtered or unexported fields
}
SMTPConfig.MarshalJSON
func (c SMTPConfig) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
SMTPConfig.Validate
func (c SMTPConfig) Validate() error
Validate makes SMTPConfig validatable by implementing validation.Validatable interface.
Settings
type Settings struct {
// contains filtered or unexported fields
}
Settings defines the PocketBase app settings.
Settings.Clone
func (s *Settings) Clone() (*Settings, error)
Clone creates a new deep copy of the current settings.
Settings.DBExport
func (s *Settings) DBExport(app App) (map[string]any, error)
DBExport prepares and exports the current settings for db persistence.
Settings.IsNew
func (s *Settings) IsNew() bool
IsNew implements Model.IsNew interface method.
Settings.LastSavedPK
func (s *Settings) LastSavedPK() any
PK implements Model.LastSavedPK interface method.
Settings.MarkAsNew
func (s *Settings) MarkAsNew()
MarkAsNew implements Model.MarkAsNew interface method.
Settings.MarkAsNotNew
func (s *Settings) MarkAsNotNew()
MarkAsNew implements Model.MarkAsNotNew interface method.
Settings.MarshalJSON
func (s *Settings) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
Note that sensitive fields (S3 secret, SMTP password, etc.) are excluded.
Settings.Merge
func (s *Settings) Merge(other *Settings) error
Merge merges the "other" settings into the current one.
Settings.PK
func (s *Settings) PK() any
PK implements Model.PK interface method.
Settings.PostScan
func (s *Settings) PostScan() error
PostScan implements [Model.PostScan] interface method.
Settings.PostValidate
func (s *Settings) PostValidate(app App) error
PostValidate implements the PostValidator interface and defines the Settings model validations.
Settings.String
func (s *Settings) String() string
String returns a serialized string representation of the current settings.
Settings.TableName
func (s *Settings) TableName() string
TableName implements Model.TableName interface method.
TokenConfig
type TokenConfig struct {
Secret string `form:"secret" json:"secret,omitempty"`
// Duration specifies how long an issued token to be valid (in seconds)
Duration int64 `form:"duration" json:"duration"`
}
TokenConfig.DurationTime
func (c TokenConfig) DurationTime() time.Duration
DurationTime returns the current Duration as time.Duration.
TokenConfig.Validate
func (c TokenConfig) Validate() error
Validate makes TokenConfig validatable by implementing validation.Validatable interface.
TrustedProxyConfig
type TrustedProxyConfig struct {
// Headers is a list of explicit trusted header(s) to check.
Headers []string `form:"headers" json:"headers"`
// UseLeftmostIP specifies to use the left-mostish IP from the trusted headers.
//
// Note that this could be insecure when used with X-Forwarded-For header
// because some proxies like AWS ELB allow users to prepend their own header value
// before appending the trusted ones.
UseLeftmostIP bool `form:"useLeftmostIP" json:"useLeftmostIP"`
}
TrustedProxyConfig.Validate
func (c TrustedProxyConfig) Validate() error
Validate makes RateLimitRule validatable by implementing validation.Validatable interface.
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.