Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip OAuth user approval in Spring Boot OAuth2

I just want to know if there is any way to skip User approval screen in Spring Boot - Spring Security OAuth2. I heard about custom user approval handler but I am quite not sure how to override it to disable user approval process and do a direct redirect.

Thanks

like image 772
Vijay Muvva Avatar asked Apr 17 '15 09:04

Vijay Muvva


2 Answers

You don't need a custom handler to skip approval (since 2.0 anyway). You just set the autoApprove flag in the client details to "true" (or a list of scope patterns to auto approve).

like image 55
Dave Syer Avatar answered Nov 06 '22 02:11

Dave Syer


This is how I changed it in my JHipster application:

        @Override
        public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
            clients
                .inMemory()
                .withClient(jhipsterProperties.getSecurity().getAuthentication().getOauth().getClientid())
                .autoApprove(true)
                .scopes("read", "write")
                .authorities(AuthoritiesConstants.ADMIN, AuthoritiesConstants.USER)
                .authorizedGrantTypes("password", "refresh_token")
                .secret(jhipsterProperties.getSecurity().getAuthentication().getOauth().getSecret())
                .accessTokenValiditySeconds(jhipsterProperties.getSecurity().getAuthentication().getOauth().getTokenValidityInSeconds());
        }
like image 21
Pedro Madrid Avatar answered Nov 06 '22 04:11

Pedro Madrid