config

package
v1.69.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyDefaults added in v1.64.0

func ApplyDefaults(c *configpb.AuthConfig)

ApplyDefaults fills the iam-auth settings a config file left out. oauth and cors are required in the schema and validated before the defaults run, so they are never nil here.

Types

type CellConfig added in v1.54.0

type CellConfig struct {
	ID int `mapstructure:"id"`
}

CellConfig identifies a GitLab Cell whose OAuth discovery keys IAM should aggregate. Cells are reached through the shared gitlab-http-router (see Config.GitlabURL), not a per-Cell address, so only the ID is needed here.

func (CellConfig) Validate added in v1.54.0

func (c CellConfig) Validate() error

type Config

type Config struct {
	GRPCAddress string `mapstructure:"grpc_address"`
	HttpAddress string `mapstructure:"http_address"`

	// MetricsAddress defaults to ":9090" when unset (see MetricsAddr).
	MetricsAddress string `mapstructure:"metrics_address"`

	BaseUrl url.URL `mapstructure:"base_url"`

	// GitlabURL is the single GitLab instance this deployment talks to: the
	// instance third-party identities are linked into (OAuthClient's sign-in
	// flow) and, fronted by gitlab-http-router, the entry point used to reach
	// every configured Cell (OAuth.Cells) via a routing-hint cookie rather
	// than a per-Cell address. One field, not two: in every real deployment
	// these are the same URL.
	GitlabURL string `mapstructure:"gitlab_url"`

	OAuth OAuthServerConfig `mapstructure:"oauth"`

	OAuthClient OAuthClientConfig `mapstructure:"oauth_client"`

	ServiceAuth serviceauth.Config `mapstructure:",squash"`
}

func (Config) GRPCAddr

func (c Config) GRPCAddr() string

func (Config) HTTPAddr

func (c Config) HTTPAddr() string

func (Config) MetricsAddr added in v1.66.0

func (c Config) MetricsAddr() string

func (Config) Validate

func (c Config) Validate() error

type OAuthClientConfig

type OAuthClientConfig struct {
	Providers map[string]OAuthClientProviderConfig `mapstructure:"providers"`
}

func (*OAuthClientConfig) Validate

func (c *OAuthClientConfig) Validate(gitlabURL string) error

Validate also takes gitlabURL; see Config.GitlabURL.

type OAuthClientProviderConfig

type OAuthClientProviderConfig struct {
	// OIDC Discovery - if provided, auth_url, token_url, and user_info_url are fetched automatically
	Issuer string `mapstructure:"issuer"`

	// Manual OAuth configuration - required if issuer is not provided
	AuthURL     string `mapstructure:"auth_url"`
	TokenURL    string `mapstructure:"token_url"`
	UserInfoURL string `mapstructure:"user_info_url"`

	// Required for all providers
	ClientID     string   `mapstructure:"client_id"`
	ClientSecret string   `mapstructure:"client_secret"`
	Scopes       []string `mapstructure:"scopes"`
}

func (*OAuthClientProviderConfig) IsOIDC

func (p *OAuthClientProviderConfig) IsOIDC() bool

func (*OAuthClientProviderConfig) Validate

func (p *OAuthClientProviderConfig) Validate(providerName string) error

type OAuthServerConfig

type OAuthServerConfig struct {
	Issuer     string `mapstructure:"issuer"`
	ConsentURL string `mapstructure:"consent_url"`
	LoginURL   string `mapstructure:"login_url"`
	HMACSecret string `mapstructure:"hmac_secret"`

	// SigningKey is a base64-encoded PKCS#8 PEM RSA private key.
	SigningKey string `mapstructure:"signing_key"`

	// AccessTokenAudience identifies the resource server that consumes
	// IAM-issued JWT access tokens; set as the `aud` claim per RFC 9068 §2.2.
	AccessTokenAudience string `mapstructure:"access_token_audience" default:"gitlab-rails"`

	JwksCacheDuration time.Duration `mapstructure:"jwks_cache_duration" default:"3600s"`

	// UserInfoURL is GitLab Rails' `/api/v4/iam/userinfo` endpoint, which
	// accepts only an IAM-issued OAuth JWT (unlike the OIDC `/oauth/userinfo`
	// endpoint, which accepts any Doorkeeper-recognized token).
	//
	// SECURITY-SENSITIVE: every openid-scoped token exchange sends a bearer
	// access token to this URL. Must resolve to a trusted gitlab-rails instance
	UserInfoURL string `mapstructure:"user_info_url"`

	// Cells whose OAuth discovery keys IAM aggregates at /oauth/discovery/keys.
	// Reached through the shared gitlab-http-router at Config.GitlabURL, not a
	// per-Cell address; see CellConfig.
	Cells []CellConfig `mapstructure:"cells"`

	DynamicClientOrganizationID string `mapstructure:"dynamic_client_organization_id"`
}

func (OAuthServerConfig) CellIDs added in v1.54.0

func (o OAuthServerConfig) CellIDs() []int

CellIDs returns the configured Cell IDs, extracted here so callers (e.g. wiring a KeyAggregator) don't need to depend on CellConfig.

func (OAuthServerConfig) String added in v1.45.3

func (o OAuthServerConfig) String() string

String redacts HMACSecret and SigningKey so an accidental %v/%+v of this config (or a struct that embeds it) can't leak either into logs.

func (OAuthServerConfig) Validate

func (o OAuthServerConfig) Validate(gitlabURL string) error

Validate also takes gitlabURL; see Config.GitlabURL.

Jump to

Keyboard shortcuts

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