Files
wonderwall/pkg/mock/client.go
Trong Huu Nguyen da69847027 feat(openid): add opt-in toggle for typ header in accordance with RFC7523bis
Some providers require that the `typ` header has a value exactly equal
to `client-authentication+jwt` in accordance with changes introduced by
RFC7523bis.

This commit allows for opting in to setting the `typ` header with this new value.

The default behaviour is to use the previous de facto standard value, `JWT`.
Once the changes in RFC7523bis lands in the affected standards and
identity providers start supporting the new `typ` header (Entra ID being
notable for not supporting this as of this commit), we will default to
use `client-authentication+jwt`.
2025-08-26 08:29:27 +02:00

83 lines
2.0 KiB
Go

package mock
import (
"github.com/lestrrat-go/jwx/v3/jwk"
"github.com/nais/wonderwall/internal/crypto"
"github.com/nais/wonderwall/pkg/config"
openidconfig "github.com/nais/wonderwall/pkg/openid/config"
"github.com/nais/wonderwall/pkg/openid/scopes"
)
type TestClientConfiguration struct {
*config.Config
clientJwk jwk.Key
trustedAudiences map[string]bool
}
var _ openidconfig.Client = (*TestClientConfiguration)(nil)
func (c *TestClientConfiguration) ACRValues() string {
return c.Config.OpenID.ACRValues
}
func (c *TestClientConfiguration) Audiences() map[string]bool {
return c.trustedAudiences
}
func (c *TestClientConfiguration) AuthMethod() openidconfig.AuthMethod {
return openidconfig.AuthMethodPrivateKeyJWT
}
func (c *TestClientConfiguration) ClientID() string {
return c.Config.OpenID.ClientID
}
func (c *TestClientConfiguration) ClientJWK() jwk.Key {
return c.clientJwk
}
func (c *TestClientConfiguration) ClientSecret() string {
return c.Config.OpenID.ClientSecret
}
func (c *TestClientConfiguration) NewClientAuthJWTType() bool {
return c.Config.OpenID.NewClientAuthJWTType
}
func (c *TestClientConfiguration) SetPostLogoutRedirectURI(uri string) {
c.Config.OpenID.PostLogoutRedirectURI = uri
}
func (c *TestClientConfiguration) PostLogoutRedirectURI() string {
return c.Config.OpenID.PostLogoutRedirectURI
}
func (c *TestClientConfiguration) ResourceIndicator() string {
return c.Config.OpenID.ResourceIndicator
}
func (c *TestClientConfiguration) Scopes() scopes.Scopes {
return scopes.DefaultScopes().WithAdditional(c.Config.OpenID.Scopes...)
}
func (c *TestClientConfiguration) UILocales() string {
return c.Config.OpenID.UILocales
}
func (c *TestClientConfiguration) WellKnownURL() string {
return c.Config.OpenID.WellKnownURL
}
func clientConfiguration(cfg *config.Config) *TestClientConfiguration {
key, err := crypto.NewJwk()
if err != nil {
panic(err)
}
return &TestClientConfiguration{
Config: cfg,
clientJwk: key,
trustedAudiences: cfg.OpenID.TrustedAudiences(),
}
}