You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-05-18 10:01:03 +02:00
7c96234233
* feat: add support for specifying allowed OIDC JWT signing algorithms (#2753) TODO: - [X] update docs - [X] add support in yaml (modern) config - [X] add more test(s)? Add (legacy for now) configuration flag "oidc-enabled-signing-alg" (cfg: oidc_enabled_signing_algs) that allows setting what signing algorithms are specified by provider in JWT header ("alg" header claim). In particular useful when skip_oidc_discovery = true, as verifier defaults to only accept "RS256" in alg field in such circumstances. Signed-off-by: Jan Larwig <jan@larwig.com> * doc: update changelog and alpha config Signed-off-by: Jan Larwig <jan@larwig.com> * feat: add signing algorithm intersection handling with oidc discovery and additional tests Signed-off-by: Jan Larwig <jan@larwig.com> --------- Signed-off-by: Jan Larwig <jan@larwig.com> Co-authored-by: Jan Larwig <jan@larwig.com>
137 lines
4.1 KiB
Go
137 lines
4.1 KiB
Go
package validation
|
|
|
|
import (
|
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Providers", func() {
|
|
type validateProvidersTableInput struct {
|
|
options *options.Options
|
|
errStrings []string
|
|
}
|
|
|
|
validProvider := options.Provider{
|
|
ID: "ProviderID",
|
|
ClientID: "ClientID",
|
|
ClientSecret: "ClientSecret",
|
|
}
|
|
|
|
validOIDCSigningAlgorithmsProvider := options.Provider{
|
|
ID: "ProviderIDOIDCSigningAlgorithms",
|
|
ClientID: "ClientID",
|
|
ClientSecret: "ClientSecret",
|
|
OIDCConfig: options.OIDCOptions{
|
|
EnabledSigningAlgs: []string{"RS256", "EdDSA"},
|
|
},
|
|
}
|
|
|
|
invalidOIDCSigningAlgorithmsProvider := options.Provider{
|
|
ID: "ProviderIDInvalidOIDCSigningAlgorithms",
|
|
ClientID: "ClientID",
|
|
ClientSecret: "ClientSecret",
|
|
OIDCConfig: options.OIDCOptions{
|
|
EnabledSigningAlgs: []string{"RS256", "invalid"},
|
|
},
|
|
}
|
|
|
|
invalidOIDCSigningAlgorithmCaseProvider := options.Provider{
|
|
ID: "ProviderIDInvalidOIDCSigningAlgorithmCase",
|
|
ClientID: "ClientID",
|
|
ClientSecret: "ClientSecret",
|
|
OIDCConfig: options.OIDCOptions{
|
|
EnabledSigningAlgs: []string{"rs256"},
|
|
},
|
|
}
|
|
|
|
validLoginGovProvider := options.Provider{
|
|
Type: "login.gov",
|
|
ID: "ProviderIDLoginGov",
|
|
ClientID: "ClientID",
|
|
ClientSecret: "ClientSecret",
|
|
}
|
|
|
|
missingIDProvider := options.Provider{
|
|
ClientID: "ClientID",
|
|
ClientSecret: "ClientSecret",
|
|
}
|
|
|
|
missingProvider := "at least one provider has to be defined"
|
|
emptyIDMsg := "provider has empty id: ids are required for all providers"
|
|
duplicateProviderIDMsg := "multiple providers found with id ProviderID: provider ids must be unique"
|
|
skipButtonAndMultipleProvidersMsg := "SkipProviderButton and multiple providers are mutually exclusive"
|
|
invalidOIDCSigningAlgorithmMsg := "provider ProviderIDInvalidOIDCSigningAlgorithms has invalid EnabledSigningAlgs entry \"invalid\""
|
|
invalidOIDCSigningAlgorithmCaseMsg := "provider ProviderIDInvalidOIDCSigningAlgorithmCase has invalid EnabledSigningAlgs entry \"rs256\""
|
|
|
|
DescribeTable("validateProviders",
|
|
func(o *validateProvidersTableInput) {
|
|
Expect(validateProviders(o.options)).To(ConsistOf(o.errStrings))
|
|
},
|
|
Entry("with no providers", &validateProvidersTableInput{
|
|
options: &options.Options{},
|
|
errStrings: []string{missingProvider},
|
|
}),
|
|
Entry("with valid providers", &validateProvidersTableInput{
|
|
options: &options.Options{
|
|
Providers: options.Providers{
|
|
validProvider,
|
|
validLoginGovProvider,
|
|
},
|
|
},
|
|
errStrings: []string{},
|
|
}),
|
|
Entry("with an empty providerID", &validateProvidersTableInput{
|
|
options: &options.Options{
|
|
Providers: options.Providers{
|
|
missingIDProvider,
|
|
},
|
|
},
|
|
errStrings: []string{emptyIDMsg},
|
|
}),
|
|
Entry("with same providerID", &validateProvidersTableInput{
|
|
options: &options.Options{
|
|
Providers: options.Providers{
|
|
validProvider,
|
|
validProvider,
|
|
},
|
|
},
|
|
errStrings: []string{duplicateProviderIDMsg},
|
|
}),
|
|
Entry("with multiple providers and skip provider button", &validateProvidersTableInput{
|
|
options: &options.Options{
|
|
SkipProviderButton: true,
|
|
Providers: options.Providers{
|
|
validProvider,
|
|
validLoginGovProvider,
|
|
},
|
|
},
|
|
errStrings: []string{skipButtonAndMultipleProvidersMsg},
|
|
}),
|
|
Entry("with valid OIDC signing algorithms", &validateProvidersTableInput{
|
|
options: &options.Options{
|
|
Providers: options.Providers{
|
|
validOIDCSigningAlgorithmsProvider,
|
|
},
|
|
},
|
|
errStrings: []string{},
|
|
}),
|
|
Entry("with an invalid OIDC signing algorithm", &validateProvidersTableInput{
|
|
options: &options.Options{
|
|
Providers: options.Providers{
|
|
invalidOIDCSigningAlgorithmsProvider,
|
|
},
|
|
},
|
|
errStrings: []string{invalidOIDCSigningAlgorithmMsg},
|
|
}),
|
|
Entry("with an OIDC signing algorithm using invalid casing", &validateProvidersTableInput{
|
|
options: &options.Options{
|
|
Providers: options.Providers{
|
|
invalidOIDCSigningAlgorithmCaseProvider,
|
|
},
|
|
},
|
|
errStrings: []string{invalidOIDCSigningAlgorithmCaseMsg},
|
|
}),
|
|
)
|
|
})
|