Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultOAuthDisplayName added in v0.1.1

func DefaultOAuthDisplayName(providerID string) string

DefaultOAuthDisplayName returns the login button label for a provider.

func NormalizeEmailDomain added in v0.1.3

func NormalizeEmailDomain(raw string) string

NormalizeEmailDomain lowercases an email domain and strips a leading "@".

func NormalizeOAuthProviderID added in v0.1.1

func NormalizeOAuthProviderID(id string) string

Types

type ClaimMapEntry added in v0.1.3

type ClaimMapEntry struct {
	Value  string
	Mapped string
}

ClaimMapEntry maps an IdP claim value to an IPAM role or organization (parse order is preserved).

type Config

type Config struct {
	OAuth OAuthConfig
	// AppOrigin is the public URL of the frontend (e.g. http://localhost:5173). When set, invite URLs and OAuth redirects use it; non-API requests to this server return 401 Unauthorized.
	AppOrigin string
	Metrics   MetricsConfig
}

func LoadFromEnv

func LoadFromEnv() *Config

func (*Config) EnabledOAuthProviders

func (c *Config) EnabledOAuthProviders() []string

EnabledOAuthProviders returns the list of provider IDs that are configured and enabled.

func (*Config) OAuthProvider

func (c *Config) OAuthProvider(providerID string) *OAuthProviderConfig

OAuthProvider returns the config for a provider ID, or nil if not configured.

type MetricsConfig added in v0.1.2

type MetricsConfig struct {
	// Enabled mounts /metrics. METRICS_ENABLED; defaults to true.
	Enabled bool
	// Token, when non-empty, requires Authorization: Bearer <token> on /metrics. METRICS_TOKEN.
	Token string // #nosec G117 -- scrape credential from config, not logged
}

MetricsConfig controls the Prometheus GET /metrics endpoint.

type OAuthClientMTLSConfig added in v0.1.1

type OAuthClientMTLSConfig struct {
	Enabled     bool
	TLSCertFile string
	TLSKeyFile  string
	TLSVersion  uint16
}

type OAuthConfig

type OAuthConfig struct {
	Providers map[string]OAuthProviderConfig
}

type OAuthProviderConfig

type OAuthProviderConfig struct {
	ClientID               string
	ClientSecret           string // #nosec G117 -- OAuth client secret from config, not logged
	Scopes                 []string
	AuthURL                string
	TokenURL               string
	UserInfoURL            string
	UserIDClaim            string // JSON claim for provider user id; default "sub"
	EmailClaim             string // JSON claim for email; default "email"
	EmailsURL              string // Optional second URL returning a JSON array when email is not on userinfo (e.g. GitHub /user/emails)
	EmailsPrimaryClaim     string // Claim on array entries marking the preferred email; default "primary"
	EmailVerifiedClaim     string // Userinfo claim that must be true when email comes from userinfo (e.g. email_verified)
	EmailsVerifiedClaim    string // Emails-list entry claim that must be true (e.g. verified on GitHub /user/emails)
	AllowEmailMatch        bool   // Allow signing in to an existing account by email alone; default false
	DisplayName            string // Login/signup button label; default derived from provider id
	ClientMTLS             OAuthClientMTLSConfig
	JITEnabled             bool            // Create users on first SSO login without an invite; default false
	JITDefaultRole         string          // Role when ROLE_MAP does not match; default "user"
	JITDefaultOrganization string          // Org name or UUID when ORG_CLAIM is missing and domain map does not match
	JITAllowedEmailDomains []string        // If set, JIT only accepts these exact email domains
	JITDomainOrgMap        []ClaimMapEntry // email domain → organization name or UUID; also an allowlist when AllowedEmailDomains is empty
	RoleClaim              string          // Dotted claim path for role mapping (e.g. groups, realm_access.roles)
	RoleMap                []ClaimMapEntry // claim value → IPAM role (user or admin)
	OrgClaim               string          // Dotted claim path for organization mapping
	OrgMap                 []ClaimMapEntry // claim value → organization name or UUID
}

func (OAuthProviderConfig) BuildHTTPClient added in v0.1.1

func (p OAuthProviderConfig) BuildHTTPClient() (*http.Client, error)

func (OAuthProviderConfig) Enabled added in v0.1.1

func (p OAuthProviderConfig) Enabled() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL