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

fix: add id_token and support auth header #338

Merged
merged 1 commit into from
Nov 28, 2021

Conversation

ComradeProgrammer
Copy link
Contributor

This PR contains 2 fixes:

  1. add an 'id_token' field in access_token according to oidc protocol
  2. supporting read client_id and client_secret from Basic Authorization Header, and return 400 instead of 200 when we cannot give out access_token.
    See https://code.google.com/p/goauth2/issues/detail?id=31 for why we are doing this.

This is because that despite Oauth 2.0 (rfc 6749, section 4.1.3)has mentioned that client_id and client_secret should be put into post form when using 'authorization code grant' method, (which is exactly the way we use in casdoor), however there do exist a contradictory expression in the same doc (rfc 6749, section 2.3.1) which is "The authorization server MUST support the HTTP Basic authentication scheme for authenticating clients that were issued a client password", indicating that it's ok to pass client_id and client_secret in Basic Authorization Header. For example, google uses the former way but github, reddit uses the latter way.

Due to this confusion, it is SUGGESTED (not STIPULATED) that oauth client should try both methods, and distinguishes whether the current method successes by http response code.(for example, go oauth library try auth header first, and if non-2xx is returned, they try post form).This is the reason why we are adding 400 code into controller.

Also ,to avoid unnecessary failures, it's proper for us to support both methods, so we add support to read client_id and client_secret from Basic Authorization Header.

@casbin-bot
Copy link
Contributor

@seriouszyx @tangyang9464 please review

Signed-off-by: Товарищ <2962928213@qq.com>
@hsluoyz
Copy link
Member

hsluoyz commented Nov 28, 2021

@ComradeProgrammer can you add the texts to our official docs? https://github.com/casdoor/casdoor-website

@hsluoyz hsluoyz merged commit df5ee77 into casdoor:master Nov 28, 2021
@ComradeProgrammer ComradeProgrammer deleted the oidc_fix branch January 2, 2022 12:35
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.

3 participants