Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1422,8 +1422,21 @@ spec:
type: object
type:
description: 'Type is the auth strategy: "unauthenticated",
"header_injection", "token_exchange"'
"header_injection", "token_exchange", "upstream_inject"'
type: string
upstreamInject:
description: |-
UpstreamInject contains configuration for upstream inject auth strategy.
Used when Type = "upstream_inject".
properties:
providerName:
description: |-
ProviderName is the name of the upstream provider configured in the
embedded authorization server. Must match an entry in AuthServer.Upstreams.
type: string
required:
- providerName
type: object
required:
- type
type: object
Expand Down Expand Up @@ -1498,8 +1511,21 @@ spec:
type: object
type:
description: 'Type is the auth strategy: "unauthenticated",
"header_injection", "token_exchange"'
"header_injection", "token_exchange", "upstream_inject"'
type: string
upstreamInject:
description: |-
UpstreamInject contains configuration for upstream inject auth strategy.
Used when Type = "upstream_inject".
properties:
providerName:
description: |-
ProviderName is the name of the upstream provider configured in the
embedded authorization server. Must match an entry in AuthServer.Upstreams.
type: string
required:
- providerName
type: object
required:
- type
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1425,8 +1425,21 @@ spec:
type: object
type:
description: 'Type is the auth strategy: "unauthenticated",
"header_injection", "token_exchange"'
"header_injection", "token_exchange", "upstream_inject"'
type: string
upstreamInject:
description: |-
UpstreamInject contains configuration for upstream inject auth strategy.
Used when Type = "upstream_inject".
properties:
providerName:
description: |-
ProviderName is the name of the upstream provider configured in the
embedded authorization server. Must match an entry in AuthServer.Upstreams.
type: string
required:
- providerName
type: object
required:
- type
type: object
Expand Down Expand Up @@ -1501,8 +1514,21 @@ spec:
type: object
type:
description: 'Type is the auth strategy: "unauthenticated",
"header_injection", "token_exchange"'
"header_injection", "token_exchange", "upstream_inject"'
type: string
upstreamInject:
description: |-
UpstreamInject contains configuration for upstream inject auth strategy.
Used when Type = "upstream_inject".
properties:
providerName:
description: |-
ProviderName is the name of the upstream provider configured in the
embedded authorization server. Must match an entry in AuthServer.Upstreams.
type: string
required:
- providerName
type: object
required:
- type
type: object
Expand Down
21 changes: 20 additions & 1 deletion docs/operator/crd-api.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions pkg/authserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ const (
UpstreamProviderTypeOAuth2 UpstreamProviderType = "oauth2"
)

// DefaultUpstreamName is the name assigned to a single unnamed upstream.
const DefaultUpstreamName = "default"

// ResolveUpstreamName returns the canonical name for an upstream.
// An empty name is resolved to DefaultUpstreamName ("default").
func ResolveUpstreamName(name string) string {
if name == "" {
return DefaultUpstreamName
}
return name
}

// upstreamNameRegex validates upstream provider names.
// Names must be DNS-label-like to prevent delimiter injection in storage keys.
var upstreamNameRegex = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`)
Expand Down Expand Up @@ -414,14 +426,14 @@ func (c *Config) validateUpstreams() error {
func (c *Config) validateUpstreamName(i int, up *UpstreamConfig) error {
if len(c.Upstreams) == 1 {
if up.Name == "" {
up.Name = "default"
up.Name = DefaultUpstreamName
}
} else {
if up.Name == "" {
return fmt.Errorf(
"upstream[%d]: name must be explicitly set when multiple upstreams are configured", i)
}
if up.Name == "default" {
if up.Name == DefaultUpstreamName {
return fmt.Errorf(
"upstream[%d]: name %q is reserved for single-upstream configs; use a descriptive name",
i, up.Name)
Expand Down
22 changes: 21 additions & 1 deletion pkg/vmcp/auth/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const (
// This strategy exchanges an incoming token for a new token to use
// when authenticating to the backend service.
StrategyTypeTokenExchange = "token_exchange"

// StrategyTypeUpstreamInject identifies the upstream inject strategy.
// This strategy injects an upstream IDP token obtained by the embedded
// authorization server into requests to the backend service.
StrategyTypeUpstreamInject = "upstream_inject"
)

// BackendAuthStrategy defines how to authenticate to a specific backend.
Expand All @@ -36,7 +41,7 @@ const (
// +kubebuilder:object:generate=true
// +gendoc
type BackendAuthStrategy struct {
// Type is the auth strategy: "unauthenticated", "header_injection", "token_exchange"
// Type is the auth strategy: "unauthenticated", "header_injection", "token_exchange", "upstream_inject"
Type string `json:"type" yaml:"type"`

// HeaderInjection contains configuration for header injection auth strategy.
Expand All @@ -46,6 +51,10 @@ type BackendAuthStrategy struct {
// TokenExchange contains configuration for token exchange auth strategy.
// Used when Type = "token_exchange".
TokenExchange *TokenExchangeConfig `json:"tokenExchange,omitempty" yaml:"tokenExchange,omitempty"`

// UpstreamInject contains configuration for upstream inject auth strategy.
// Used when Type = "upstream_inject".
UpstreamInject *UpstreamInjectConfig `json:"upstreamInject,omitempty" yaml:"upstreamInject,omitempty"`
}

// HeaderInjectionConfig configures the header injection auth strategy.
Expand Down Expand Up @@ -95,3 +104,14 @@ type TokenExchangeConfig struct {
// Defaults to "urn:ietf:params:oauth:token-type:access_token" if not specified.
SubjectTokenType string `json:"subjectTokenType,omitempty" yaml:"subjectTokenType,omitempty"`
}

// UpstreamInjectConfig configures the upstream inject auth strategy.
// This strategy uses the embedded authorization server to obtain and inject
// upstream IDP tokens into backend requests.
// +kubebuilder:object:generate=true
// +gendoc
type UpstreamInjectConfig struct {
// ProviderName is the name of the upstream provider configured in the
// embedded authorization server. Must match an entry in AuthServer.Upstreams.
ProviderName string `json:"providerName" yaml:"providerName"`
}
20 changes: 20 additions & 0 deletions pkg/vmcp/auth/types/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading