fix: add id_token and support auth header #338
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains 2 fixes:
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.