-
Notifications
You must be signed in to change notification settings - Fork 57
Support Sign in with Apple #3521
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
Changes from 6 commits
2059e7b
3f07d45
c6954ea
ffe7622
82e76f0
ac70632
04e6960
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,11 +187,17 @@ pub async fn config_sync( | |
continue; | ||
} | ||
|
||
let encrypted_client_secret = provider | ||
.client_secret | ||
.as_deref() | ||
.map(|client_secret| encrypter.encrypt_to_string(client_secret.as_bytes())) | ||
.transpose()?; | ||
let encrypted_client_secret = | ||
if let Some(client_secret) = provider.client_secret.as_deref() { | ||
Some(encrypter.encrypt_to_string(client_secret.as_bytes())?) | ||
} else if let Some(siwa) = provider.sign_in_with_apple.as_ref() { | ||
// For SIWA, we JSON-encode the config and encrypt it, reusing the client_secret | ||
// field in the database | ||
let encoded = serde_json::to_vec(siwa)?; | ||
Some(encrypter.encrypt_to_string(&encoded)?) | ||
} else { | ||
None | ||
}; | ||
|
||
let discovery_mode = match provider.discovery_mode { | ||
mas_config::UpstreamOAuth2DiscoveryMode::Oidc => { | ||
|
@@ -205,6 +211,36 @@ pub async fn config_sync( | |
} | ||
}; | ||
|
||
let token_endpoint_auth_method = match provider.token_endpoint_auth_method { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this would be better suited as an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The crates where both structures are defined don't depend on each other, which is why we can't implement it |
||
mas_config::UpstreamOAuth2TokenAuthMethod::None => { | ||
mas_data_model::UpstreamOAuthProviderTokenAuthMethod::None | ||
} | ||
mas_config::UpstreamOAuth2TokenAuthMethod::ClientSecretBasic => { | ||
mas_data_model::UpstreamOAuthProviderTokenAuthMethod::ClientSecretBasic | ||
} | ||
mas_config::UpstreamOAuth2TokenAuthMethod::ClientSecretPost => { | ||
mas_data_model::UpstreamOAuthProviderTokenAuthMethod::ClientSecretPost | ||
} | ||
mas_config::UpstreamOAuth2TokenAuthMethod::ClientSecretJwt => { | ||
mas_data_model::UpstreamOAuthProviderTokenAuthMethod::ClientSecretJwt | ||
} | ||
mas_config::UpstreamOAuth2TokenAuthMethod::PrivateKeyJwt => { | ||
mas_data_model::UpstreamOAuthProviderTokenAuthMethod::PrivateKeyJwt | ||
} | ||
mas_config::UpstreamOAuth2TokenAuthMethod::SignInWithApple => { | ||
mas_data_model::UpstreamOAuthProviderTokenAuthMethod::SignInWithApple | ||
} | ||
}; | ||
|
||
let response_mode = match provider.response_mode { | ||
mas_config::UpstreamOAuth2ResponseMode::Query => { | ||
mas_data_model::UpstreamOAuthProviderResponseMode::Query | ||
} | ||
mas_config::UpstreamOAuth2ResponseMode::FormPost => { | ||
mas_data_model::UpstreamOAuthProviderResponseMode::FormPost | ||
} | ||
}; | ||
|
||
if discovery_mode.is_disabled() { | ||
if provider.authorization_endpoint.is_none() { | ||
error!("Provider has discovery disabled but no authorization endpoint set"); | ||
|
@@ -240,7 +276,7 @@ pub async fn config_sync( | |
human_name: provider.human_name, | ||
brand_name: provider.brand_name, | ||
scope: provider.scope.parse()?, | ||
token_endpoint_auth_method: provider.token_endpoint_auth_method.into(), | ||
token_endpoint_auth_method, | ||
token_endpoint_signing_alg: provider | ||
.token_endpoint_auth_signing_alg | ||
.clone(), | ||
|
@@ -252,6 +288,7 @@ pub async fn config_sync( | |
jwks_uri_override: provider.jwks_uri, | ||
discovery_mode, | ||
pkce_mode, | ||
response_mode, | ||
additional_authorization_parameters: provider | ||
.additional_authorization_parameters | ||
.into_iter() | ||
|
Uh oh!
There was an error while loading. Please reload this page.