spring-boot OAuth2 client configuration -
i try implement oauth2 client using authorization-code grant flow spring-boot. not work.
"http://external_server/oauth/authorize" called, no get
arguments added.
does know wrong in below configuration?
auth provider implemented doorkeeper
, it's working. url constants in websecurityconfiguration
correct.
@configuration @enablewebmvcsecurity @enableoauth2client public class websecurityconfiguration extends websecurityconfigureradapter { private static final string auth_endpoint = "http://external_server"; private static final string login_url = auth_endpoint + "/users/sign_in"; private static final string logout_url = auth_endpoint + "/sign_out"; private static final string auth_url = auth_endpoint + "/oauth/authorize"; private static final string access_token_url = auth_endpoint + "/oauth/token"; @autowired oauth2clientcontext oauth2clientcontext; /** * specific api */ @bean public resttemplate resttemplate() { return new resttemplate(); } /** * accessing protected resource */ @bean public oauth2resttemplate oauth2resttemplate() { return new oauth2resttemplate(resource(), oauth2clientcontext); } @bean protected oauth2protectedresourcedetails resource() { authorizationcoderesourcedetails resource = new authorizationcoderesourcedetails(); resource.setclientid("_xxx_"); resource.setclientsecret("_yyy_"); resource.setuserauthorizationuri(auth_url); resource.setaccesstokenuri(access_token_url); return resource; } @override public void configure(websecurity web) throws exception { web.debug(true).ignoring().antmatchers("/webjars/**", "/css/**"); } @override protected void configure(httpsecurity http) throws exception { //@formatter:off http.csrf().disable().authorizerequests() .antmatchers("/", "/callback") .permitall() .anyrequest() .authenticated(); http.formlogin() .loginpage(auth_url) .loginprocessingurl(login_url); http.httpbasic() .disable(); //@formatter:on } }
Comments
Post a Comment