phoenixnap / springmvc-raml-plugin

Spring MVC - RAML Spec Synchroniser Plugin. A Maven plugin designed to Generate Server & Client code in Spring from a RAML API descriptor and conversely, a RAML API document from the SpringMVC Server implementation.
Apache License 2.0
136 stars 84 forks source link

Generating client for more than one authorization grant #241

Closed stojsavljevic closed 6 years ago

stojsavljevic commented 6 years ago

In case of multiple authorization grants, generated client should use different restTemplate for every different grant. Example raml:

#%RAML 1.0
title: OAuth2
...
/root:    
  /clients:
    securedBy: 
      oauth_2_0: 
        authorizationGrants: client_credentials
    get:
      responses: 
        200:
          body: 
            application/json:
              type: Client
    /resources:
      get:
        securedBy: 
          oauth_2_0:
            authorizationGrants: authorization_code
        responses: 
          200:
            body: 
              application/json:
                type: Resource

Generated client should use different restTemplate (actually OAuth2RestTemplate) for these 2 endpoints - the one with ClientCredentialsResourceDetails and the one with AuthorizationCodeResourceDetails. Actual configuration is not the part of generated code but client should make usage of different restTemplate.

stojsavljevic commented 6 years ago

The logic for generating restTemplates is following:

When two or more grants are specified for a single action (e.g. [ implicit, client_credentials, authorization_code ]) - the first one will be picked up (in this example it will be implicit).