Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit fc7489c

Browse files
committed
Flatten the upstream_oauth2 config section
1 parent aa6178a commit fc7489c

File tree

4 files changed

+259
-254
lines changed

4 files changed

+259
-254
lines changed

crates/cli/src/sync.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use sqlx::{postgres::PgAdvisoryLock, Connection, PgConnection};
2424
use tracing::{error, info, info_span, warn};
2525

2626
fn map_import_action(
27-
config: &mas_config::UpstreamOAuth2ImportAction,
27+
config: mas_config::UpstreamOAuth2ImportAction,
2828
) -> mas_data_model::UpstreamOAuthProviderImportAction {
2929
match config {
3030
mas_config::UpstreamOAuth2ImportAction::Ignore => {
@@ -50,15 +50,15 @@ fn map_claims_imports(
5050
template: config.subject.template.clone(),
5151
},
5252
localpart: mas_data_model::UpstreamOAuthProviderImportPreference {
53-
action: map_import_action(&config.localpart.action),
53+
action: map_import_action(config.localpart.action),
5454
template: config.localpart.template.clone(),
5555
},
5656
displayname: mas_data_model::UpstreamOAuthProviderImportPreference {
57-
action: map_import_action(&config.displayname.action),
57+
action: map_import_action(config.displayname.action),
5858
template: config.displayname.template.clone(),
5959
},
6060
email: mas_data_model::UpstreamOAuthProviderImportPreference {
61-
action: map_import_action(&config.email.action),
61+
action: map_import_action(config.email.action),
6262
template: config.email.template.clone(),
6363
},
6464
verify_email: match config.email.set_email_verification {
@@ -145,11 +145,10 @@ pub async fn config_sync(
145145
}
146146

147147
let encrypted_client_secret = provider
148-
.client_secret()
148+
.client_secret
149+
.as_deref()
149150
.map(|client_secret| encrypter.encrypt_to_string(client_secret.as_bytes()))
150151
.transpose()?;
151-
let token_endpoint_auth_method = provider.client_auth_method();
152-
let token_endpoint_signing_alg = provider.client_auth_signing_alg();
153152

154153
let discovery_mode = match provider.discovery_mode {
155154
mas_config::UpstreamOAuth2DiscoveryMode::Oidc => {
@@ -198,8 +197,10 @@ pub async fn config_sync(
198197
human_name: provider.human_name,
199198
brand_name: provider.brand_name,
200199
scope: provider.scope.parse()?,
201-
token_endpoint_auth_method,
202-
token_endpoint_signing_alg,
200+
token_endpoint_auth_method: provider.token_endpoint_auth_method.into(),
201+
token_endpoint_signing_alg: provider
202+
.token_endpoint_auth_signing_alg
203+
.clone(),
203204
client_id: provider.client_id,
204205
encrypted_client_secret,
205206
claims_imports: map_claims_imports(&provider.claims_imports),

crates/config/src/sections/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ pub use self::{
5353
upstream_oauth2::{
5454
ClaimsImports as UpstreamOAuth2ClaimsImports, DiscoveryMode as UpstreamOAuth2DiscoveryMode,
5555
EmailImportPreference as UpstreamOAuth2EmailImportPreference,
56-
ImportAction as UpstreamOAuth2ImportAction,
57-
ImportPreference as UpstreamOAuth2ImportPreference, PkceMethod as UpstreamOAuth2PkceMethod,
56+
ImportAction as UpstreamOAuth2ImportAction, PkceMethod as UpstreamOAuth2PkceMethod,
5857
SetEmailVerification as UpstreamOAuth2SetEmailVerification, UpstreamOAuth2Config,
5958
},
6059
};

0 commit comments

Comments
 (0)