Skip to content

Commit 9cfecaf

Browse files
authored
Insert client_name when upserting statically registered clients (#4417)
2 parents 19b4f0d + c0582ed commit 9cfecaf

8 files changed

+43
-26
lines changed

crates/cli/src/sync.rs

+2
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ pub async fn config_sync(
357357
}
358358

359359
let client_secret = client.client_secret.as_deref();
360+
let client_name = client.client_name.as_ref();
360361
let client_auth_method = client.client_auth_method();
361362
let jwks = client.jwks.as_ref();
362363
let jwks_uri = client.jwks_uri.as_ref();
@@ -369,6 +370,7 @@ pub async fn config_sync(
369370
repo.oauth2_client()
370371
.upsert_static(
371372
client.client_id,
373+
client_name.cloned(),
372374
client_auth_method,
373375
encrypted_client_secret,
374376
jwks.cloned(),

crates/config/src/sections/clients.rs

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ pub struct ClientConfig {
7979
/// Authentication method used for this client
8080
client_auth_method: ClientAuthMethodConfig,
8181

82+
/// Name of the `OAuth2` client
83+
#[serde(skip_serializing_if = "Option::is_none")]
84+
pub client_name: Option<String>,
85+
8286
/// The client secret, used by the `client_secret_basic`,
8387
/// `client_secret_post` and `client_secret_jwt` authentication methods
8488
#[serde(skip_serializing_if = "Option::is_none")]

crates/storage-pg/.sqlx/query-5236305c49b1ee99a00e32df3727ebe97b523b6836e1696d8b8e2a0ef70bfa44.json

-23
This file was deleted.

crates/storage-pg/.sqlx/query-da02f93d7346992a9795f12b900f91ac0b326dd751c0d374d6ef4d19f671d22e.json

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/storage-pg/.sqlx/query-fcd8b4b9e003d1540357c6bf1ff9c715560d011d4c01112703a9c046170c84f1.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/storage-pg/src/oauth2/client.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
554554
async fn upsert_static(
555555
&mut self,
556556
client_id: Ulid,
557+
client_name: Option<String>,
557558
client_auth_method: OAuthClientAuthenticationMethod,
558559
encrypted_client_secret: Option<String>,
559560
jwks: Option<PublicJsonWebKeySet>,
@@ -581,11 +582,12 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
581582
, grant_type_device_code
582583
, token_endpoint_auth_method
583584
, jwks
585+
, client_name
584586
, jwks_uri
585587
, is_static
586588
)
587589
VALUES
588-
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, TRUE)
590+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, TRUE)
589591
ON CONFLICT (oauth2_client_id)
590592
DO
591593
UPDATE SET encrypted_client_secret = EXCLUDED.encrypted_client_secret
@@ -596,6 +598,7 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
596598
, grant_type_device_code = EXCLUDED.grant_type_device_code
597599
, token_endpoint_auth_method = EXCLUDED.token_endpoint_auth_method
598600
, jwks = EXCLUDED.jwks
601+
, client_name = EXCLUDED.client_name
599602
, jwks_uri = EXCLUDED.jwks_uri
600603
, is_static = TRUE
601604
"#,
@@ -608,6 +611,7 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
608611
true,
609612
client_auth_method,
610613
jwks_json,
614+
client_name,
611615
jwks_uri.as_ref().map(Url::as_str),
612616
)
613617
.traced()
@@ -633,7 +637,7 @@ impl OAuth2ClientRepository for PgOAuth2ClientRepository<'_> {
633637
GrantType::RefreshToken,
634638
GrantType::ClientCredentials,
635639
],
636-
client_name: None,
640+
client_name,
637641
logo_uri: None,
638642
client_uri: None,
639643
policy_uri: None,

crates/storage/src/oauth2/client.rs

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub trait OAuth2ClientRepository: Send + Sync {
157157
async fn upsert_static(
158158
&mut self,
159159
client_id: Ulid,
160+
client_name: Option<String>,
160161
client_auth_method: OAuthClientAuthenticationMethod,
161162
encrypted_client_secret: Option<String>,
162163
jwks: Option<PublicJsonWebKeySet>,
@@ -237,6 +238,7 @@ repository_impl!(OAuth2ClientRepository:
237238
async fn upsert_static(
238239
&mut self,
239240
client_id: Ulid,
241+
client_name: Option<String>,
240242
client_auth_method: OAuthClientAuthenticationMethod,
241243
encrypted_client_secret: Option<String>,
242244
jwks: Option<PublicJsonWebKeySet>,

docs/config.schema.json

+4
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@
239239
}
240240
]
241241
},
242+
"client_name": {
243+
"description": "Name of the `OAuth2` client",
244+
"type": "string"
245+
},
242246
"client_secret": {
243247
"description": "The client secret, used by the `client_secret_basic`, `client_secret_post` and `client_secret_jwt` authentication methods",
244248
"type": "string"

0 commit comments

Comments
 (0)