Documentation
¶
Index ¶
- func ParseLogLevel(level string) slog.Level
- type ClosableClientConnInterface
- type Config
- type ExtAuthzServiceConfig
- type Integrations
- type KafkaConfig
- type LoggingConfig
- type OpenFGAConfig
- type PostgresConfig
- type STSConfig
- type ServerConfig
- type Services
- type TelemetryConfig
- type ValkeyConfig
- type WorkerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseLogLevel ¶ added in v1.0.0
ParseLogLevel converts a string representation of a log level to slog.Level.
Types ¶
type ClosableClientConnInterface ¶
type ClosableClientConnInterface interface {
io.Closer
grpc.ClientConnInterface
}
type Config ¶
type Config struct {
MultitenancyEnabled bool `validate:"" envconfig:"MULTITENANCY_ENABLED" mapstructure:"multitenancy_enabled" default:"false"`
Server *ServerConfig `validate:"required" mapstructure:"server"`
ExtAuthzService *ExtAuthzServiceConfig `validate:"required" mapstructure:"ext_authz_service"`
OpenFGA *OpenFGAConfig `validate:"required" mapstructure:"open_fga"`
Valkey *ValkeyConfig `validate:"required" mapstructure:"valkey"`
STS *STSConfig `validate:"required" mapstructure:"sts"`
Postgres *PostgresConfig `validate:"required" mapstructure:"postgres"`
Logging *LoggingConfig `validate:"required" mapstructure:"logging"`
Telemetry *TelemetryConfig `validate:"required" mapstructure:"telemetry"`
Kafka *KafkaConfig `validate:"required" mapstructure:"kafka"`
Worker *WorkerConfig `validate:"required" mapstructure:"worker"`
}
Config represents the application configuration
func LoadConfig ¶ added in v1.0.0
LoadConfig loads the configuration from default values, config file, environment variables, and CLI flags.
type ExtAuthzServiceConfig ¶
type ExtAuthzServiceConfig struct {
JwkSetURL string `` /* 142-byte string literal not displayed */
}
type Integrations ¶
type Integrations struct {
MultitenancyEnabled bool
OpenFGA openfga.OpenFGAClientInterface
Valkey valkey.CacheClientInterface
STS stsv1.SecurityTokenServiceClient
Postgres postgres.DBClientInterface
KafkaConsumer kafkaintegration.ConsumerInterface
ServiceRegistry *listen.ServiceRegistry
// contains filtered or unexported fields
}
Integrations holds all external service clients
func InitializeIntegrations ¶
func (*Integrations) CleanupIntegrations ¶
func (i *Integrations) CleanupIntegrations(logger *slog.Logger)
func (*Integrations) InitializeServices ¶
type KafkaConfig ¶ added in v1.0.0
type KafkaConfig struct {
Enabled bool `validate:"" envconfig:"KAFKA_ENABLED" mapstructure:"enabled" default:"false"`
Brokers []string `validate:"required_if=Enabled true" envconfig:"KAFKA_BROKERS" mapstructure:"brokers" default:"localhost:9092"`
FederatedServices []string `validate:"required_if=Enabled true" envconfig:"FEDERATED_SERVICES" mapstructure:"federated_services"`
ConsumerGroup string `validate:"required_if=Enabled true" envconfig:"KAFKA_CONSUMER_GROUP" mapstructure:"consumer_group" default:"authz-listener"`
TopicPartitions int `validate:"min=1" envconfig:"KAFKA_TOPIC_PARTITIONS" mapstructure:"topic_partitions" default:"1"`
TopicReplicationFactor int `validate:"min=1" envconfig:"KAFKA_TOPIC_REPLICATION_FACTOR" mapstructure:"topic_replication_factor" default:"1"`
}
KafkaConfig contains Kafka consumer configuration for the permission-update ingestion listener.
FederatedServices is the registry source: each entry is a service slug, and the listener subscribes to the derived "<slug>.permissions" topic within a single consumer group. Topics are never hardcoded.
type LoggingConfig ¶
type LoggingConfig struct {
Level string `validate:"required,oneof=debug info warn error" envconfig:"LOG_LEVEL" mapstructure:"level" default:"info"`
Format string `validate:"required,oneof=json text" envconfig:"LOG_FORMAT" mapstructure:"format" default:"json"`
}
LoggingConfig contains logging configuration
func (*LoggingConfig) SetupLogger ¶
func (c *LoggingConfig) SetupLogger() *slog.Logger
type OpenFGAConfig ¶
type OpenFGAConfig struct {
Address string `validate:"required" envconfig:"OPENFGA_ADDRESS" mapstructure:"address" default:"http://localhost:8081"`
StoreID string `validate:"required" envconfig:"OPENFGA_STORE_ID" mapstructure:"store_id"`
AuthorizationModelID string `validate:"required" envconfig:"OPENFGA_AUTHZ_MODEL_ID" mapstructure:"authorization_model_id"`
ApiKey string `validate:"required" envconfig:"OPENFGA_API_KEY" mapstructure:"api_key"`
Timeout time.Duration `validate:"" envconfig:"OPENFGA_TIMEOUT" mapstructure:"timeout" default:"10s"`
}
OpenFGAConfig contains OpenFGA configuration
type PostgresConfig ¶
type PostgresConfig struct {
Host string `validate:"required" envconfig:"POSTGRES_HOST" mapstructure:"host" default:"localhost"`
Port int `validate:"required,min=1,max=65535" envconfig:"POSTGRES_PORT" mapstructure:"port" default:"5432"`
User string `validate:"required" envconfig:"POSTGRES_USER" mapstructure:"user" default:"authz"`
Password string `validate:"" envconfig:"POSTGRES_PASSWORD" mapstructure:"password" default:"authz-password"`
DBName string `validate:"required" envconfig:"POSTGRES_DB" mapstructure:"db_name" default:"cerberus"`
SSLMode string `` /* 135-byte string literal not displayed */
MaxOpenConns int32 `validate:"min=1" envconfig:"POSTGRES_MAX_OPEN_CONNS" mapstructure:"max_open_conns" default:"25"`
MaxIdleConns int32 `validate:"min=1" envconfig:"POSTGRES_MAX_IDLE_CONNS" mapstructure:"max_idle_conns" default:"5"`
ConnMaxLifetime time.Duration `validate:"" envconfig:"POSTGRES_CONN_MAX_LIFETIME" mapstructure:"conn_max_lifetime" default:"30m"`
ConnMaxIdleTime time.Duration `validate:"" envconfig:"POSTGRES_CONN_MAX_IDLE_TIME" mapstructure:"conn_max_idle_time" default:"5m"`
ConnectTimeout time.Duration `validate:"" envconfig:"POSTGRES_CONNECT_TIMEOUT" mapstructure:"connect_timeout" default:"10s"`
}
PostgresConfig contains PostgreSQL database configuration. Postgres 14 or later is required.
type STSConfig ¶
type STSConfig struct {
Address string `validate:"required" envconfig:"STS_ADDRESS" mapstructure:"address" default:"localhost:9090"`
UseTLS bool `validate:"" envconfig:"STS_USE_TLS" mapstructure:"use_tls" default:"false"`
Timeout time.Duration `validate:"" envconfig:"STS_TIMEOUT" mapstructure:"timeout" default:"10s"`
EagerConnectionCheck bool `validate:"" envconfig:"STS_EAGER_CONNECTION_CHECK" mapstructure:"eager_connection_check" default:"false"`
}
STSConfig contains Secure Token Service configuration
func (*STSConfig) CreateSTSConnection ¶
func (s *STSConfig) CreateSTSConnection() (*grpc.ClientConn, error)
CreateSTSConnection creates a gRPC connection to the STS service
type ServerConfig ¶
type ServerConfig struct {
GRPCPort int `validate:"required,min=1,max=65535" envconfig:"GRPC_PORT" mapstructure:"grpc_port" default:"9091"`
HTTPPort int `validate:"required,min=1,max=65535" envconfig:"HTTP_PORT" mapstructure:"http_port" default:"8070"`
Host string `validate:"required" envconfig:"SERVER_HOST" mapstructure:"host" default:"0.0.0.0"`
GracefulShutdownTimeout time.Duration `validate:"" envconfig:"SERVER_SHUTDOWN_TIMEOUT" mapstructure:"shutdown_timeout" default:"15s"`
Development bool `validate:"required" envconfig:"DEV" mapstructure:"development" default:"false"`
}
ServerConfig contains server configuration
func (*ServerConfig) GetGRPCAddress ¶
func (s *ServerConfig) GetGRPCAddress() string
GetGRPCAddress returns the full gRPC server address
func (*ServerConfig) GetHTTPAddress ¶
func (s *ServerConfig) GetHTTPAddress() string
GetHTTPAddress returns the full HTTP server address
type Services ¶
type Services struct {
Permissions *permissions.Service
ExternalAuthz *authz.ExternalAuthzService
}
Services holds all business logic services
type TelemetryConfig ¶
type TelemetryConfig struct {
Enabled bool `validate:"" envconfig:"TELEMETRY_ENABLED" mapstructure:"enabled" default:"false"`
OTLPEndpoint string `validate:"" envconfig:"OTEL_EXPORTER_OTLP_ENDPOINT" mapstructure:"otlp_endpoint"`
ServiceName string `validate:"required_if=Enabled true" envconfig:"OTEL_SERVICE_NAME" mapstructure:"service_name" default:"authorization-service"`
ServiceVersion string `validate:"required_if=Enabled true" envconfig:"OTEL_SERVICE_VERSION" mapstructure:"service_version" default:"v1.0.0"`
}
TelemetryConfig contains telemetry configuration
type ValkeyConfig ¶
type ValkeyConfig struct {
Enabled bool `validate:"" envconfig:"VALKEY_ENABLED" mapstructure:"enabled" default:"false"`
Address string `validate:"required_if=Enabled true" envconfig:"VALKEY_ADDRESS" mapstructure:"address" default:"localhost:6379"`
Username string `validate:"" envconfig:"VALKEY_USERNAME" mapstructure:"username"`
Password string `validate:"" envconfig:"VALKEY_PASSWORD" mapstructure:"password"`
DB int `validate:"min=0,max=15" envconfig:"VALKEY_DB" mapstructure:"db" default:"0"`
PoolSize int `validate:"min=1" envconfig:"VALKEY_POOL_SIZE" mapstructure:"pool_size" default:"10"`
Timeout time.Duration `validate:"" envconfig:"VALKEY_TIMEOUT" mapstructure:"timeout" default:"5s"`
UseTLS bool `validate:"" envconfig:"VALKEY_USE_TLS" mapstructure:"use_tls" default:"false"`
}
ValkeyConfig contains Valkey (Redis-compatible) configuration
type WorkerConfig ¶ added in v1.0.0
type WorkerConfig struct {
Enabled bool `validate:"" envconfig:"WORKER_ENABLED" mapstructure:"enabled" default:"false"`
BatchSize int `validate:"min=1" envconfig:"WORKER_BATCH_SIZE" mapstructure:"batch_size" default:"100"`
PollInterval time.Duration `validate:"" envconfig:"WORKER_POLL_INTERVAL" mapstructure:"poll_interval" default:"1s"`
MaxAttempts int `validate:"min=1" envconfig:"WORKER_MAX_ATTEMPTS" mapstructure:"max_attempts" default:"5"`
RetryBackoff time.Duration `validate:"" envconfig:"WORKER_RETRY_BACKOFF" mapstructure:"retry_backoff" default:"5m"`
StaleTimeout time.Duration `validate:"" envconfig:"WORKER_STALE_TIMEOUT" mapstructure:"stale_timeout" default:"15m"`
ReaperInterval time.Duration `validate:"" envconfig:"WORKER_REAPER_INTERVAL" mapstructure:"reaper_interval" default:"1m"`
}
WorkerConfig contains configuration for the async permission-update worker that claims rows from permission_update_work and applies them to OpenFGA.
The worker processes rows serially and scales horizontally by running multiple instances (FOR UPDATE SKIP LOCKED assigns disjoint rows), mirroring how the listener scales.