Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/auth : NbOAuth2AuthStrategy implementing basic authentication scheme against token endpoints #582

Merged
merged 8 commits into from
Jul 30, 2018
Merged

feature/auth : NbOAuth2AuthStrategy implementing basic authentication scheme against token endpoints #582

merged 8 commits into from
Jul 30, 2018

Conversation

alain-charles
Copy link
Contributor

@alain-charles alain-charles commented Jul 26, 2018

What it resolves

NbOAuth2Strategy now implements client authentication as specified in RFC 6749 section 2-3

There is a new optional parameter of NbOAuth2StrategyOption.
The parameter is clientAuthMethod, and is a member of NbOAuth2ClientAuthMethod enum:

  • NONE (default) : no credentials are sent => No breaking change,
  • BASIC : credentials are sent in the authorization header
  • REQUEST_BODY: credentials are sent in the request body

AuthMethod is used (credentials are sent) when accessing to the authServer for :

  • Getting token with authorization_code grant_type
  • Getting token with password grant-type
  • Getting token with refresh_token grant-type

RFC6749 says the client must not authenticate when hitting authorize endpoints, even if asking for a token. So nothing changed here, only clientId is sent in the url.

issue resolved

issue #581

NbOAuth2AuthStrategy now implements basic authentication scheme against token endpoints
if both clientId and clientSecret are set.
(See https://tools.ietf.org/html/rfc6749#section-2.3)

TODO : Alternatively, clientId and clientSecret can be params of the request (RFC 6749)
=> add a parameter to the strategy indicating if it shall user header or reqsuest params to send credentials
@@ -282,6 +282,20 @@ export class NbOAuth2AuthStrategy extends NbAuthStrategy {
return this.cleanParams(params);
}

protected buildRequestsHttpOptions(): any {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make it optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense since clientId and clientSecret are optional

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my comment was a bit misleading. What I meant is that probably we should add an option to the configuration as you proposed in the PR description indicating if we want to enable the base auth, pass clientid/cliensecret as body parameters or none of the above?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alain-charles just checking if you saw my comment :)

@@ -4,7 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { Inject, Injectable } from '@angular/core';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import {HttpClient, HttpErrorResponse, HttpHeaders} from '@angular/common/http';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces

@alain-charles
Copy link
Contributor Author

alain-charles commented Jul 27, 2018 via email

- NONE (default)
- BASIC : credentials are sent in the authorization header
- REQUEST_BODY: credentials are sent in the request body

AuthMethod is used (credentials are sent) when accessing to the authServer for :
- Getting token with code grant_type
- Getting token with password grant-type
- Getting token with refresh_token grant-type

RFC6749 says the client must not authenticate when hitting authorize endpoint, even if asking for a token.

NO BREAKING CHANGES because of defaults to NONE.
import { NbOAuth2AuthStrategy } from './oauth2-strategy';
import { NbOAuth2GrantType, NbOAuth2ResponseType } from './oauth2-strategy.options';
import {NbOAuth2ClientAuthMethod, NbOAuth2GrantType, NbOAuth2ResponseType} from './oauth2-strategy.options';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces :)

@nnixaa nnixaa merged commit 4360a18 into akveo:master Jul 30, 2018
@alain-charles alain-charles deleted the feat/auth_oAuth2_basic branch July 31, 2018 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants