Project

General

Profile

Actions

task #6118

closed

evaluate spring-security-auth2 and spring-cloud-security as a framework for OAuth2

Added by Andreas Kohlbecker over 7 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
New
Category:
cdmlib
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Severity:
normal

Description

spring-security-oauth & Spring-Cloud-Security & bring OAuth2 for spring applications.

OAuth2

OAuth2 security threads and consideration

Specification details

The OAuth2 specification (rfc6749) defines four (six) grant types:

rfc6749 section grant_type implemented and tested in cdmlib
4.1. Authorization Code Grant grant_type=authorization_code OK
4.2. Implicit Grant grant_type=implicit OK
4.3. Resource Owner Password Credentials Grant grant_type=password undesirable
4.4. Client Credentials Grant grant_type=client_credentials see #6248
4.5. Extension Grants - (extensibility mechanism for defining additional types) not needed
6. Refreshing an Access Token grant_type=refresh_token TODO

When using implicit or password it is strongly required that the communication secured by TSL/SSL. TSL/SSL can be enforced in spring-security-oauth. --> #6232

Test Requests for testing various grant types during development are found in OAuth2-test.sh

Example implementations

The reference implementation is found at github: spring-projects/spring-security-oauth whereas the samples/oauth2/sparklr project is most relevant for us. This is an example for the password grant type: http://blog.e-zest.net/rest-authentication-using-oauth-2-0-resource-owner-password-flow-protocol/

Usage scenarios

Dataportal as OAuth2 Client using grant_type=authorization_code

Dataportal as OAuth2 Client using grant_type=implicit

Notes

spring-security-oauth

The following endpoints are required in the Spring Security filter chain in order to implement OAuth 2.0 Authorization Server:

  • AuthorizationEndpoint is used to service requests for authorization. Default URL: /oauth/authorize. This enpoint should be protected using Spring Security so that it is only accessible to authenticated users. For instance using a standard Spring Security WebSecurityConfigurer:
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests().antMatchers("/login").permitAll().and()
        // default protection for all resources (including /oauth/authorize)
            .authorizeRequests()
                .anyRequest().hasRole("USER")
        // ... more configuration, e.g. for form login
    }

Note: if your Authorization Server is also a Resource Server then there is another security filter chain with lower priority controlling the API resources. Fo those requests to be protected by access tokens you need their paths not to be matched by the ones in the main user-facing filter chain, so be sure to include a request matcher that picks out only non-API resources in the WebSecurityConfigurer above. (see configuring-the-endpoint-urls)

  • TokenEndpoint is used to service requests for access tokens. Default URL: /oauth/token.

The following filter is required to implement an OAuth 2.0 Resource Server:

  • The OAuth2AuthenticationProcessingFilter is used to load the Authentication for the request given an authenticated access token.

Anonymous Authentication

Is useful in cases when you don't want to skip authentication for pages which should behave differently for authenticated and not authenticated users (see spring-security 4.1.3.RELEASE #anonymous

Is configured automatically when using the WebSecurityConfigurerAdapter. By default anonymous users will be represented with token containing the role "ROLE_ANONYMOUS".


Files

OAuth2-test.sh (2.29 KB) OAuth2-test.sh Andreas Kohlbecker, 10/11/2016 10:03 AM
OAuth2-sequence-diagram-DataPortal.png (44.7 KB) OAuth2-sequence-diagram-DataPortal.png Andreas Kohlbecker, 10/11/2016 02:50 PM

Related issues

Related to EDIT - bug #6248: allow machine clients to access /manage/* OAuth2 protected web servicesClosedAndreas Kohlbecker

Actions
Related to EDIT - feature request #6332: cdm-dataportal as oauth2 client of cdm-remote instancesNewAndreas Kohlbecker

Actions
Copied to EDIT - task #6125: Implement tests for OAuth2 in cdmlib-remoteNewAndreas Kohlbecker

Actions
Copied to EDIT - feature request #6232: secure OAuth2 grant types 'implicit' or 'password' by TSL/SSL.NewAndreas Kohlbecker

Actions
Actions #1

Updated by Andreas Kohlbecker over 7 years ago

  • Status changed from New to In Progress
Actions #2

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #3

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #4

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #5

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #6

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #7

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #8

Updated by Andreas Kohlbecker over 7 years ago

  • Subject changed from evaluate spring-cloud-security as a framework for OAuth2 to evaluate spring-security-auth2 and spring-cloud-security as a framework for OAuth2
  • Description updated (diff)
Actions #9

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #10

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #11

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #12

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #13

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #14

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #15

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #16

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #17

Updated by Andreas Kohlbecker over 7 years ago

  • File OAuth2-test.sh added

Adding shell script to test different authentication modes.

Actions #18

Updated by Andreas Kohlbecker over 7 years ago

updating development test script to latest implementation

Actions #19

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #20

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #21

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #22

Updated by Andreas Kohlbecker over 7 years ago

  • File OAuth2-sequence-diagram-DataPortal.png added
  • Description updated (diff)
Actions #23

Updated by Andreas Kohlbecker over 7 years ago

  • File deleted (OAuth2-test.sh)
Actions #25

Updated by Andreas Kohlbecker over 7 years ago

  • File deleted (OAuth2-sequence-diagram-DataPortal.png)
Actions #26

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #27

Updated by Andreas Müller over 7 years ago

  • Target version changed from Release 4.4 to Release 4.5
Actions #28

Updated by Andreas Kohlbecker over 7 years ago

  • Copied to task #6125: Implement tests for OAuth2 in cdmlib-remote added
Actions #29

Updated by Andreas Kohlbecker over 7 years ago

  • Status changed from In Progress to Closed
  • Target version changed from Release 4.5 to Release 4.4
  • % Done changed from 0 to 100
Actions #30

Updated by Andreas Kohlbecker over 7 years ago

Actions #31

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #32

Updated by Andreas Kohlbecker over 7 years ago

  • Related to bug #6248: allow machine clients to access /manage/* OAuth2 protected web services added
Actions #33

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #34

Updated by Andreas Kohlbecker over 7 years ago

  • Description updated (diff)
Actions #35

Updated by Andreas Kohlbecker over 7 years ago

Actions #36

Updated by Andreas Kohlbecker about 3 years ago

  • Tags changed from security to security, OAuth2
Actions

Also available in: Atom PDF