Skip to content

Commit 083798e

Browse files
committed
feat: add support for specifying a clientAuthenticationMethod for OIDC
1 parent 2ba637e commit 083798e

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

crates/stackable-operator/crds/DummyCluster.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ spec:
3030
description: This field contains OIDC-specific configuration. It is only required in case OIDC is used.
3131
nullable: true
3232
properties:
33+
clientAuthenticationMethod:
34+
default: client_secret_basic
35+
description: 'The client authentication method used when communicating with the token endpoint. Defaults to `client_secret_basic`. The required contents of `clientCredentialsSecret` depend on the chosen method: secret-based methods (`client_secret_basic`, `client_secret_post`, `client_secret_jwt`) expect a client secret, while `private_key_jwt` expects a private key.'
36+
enum:
37+
- client_secret_basic
38+
- client_secret_post
39+
- client_secret_jwt
40+
- private_key_jwt
41+
- none
42+
type: string
3343
clientCredentialsSecret:
3444
description: |-
3545
A reference to the OIDC client credentials secret. The secret contains

crates/stackable-operator/src/crd/authentication/oidc/mod.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,40 @@ pub mod versioned {
9090
Keycloak,
9191
}
9292

93+
/// OAuth2 client authentication methods as defined in the OpenID Connect Core spec.
94+
/// These methods are used by clients to authenticate to the authorization server
95+
/// when using the token endpoint.
96+
///
97+
/// See <https://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication> for details.
98+
#[derive(
99+
Clone, Copy, Debug, Default, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd,
100+
Serialize,
101+
)]
102+
#[serde(rename_all = "snake_case")]
103+
pub enum ClientAuthenticationMethod {
104+
/// Authenticate using HTTP Basic authentication with client_id and client_secret.
105+
/// This is the default method according to the OIDC spec.
106+
#[default]
107+
#[serde(rename = "client_secret_basic")]
108+
ClientSecretBasic,
109+
110+
/// Send client_id and client_secret in the request body.
111+
#[serde(rename = "client_secret_post")]
112+
ClientSecretPost,
113+
114+
/// Authenticate using a JWT signed with an HMAC SHA algorithm using the client_secret.
115+
#[serde(rename = "client_secret_jwt")]
116+
ClientSecretJwt,
117+
118+
/// Authenticate using a JWT signed with the client's private key.
119+
#[serde(rename = "private_key_jwt")]
120+
PrivateKeyJwt,
121+
122+
/// No client authentication (for public clients or implicit flow).
123+
#[serde(rename = "none")]
124+
None,
125+
}
126+
93127
/// OIDC specific config options. These are set on the product config level.
94128
#[derive(
95129
Clone, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize,
@@ -111,6 +145,25 @@ pub mod versioned {
111145
#[serde(default)]
112146
pub extra_scopes: Vec<String>,
113147

148+
/// The OAuth2 client authentication method to use for token endpoint requests.
149+
/// Defaults to [`ClientAuthenticationMethod::ClientSecretBasic`].
150+
///
151+
/// The contents and format of the `clientCredentialsSecret` are dependent on the selected
152+
/// method. For example, [`ClientAuthenticationMethod::ClientSecretBasic`] and
153+
/// [`ClientAuthenticationMethod::ClientSecretPost`] require a client secret string, whereas
154+
/// [`ClientAuthenticationMethod::PrivateKeyJwt`] requires a private key.
155+
///
156+
/// See [`ClientAuthenticationMethod`] for available options.
157+
#[schemars(
158+
description = "The client authentication method used when communicating with the token \
159+
endpoint. Defaults to `client_secret_basic`. The required contents of \
160+
`clientCredentialsSecret` depend on the chosen method: secret-based methods \
161+
(`client_secret_basic`, `client_secret_post`, `client_secret_jwt`) expect a client \
162+
secret, while `private_key_jwt` expects a private key."
163+
)]
164+
#[serde(default)]
165+
pub client_authentication_method: ClientAuthenticationMethod,
166+
114167
// If desired, operators can add custom fields that are only needed for this specific product.
115168
// They need to create a struct holding them and pass that as `T`.
116169
#[serde(flatten)]

0 commit comments

Comments
 (0)