fix: harden API principal config after review

Add require_direct_header toggle, external user ID validation, JWT TTL
limits, SaveToken error handling, ru-RU i18n, API docs, and Go SDK methods.
This commit is contained in:
wizardchen
2026-06-30 10:54:00 +08:00
committed by lyingbug
parent cb99736d72
commit 97bca74a31
17 changed files with 1212 additions and 14 deletions
-1
View File
@@ -8,7 +8,6 @@ import (
const (
PrincipalWebUser = "web_user"
PrincipalAPITenant = "api_tenant"
PrincipalAPIUser = "api_user"
PrincipalAPIExternalUser = "api_external_user"
PrincipalIMUser = "im_user"
PrincipalEmbedChannel = "embed_channel"
+5 -1
View File
@@ -232,7 +232,11 @@ type APIPrincipalConfig struct {
Mode APIPrincipalMode `json:"mode"`
DirectHeaderName string `json:"direct_header_name,omitempty"`
SignedTokenHeaderName string `json:"signed_token_header_name,omitempty"`
HMACSecret string `json:"hmac_secret,omitempty"`
// RequireDirectHeader, when true in direct_header mode, rejects API-key
// requests that omit the configured user-id header instead of falling
// back to the tenant-level principal.
RequireDirectHeader bool `json:"require_direct_header,omitempty"`
HMACSecret string `json:"hmac_secret,omitempty"`
}
func (c *APIPrincipalConfig) Value() (driver.Value, error) {