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

Set WWW-Authenticate header for invalid requests #96

Merged
merged 2 commits into from
Jan 7, 2022

Conversation

FStefanni
Copy link
Contributor

Summary

This adds the WWW-Authenticate header for InvalidRequestError, InvalidTokenError,
and InsufficientScopeError, as specified in RFC 6750, Section 3
The original pr is oauthjs/node-oauth2-server#646

Linked issue(s)

Fixes issue #89, point 18.

Added tests?

Yes

OAuth2 standard

RFC 6750, Section 3

@FStefanni FStefanni mentioned this pull request Dec 5, 2021
33 tasks
@jorenvandeweyer
Copy link
Member

Looks fine for me. I can not find that the header "MUST be" included like the original pull request claimed. Personally I do not see any harm in including this context.

@jankapunkt
Copy link
Member

Please set target to development, not master

@jankapunkt
Copy link
Member

please set target to development, not master

@FStefanni FStefanni changed the base branch from master to development December 8, 2021 09:40
@FStefanni
Copy link
Contributor Author

Hi,

done

Regards

@jankapunkt
Copy link
Member

Two things to mention here regarding RFC6750/section3:

If the request lacks any authentication information (e.g., the client was unaware that authentication is necessary or attempted using an unsupported authentication method), the resource server SHOULD NOT include an error code or other error information.

This should be taken into consideration.

And in response to a protected resource request with an authentication attempt using an expired access token:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="example",
                  error="invalid_token",
                  error_description="The access token expired"

The example also shows, that the error_description is included. I think we should add the description as well but only considering the above mentioned issue that the client is aware of the authentication)

@jankapunkt jankapunkt added the compliance 📜 OAuth 2.0 standard compliance label Dec 10, 2021
@FStefanni
Copy link
Contributor Author

Hi,

so, if I understand correctly what you mean and what the standard says:

  1. The proposed pr is fine, since it does not regards the UnauthorizedRequestError case
  2. You suggest to add a error_description instead of only the error (even if the error_description is optional according with the standard)

I think that adding the description could be useful, but not so straightforward, since it should report the specific failure reason IMHO. So I propose:

  • If this pr is fine, just accept it
  • About the optional description, let's open an issue as a reminder for a possible improvement, and in case let's propose a specific pr

Regards

@jankapunkt
Copy link
Member

@FStefanni the optional description can remain optional that's fine to me but I wanted to ask you as the author of the PR if you are sure, that you don't send error information in case the request contains no authentication method or info. From what I see there is no check about this but maybe this happens already at some other place?

@FStefanni
Copy link
Contributor Author

Hi,

to me, it seems fine: please see getTokenFromRequest() at line 117.
There, there are the checks about authorization info, and if it arrives to the end, it means that no info was provided.
Also corner cases seems fine to me: the checking methods are called only if the corresponding info is found.

But a second check by someone else is welcome.

Regards.

Copy link
Member

@jankapunkt jankapunkt left a comment

Choose a reason for hiding this comment

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

From my end this seems to be okay but I'd like to have a second check on the auth-checking issue (see prior discussion)

@jankapunkt
Copy link
Member

From my point this is resolved and approved. Can someone else second-check, please?

@jankapunkt
Copy link
Member

@jorenvandeweyer sorry for being late this is now finally merged

@jankapunkt jankapunkt merged commit d1ba63c into node-oauth:development Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compliance 📜 OAuth 2.0 standard compliance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants