OAuth2 Protocol with Grails Spring Security

50 %
50 %
Information about OAuth2 Protocol with Grails Spring Security

Published on February 25, 2016

Author: NexThoughts

Source: slideshare.net

1. OAUTH 2.0

2. What is OAuth OAuth 2 is an authorization framework that enables applications to obtain limited access to user accounts on an HTTP service, such as Facebook, GitHub, and DigitalOcean. It works by delegating user authentication to the service that hosts the user account, and authorizing third-party applications to access the user account.

3. How to work

4. Lets start building an app with OAuth

5. Add plugin in buildConfig.groovy compile ":spring-security-oauth2- provider:2.0-RC5"

6. Domain Classes Run this script grails s2-init-oauth2-provider <package> <client> <authorization-code> <access- token> <refresh-token>

7. Config.groovy grails.plugin.springsecurity.controllerAnnotations.staticRules = [ [pattern: '/oauth/authorize', access: "isFullyAuthenticated() and (request.getMethod().equals('GET') or request.getMethod().equals('POST'))"], [pattern: '/oauth/token', access: "isFullyAuthenticated() and request.getMethod().equals('POST')"], ]

8. grails.plugin.springsecurity.filterChain.chainM ap = [ [pattern: '/oauth/token', filters: 'JOINED_FILTERS,-oauth2ProviderFilter,- securityContextPersistenceFilter,- logoutFilter,- authenticationProcessingFilter,- rememberMeAuthenticationFilter,- exceptionTranslationFilter'], [pattern: '/securedOAuth2Resources/**',

9. Add User Role roleUser = new Role(authority: 'ROLE_USER').save(flush: true) User user = new User( username: 'user1', password: 'user1', enabled: true, accountExpired: false,

10. Add Client new RestClient( clientId: 'AskMeBazaar', authorizedGrantTypes: ['authorization_code', 'refresh_token', 'implicit', 'password', 'client_credentials'], authorities: ['ROLE_CLIENT'], scopes: ['read', 'write'], redirectUris: ['path of your application where u want to render the auth

11. Authorization Code Grant http://localhost:8080/oauth2- test/oauth/authorize? response_type=code&client_id=my- client&scope=read

12. Redirect http://myredirect.com/?code=139R59

13. Using HTTP Basic for client authentication curl -X POST -d "client_id=my-client" -d "grant_type=authorization_code" -d "code=139R59" http://localhost:8080/oauth2- test/oauth/token

14. receive the access token in the response access_token": "a1ce2915-8d79-4961-8abb-2c6f0fdb4aba", "token_type": "bearer", "refresh_token": "6540222d-0fb9-4b01-8d45-7be2bdfb68f9", "expires_in": 43199, "scope": "read"

15. References  https://developers.google.com/identity/protocol  https://www.digitalocean.com/community/tutoria  https://grails.org/plugins/tag/oauth2

Add a comment

Related pages

OAuth2 Provider support for the Spring Security plugin.

compile ':spring-security-oauth2-provider: ... For grails 2.3+, use version 2.0+ of the plugin (current latest is 2.0-RC4). For grails 2.0-2.2, ...
Read more

Grails Plugins

Plugins You can find out about all the publicly available Grails plugins. ... oauth2, spring security ... OAuth2 Provider support for the Spring Security ...
Read more

Spring Security OAuth - Projects

Spring Security OAuth provides support for using Spring ... and OAuth2 using standard Spring and Spring Security programming models and ...
Read more

Spring Security OAuth 2 with Grails 3.0 and Spring ...

I try to use Spring Security OAuth 2 in my project My project is a Grails 3.0.9 application with Spring Security Core Plugin I just want authorize a client ...
Read more

Grails and Oauth2 Spring security - Stack Overflow

I'm tring to configure ad OAUTH2 provider with grails based on plugin grails-spring-security-oauth2 ... on plugin grails-spring-security-oauth2-provider ...
Read more

How To: OAuth 2.0 with Spring Security - Aurora Solutions ...

There are different protocols and libraries ... artifactId>spring-security-oauth2 Read more

APIs with Grails 3 and OAuth 2 - Agile Orbit

... we will dive into APIs with Grails 3 and ... you install the Spring Security ... other Spring Security libraries directly in our Grails 3 ...
Read more

OAuth for Spring Security - Home

OAuth for Spring Security. Home; Tutorial; User Guide; Support; Downloads; JavaDocs; Source; Other Links. OAuth 1.0; OAuth 2.0; Spring Security; Spring ...
Read more

GitHub - bluesliverx/grails-spring-security-oauth2 ...

grails-spring-security-oauth2-provider - Grails Spring Security OAuth2 Provider Plugin
Read more