Skip to content

Insert client_name when upserting statically registered clients #4417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
2 changes: 2 additions & 0 deletions crates/cli/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ pub async fn config_sync(
}

let client_secret = client.client_secret.as_deref();
let client_name = client.client_name.as_ref();
let client_auth_method = client.client_auth_method();
let jwks = client.jwks.as_ref();
let jwks_uri = client.jwks_uri.as_ref();
Expand All @@ -369,6 +370,7 @@ pub async fn config_sync(
repo.oauth2_client()
.upsert_static(
client.client_id,
client_name.cloned(),
client_auth_method,
encrypted_client_secret,
jwks.cloned(),
Expand Down
4 changes: 4 additions & 0 deletions crates/config/src/sections/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ pub struct ClientConfig {
/// Authentication method used for this client
client_auth_method: ClientAuthMethodConfig,

/// Name of the `OAuth2` client
#[serde(skip_serializing_if = "Option::is_none")]
pub client_name: Option<String>,

/// The client secret, used by the `client_secret_basic`,
/// `client_secret_post` and `client_secret_jwt` authentication methods
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down

This file was deleted.

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

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

8 changes: 6 additions & 2 deletions crates/storage-pg/src/oauth2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
async fn upsert_static(
&mut self,
client_id: Ulid,
client_name: Option<String>,
client_auth_method: OAuthClientAuthenticationMethod,
encrypted_client_secret: Option<String>,
jwks: Option<PublicJsonWebKeySet>,
Expand Down Expand Up @@ -581,11 +582,12 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
, grant_type_device_code
, token_endpoint_auth_method
, jwks
, client_name
, jwks_uri
, is_static
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, TRUE)
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, TRUE)
ON CONFLICT (oauth2_client_id)
DO
UPDATE SET encrypted_client_secret = EXCLUDED.encrypted_client_secret
Expand All @@ -596,6 +598,7 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
, grant_type_device_code = EXCLUDED.grant_type_device_code
, token_endpoint_auth_method = EXCLUDED.token_endpoint_auth_method
, jwks = EXCLUDED.jwks
, client_name = EXCLUDED.client_name
, jwks_uri = EXCLUDED.jwks_uri
, is_static = TRUE
"#,
Expand All @@ -608,6 +611,7 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
true,
client_auth_method,
jwks_json,
client_name,
jwks_uri.as_ref().map(Url::as_str),
)
.traced()
Expand All @@ -633,7 +637,7 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
GrantType::RefreshToken,
GrantType::ClientCredentials,
],
client_name: None,
client_name,
logo_uri: None,
client_uri: None,
policy_uri: None,
Expand Down
2 changes: 2 additions & 0 deletions crates/storage/src/oauth2/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ pub trait OAuth2ClientRepository: Send + Sync {
async fn upsert_static(
&mut self,
client_id: Ulid,
client_name: Option<String>,
client_auth_method: OAuthClientAuthenticationMethod,
encrypted_client_secret: Option<String>,
jwks: Option<PublicJsonWebKeySet>,
Expand Down Expand Up @@ -237,6 +238,7 @@ repository_impl!(OAuth2ClientRepository:
async fn upsert_static(
&mut self,
client_id: Ulid,
client_name: Option<String>,
client_auth_method: OAuthClientAuthenticationMethod,
encrypted_client_secret: Option<String>,
jwks: Option<PublicJsonWebKeySet>,
Expand Down
4 changes: 4 additions & 0 deletions docs/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@
}
]
},
"client_name": {
"description": "Name of the `OAuth2` client",
"type": "string"
},
"client_secret": {
"description": "The client secret, used by the `client_secret_basic`, `client_secret_post` and `client_secret_jwt` authentication methods",
"type": "string"
Expand Down
Loading