Expected Behavior Apple now forces app developers to provide Sign in with Apple if they want to submit apps that currently use oath2 with other providers. Spring Security should offer a default CommonOAuth2Provider.APPLE implementation to ease the configuration process.
Current Behavior
Currently, Spring Security only support Google, Facebook, GitHub and OKTA providers. https://github.com/spring-projects/spring-security/blob/master/config/src/main/java/org/springframework/security/config/oauth2/client/CommonOAuth2Provider.java
9047 is suggesting a solution as below.
APPPLE {
@Override
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId, ClientAuthenticationMethod.POST,
DEFAULT_REDIRECT_URL);
builder.scope("openid", "name", "email");
builder.authorizationUri("https://appleid.apple.com/auth/authorize?response_mode=form_post");
builder.tokenUri("https://appleid.apple.com/auth/token");
builder.jwkSetUri("https://appleid.apple.com/auth/keys");
builder.clientName("Apple");
return builder;
}
}
Context Even though @jgrandja suggested to use application.yml file to define configuration as below. It was not resolved the issue. After adding these configurations spring security is not identified the apple provider and throws an exception.
spring:
security:
oauth2:
client:
registration:
apple:
client-id: apple-client-id
client-secret: apple-client-secret
provider:
apple:
authorization-uri: https://appleid.apple.com/auth/authorize?response_mode=form_post
token-uri: https://appleid.apple.com/auth/token
jwk-set-uri: https://appleid.apple.com/auth/keys
Exception
java.lang.IllegalArgumentException: Invalid Client Registration with Id: apple
at org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizationRequestResolver.resolve(DefaultOAuth2AuthorizationRequestResolver.java:130) ~[spring-security-oauth2-client-5.3.4.RELEASE.jar:5.3.4.RELEASE]
Comment From: jgrandja
@SelanDeemantha Based on the message in the stack trace:
java.lang.IllegalArgumentException: Invalid Client Registration with Id: apple
This is more than likely a misconfiguration in the client application.
FYI, questions are better suited to Stack Overflow. We prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add a minimal sample that reproduces this issue if you feel this is a genuine bug.