@Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .anyRequest().authenticated() .and() .securityContext() .securityContextRepository(securityContextRepository()) .and() .oauth2Login() .tokenEndpoint() .accessTokenResponseClient(createOauth2AccessTokenResponseClient()) .and() .userInfoEndpoint() .userService(createOauth2UserService()) .oidcUserService(createOidcUserService()); }
@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/oauth_login", "/loginFailure", "/") .permitAll() .anyRequest() .authenticated() .and() .oauth2Login() .loginPage("/oauth_login") .authorizationEndpoint() .baseUri("/oauth2/authorize-client") .authorizationRequestRepository(authorizationRequestRepository()) .and() .tokenEndpoint() .accessTokenResponseClient(accessTokenResponseClient()) .and() .defaultSuccessUrl("/loginSuccess") .failureUrl("/loginFailure"); }
private void configureLogin(HttpSecurity http, OktaOAuth2Properties oktaOAuth2Properties) throws Exception { http.oauth2Login() .userInfoEndpoint() .userService(new OktaOAuth2UserService(oktaOAuth2Properties.getGroupsClaim())) .oidcUserService(new OktaOidcUserService(oktaOAuth2Properties.getGroupsClaim())) .and() .tokenEndpoint() .accessTokenResponseClient(accessTokenResponseClient()); if (oktaOAuth2Properties.getRedirectUri() != null) { http.oauth2Login().redirectionEndpoint().baseUri(oktaOAuth2Properties.getRedirectUri()); } }