Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure spring boot security OAuth2 for ADFS?

Has anyone successfully configured Spring Boot OAuth2 with ADFS as the identity provider? I followed this tutorial successfully for Facebook, https://spring.io/guides/tutorials/spring-boot-oauth2/, but ADFS doesn't appear to have a userInfoUri. I think ADFS returns the claims data in the token itself (JWT format?), but not sure how to make that work with Spring. Here is what I have so far in my properties file:

security:
  oauth2:
    client:
      clientId: [client id setup with ADFS]
      userAuthorizationUri: https://[adfs domain]/adfs/oauth2/authorize?resource=[MyRelyingPartyTrust]
      accessTokenUri: https://[adfs domain]/adfs/oauth2/token
      tokenName: code
      authenticationScheme: query
      clientAuthenticationScheme: form
      grant-type: authorization_code
    resource:
      userInfoUri: [not sure what to put here?]
like image 412
Erik Pearson Avatar asked Mar 31 '17 19:03

Erik Pearson


People also ask

Does Spring Boot support OAuth2 authorization?

Because one of the samples is a full OAuth2 Authorization Server we have used the shim JAR which supports bridging from Spring Boot 2.0 to the old Spring Security OAuth2 library. The simpler samples could also be implemented using the native OAuth2 support in Spring Boot security features. The configuration is very similar.

How do I enable OAuth2 auto configuration?

OAuth2 Authorization Server Auto-Configuration If we want our application to be an OAuth2 provider, we can use @EnableAuthorizationServer. On startup, we'll notice in the logs that the auto-configuration classes will generate a client id and a client secret for our authorization server, and of course a random password for basic authentication:

How do I add security to a Spring Boot application?

Default Security Setup In order to add security to our Spring Boot application, we need to add the security starter dependency: This will also include the SecurityAutoConfiguration class containing the initial/default security configuration.

What is the use of websecurityconfigureradapter in Spring Boot?

Spring Boot attaches special meaning to a WebSecurityConfigurerAdapter on the class annotated with @SpringBootApplication: It uses it to configure the security filter chain that carries the OAuth 2.0 authentication processor. The above configuration indicates a whitelist of permitted endpoints, with every other endpoint requiring authentication.


1 Answers

Although this question is old, there is no other reference on the web on how to integrate Spring OAuth2 with ADFS.

I therefore added a sample project on how to integrate with Microsoft ADFS using the out of the box spring boot auto-configuration for Oauth2 Client:

https://github.com/selvinsource/spring-security/tree/oauth2login-adfs-sample/samples/boot/oauth2login#adfs-login

like image 185
selvinsource Avatar answered Oct 25 '22 16:10

selvinsource