Documentation
¶
Overview ¶
Package api_auth_config defines Auth configuration loaded by config.
Index ¶
Constants ¶
View Source
const AuthTypeJWT = "jwt"
AuthTypeJWT 是当前唯一支持的鉴权类型取值;未来新增类型在此常量组扩展并在门禁分发处加分支。
View Source
const EmailProviderResend = "resend"
EmailProviderResend 是当前唯一支持的邮件供应商取值。
Variables ¶
This section is empty.
Functions ¶
func AuthGateEnabled ¶
func AuthGateEnabled() bool
AuthGateEnabled 统一准入门禁是否启用:配置段或 enabled 键缺席一律按启用处理(fail-closed), 只有显式 enabled: false 才放行门禁——放行不提供身份,依赖 AuthenticatedUser 的方法照常拒绝。
func CurrentAuthType ¶
CurrentAuthType 返回门禁鉴权类型:缺省 jwt;非法值返回 error,门禁按 fail-closed 拒绝全部受保护方法。
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Enabled *bool `` /* 179-byte string literal not displayed */
AuthType string `` /* 158-byte string literal not displayed */
Email *EmailConfig `yaml:"email" json:"email" toml:"email" comment:"Email delivery configuration"`
Verification *VerificationConfig `yaml:"verification" json:"verification" toml:"verification" comment:"Verification code policy"`
Session *SessionConfig `yaml:"session" json:"session" toml:"session" comment:"JWT and refresh session policy"`
}
var (
CurrentCfgAuth *AuthConfig
)
type EmailConfig ¶
type EmailConfig struct {
Provider string `yaml:"provider" json:"provider" toml:"provider"`
APIKey string `yaml:"api_key" json:"api_key" toml:"api_key"`
From string `yaml:"from" json:"from" toml:"from"`
ReplyTo string `yaml:"reply_to" json:"reply_to" toml:"reply_to"`
ProductName string `yaml:"product_name" json:"product_name" toml:"product_name"`
VerificationSubject string `yaml:"verification_subject" json:"verification_subject" toml:"verification_subject"`
}
func CurrentEmailConfig ¶
func CurrentEmailConfig() (*EmailConfig, error)
type SessionConfig ¶
type SessionConfig struct {
JWTSigningSecret string `yaml:"jwt_signing_secret" json:"jwt_signing_secret" toml:"jwt_signing_secret"`
Issuer string `yaml:"issuer" json:"issuer" toml:"issuer"`
Audience string `yaml:"audience" json:"audience" toml:"audience"`
AccessTokenTTLSeconds int `yaml:"access_token_ttl_seconds" json:"access_token_ttl_seconds" toml:"access_token_ttl_seconds"`
RefreshTokenTTLSeconds int `yaml:"refresh_token_ttl_seconds" json:"refresh_token_ttl_seconds" toml:"refresh_token_ttl_seconds"`
}
func CurrentSessionConfig ¶
func CurrentSessionConfig() (*SessionConfig, error)
type VerificationConfig ¶
type VerificationConfig struct {
CodeTTLSeconds int `yaml:"code_ttl_seconds" json:"code_ttl_seconds" toml:"code_ttl_seconds"`
MaxAttempts int `yaml:"max_attempts" json:"max_attempts" toml:"max_attempts"`
ResendIntervalSeconds int `yaml:"resend_interval_seconds" json:"resend_interval_seconds" toml:"resend_interval_seconds"`
HourlySendLimit int `yaml:"hourly_send_limit" json:"hourly_send_limit" toml:"hourly_send_limit"`
CodeHashSecret string `yaml:"code_hash_secret" json:"code_hash_secret" toml:"code_hash_secret"`
}
func CurrentVerificationConfig ¶
func CurrentVerificationConfig() (*VerificationConfig, error)
Click to show internal directories.
Click to hide internal directories.