Something went wrong. Try again.
sloproxy
Something went wrong. Try again.
1.6 kB · 47 lines
Go
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748package access
// AccessConfig groups request authentication providers.type AccessConfig struct { // Providers lists configured authentication providers. Providers []AccessProvider `yaml:"providers,omitempty" json:"providers,omitempty"`}
// AccessProvider describes a request authentication provider entry.type AccessProvider struct { // Name is the instance identifier for the provider. Name string `yaml:"name" json:"name"`
// Type selects the provider implementation registered via the SDK. Type string `yaml:"type" json:"type"`
// SDK optionally names a third-party SDK module providing this provider. SDK string `yaml:"sdk,omitempty" json:"sdk,omitempty"`
// APIKeys lists inline keys for providers that require them. APIKeys []string `yaml:"api-keys,omitempty" json:"api-keys,omitempty"`
// Config passes provider-specific options to the implementation. Config map[string]any `yaml:"config,omitempty" json:"config,omitempty"`}
const ( // AccessProviderTypeConfigAPIKey is the built-in provider validating inline API keys. AccessProviderTypeConfigAPIKey = "config-api-key"
// DefaultAccessProviderName is applied when no provider name is supplied. DefaultAccessProviderName = "config-inline")
// MakeInlineAPIKeyProvider constructs an inline API key provider configuration.// It returns nil when no keys are supplied.func MakeInlineAPIKeyProvider(keys []string) *AccessProvider { if len(keys) == 0 { return nil } provider := &AccessProvider{ Name: DefaultAccessProviderName, Type: AccessProviderTypeConfigAPIKey, APIKeys: append([]string(nil), keys...), } return provider}