Skip to content

Instantly share code, notes, and snippets.

@fhanik
Last active May 20, 2016 21:55
Show Gist options
  • Select an option

  • Save fhanik/cd4de5baaf70cbbc21386ced71e4ac97 to your computer and use it in GitHub Desktop.

Select an option

Save fhanik/cd4de5baaf70cbbc21386ced71e4ac97 to your computer and use it in GitHub Desktop.
public class AuthcodeApplication extends OpenIdConnectConfigurerAdapter {
@RequestMapping("/oidc")
public String oidc(IdToken token) {
System.out.println("First name:" + token.getFirstName());
return "oidc";
}
@Override
protected void configure(OpenIdConnectSecurity http) throws Exception {
http
.antMatcher("/oidc").authorizeRequests().withIdToken()
.antMatchers("/oidc").access("@scopeChecker.hasAnyScope(authentication, 'openid')")
.and()
.antMatcher("/**").authorizeRequests()
.antMatchers("/", "/index", "/error").permitAll()
.anyRequest().authenticated();
}
}
@fhanik

fhanik commented May 20, 2016

Copy link
Copy Markdown
Author

The goals of this Gist would be to demonstrate how one may want to use Spring Cloud to enable both access_token and id_token to be available to a Spring Boot application.

Line 2 and Line 10- ability to override configure to protect endpoints

Line 4 - make id_token accessible through automatic injection

Line 12 - add support for withIdToken to enable retrieval of id_token (hybrid or during code to token exchange)

Spring Boot Application as it works today. Proposed functionality of OpenIdConnectConfigurerAdapter, OpenIdConnectSecurity not available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment