-
Notifications
You must be signed in to change notification settings - Fork 187
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
feat: Allow calling of the UserInfo endpoint to be configurable #172
base: master
Are you sure you want to change the base?
Conversation
Allows the calling of the userinfo endpoint to be configurable, resolving omniauth#145
@stanhu @bufferoverflow - Would it be possible to get some feedback on this? |
if access_token.id_token | ||
decoded = decode_id_token(access_token.id_token).raw_attributes | ||
merge_with = JSON::JWS.new({}) | ||
merge_with = access_token.userinfo!.raw_attributes if options.call_userinfo_endpoint | ||
|
||
@user_info = ::OpenIDConnect::ResponseObject::UserInfo.new access_token.userinfo!.raw_attributes.merge(decoded) | ||
else | ||
@user_info = ::OpenIDConnect::ResponseObject::UserInfo.new merge_with.merge(decoded) | ||
elsif options.call_userinfo_endpoint | ||
@user_info = access_token.userinfo! | ||
else | ||
@user_info = ::OpenIDConnect::ResponseObject::UserInfo.new | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to keep the default case as is and put this extra handling into elsif !options.call_userinfo_endpoint
and a test case would be great.
@@ -258,10 +259,14 @@ def user_info | |||
|
|||
if access_token.id_token | |||
decoded = decode_id_token(access_token.id_token).raw_attributes | |||
merge_with = JSON::JWS.new({}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, ::OpenIDConnect::ResponseObject::UserInfo.new
works on a regular Hash; what's the deal with using JSON::JWS
?
Allows the calling of the UserInfo endpoint to be configurable.
As mentioned in #148, ADFS does not support the
email
orprofile
claims, and calling the UserInfo endpoint is pointless, as it only returns the subject.As the UserInfo endpoint is not required, this PR adds a new config item -
call_userinfo_endpoint
(defaulttrue
), which allows the skipping of this endpoint.Resolves #145