-
Notifications
You must be signed in to change notification settings - Fork 188
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
Allows ui_locales, claims_locales and login_hint as request params #6
Conversation
@@ -18,6 +18,16 @@ def test_request_phase | |||
strategy.request_phase | |||
end | |||
|
|||
def test_request_phase_with_params | |||
expected_redirect = /^https:\/\/example\.com\/authorize\?claims_locales=es&client_id=1234&login_hint=john.doe%40example.com&nonce=\w{32}&response_type=code&scope=openid&state=\w{32}&ui_locales=en$/ |
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.
Line is too long. [205/80]
expected_redirect = /^https:\/\/example\.com\/authorize\?claims_locales=es&client_id=1234&login_hint=john.doe%40example.com&nonce=\w{32}&response_type=code&scope=openid&state=\w{32}&ui_locales=en$/ | ||
strategy.options.issuer = 'example.com' | ||
strategy.options.client_options.host = 'example.com' | ||
request.stubs(:params).returns('login_hint' => 'john.doe@example.com', 'ui_locales' => 'en', 'claims_locales' => 'es') |
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.
Line is too long. [126/80]
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.
@@ -235,6 +236,10 @@ def redirect_uri | |||
"#{ client_options.redirect_uri }?redirect_uri=#{ CGI.escape(request.params['redirect_uri']) }" | |||
end | |||
|
|||
def params | |||
request.params |
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.
Consider using delegation instead of separate method definition
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 chose to use Forwardable module, and I also replace all request.params
calls.
Tell me If you prefer another solution.
Ref: [http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest](http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest) These params are allowed to be used during Authentication request.
d0608fe
to
0e42206
Compare
@@ -18,6 +18,16 @@ def test_request_phase | |||
strategy.request_phase | |||
end | |||
|
|||
def test_request_phase_with_params | |||
expected_redirect = /^https:\/\/example\.com\/authorize\?claims_locales=es&client_id=1234&login_hint=john.doe%40example.com&nonce=\w{32}&response_type=code&scope=openid&state=\w{32}&ui_locales=en$/ |
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.
Use %r
around regular expression.
@@ -18,6 +18,16 @@ def test_request_phase | |||
strategy.request_phase | |||
end | |||
|
|||
def test_request_phase_with_params | |||
expected_redirect = /^https:\/\/example\.com\/authorize\?claims_locales=es&client_id=1234&login_hint=john.doe%40example.com&nonce=\w{32}&response_type=code&scope=openid&state=\w{32}&ui_locales=en$/ |
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.
Line is too long. [205/80]
expected_redirect = /^https:\/\/example\.com\/authorize\?claims_locales=es&client_id=1234&login_hint=john.doe%40example.com&nonce=\w{32}&response_type=code&scope=openid&state=\w{32}&ui_locales=en$/ | ||
strategy.options.issuer = 'example.com' | ||
strategy.options.client_options.host = 'example.com' | ||
request.stubs(:params).returns('login_hint' => 'john.doe@example.com', 'ui_locales' => 'en', 'claims_locales' => 'es') |
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.
Line is too long. [126/80]
if error | ||
raise CallbackError.new(request.params['error'], request.params['error_description'] || request.params['error_reason'], request.params['error_uri']) | ||
elsif request.params['state'].to_s.empty? || request.params['state'] != stored_state | ||
raise CallbackError.new(params['error'], params['error_description'] || params['error_reason'], params['error_uri']) |
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.
Line is too long. [126/80]
elsif !request.params['code'] | ||
return fail!(:missing_code, OmniAuth::OpenIDConnect::MissingCodeError.new(request.params['error'])) | ||
elsif !params['code'] | ||
return fail!(:missing_code, OmniAuth::OpenIDConnect::MissingCodeError.new(params['error'])) |
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.
Line is too long. [101/80]
@@ -231,10 +236,11 @@ def decode(str) | |||
end | |||
|
|||
def redirect_uri | |||
return client_options.redirect_uri unless request.params['redirect_uri'] | |||
"#{ client_options.redirect_uri }?redirect_uri=#{ CGI.escape(request.params['redirect_uri']) }" | |||
return client_options.redirect_uri unless params['redirect_uri'] |
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.
Add empty line after guard clause.
return client_options.redirect_uri unless request.params['redirect_uri'] | ||
"#{ client_options.redirect_uri }?redirect_uri=#{ CGI.escape(request.params['redirect_uri']) }" | ||
return client_options.redirect_uri unless params['redirect_uri'] | ||
"#{ client_options.redirect_uri }?redirect_uri=#{ CGI.escape(params['redirect_uri']) }" |
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.
Space inside string interpolation detected.
return client_options.redirect_uri unless request.params['redirect_uri'] | ||
"#{ client_options.redirect_uri }?redirect_uri=#{ CGI.escape(request.params['redirect_uri']) }" | ||
return client_options.redirect_uri unless params['redirect_uri'] | ||
"#{ client_options.redirect_uri }?redirect_uri=#{ CGI.escape(params['redirect_uri']) }" |
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.
Line is too long. [95/80]
0e42206
to
f3e706a
Compare
Thanks for your feedback @m0n9oose. |
totally up to you. What about test? Is everything okay? |
It seems ok for me. |
Hello,
These params are allowed to be used during Authentication request.
Ref: http://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
I removed the
login_hint
option, the param has to be dynamic. I don't understand why it should be declared as an option.Please let me know if I misunderstood something.