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
Allowing http token auth to set the token_authentication_key if missing from params #2271
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3025b7e
Allow http token authorization to set token_authentication_key in pla…
robhurring 22a8cfe
fix hanging line on method call
robhurring 84f743c
adding http token auth options to env[devise.token_options]
robhurring 547439d
renaming devise option "allow_authorization_to_set_auth_token" to "al…
robhurring 2d14bd2
removing params hash merging of token and mimicking http basic auth flow
robhurring 10f58b6
update devise config template with new allow_token_authenticatable_vi…
robhurring File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,11 +38,24 @@ def remember_me? | |
|
||
# Try both scoped and non scoped keys. | ||
def params_auth_hash | ||
if params[scope].kind_of?(Hash) && params[scope].has_key?(authentication_keys.first) | ||
params[scope] | ||
else | ||
params | ||
auth_key = authentication_keys.first | ||
|
||
return_params = \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need the |
||
if params[scope].kind_of?(Hash) && params[scope].has_key?(auth_key) | ||
params[scope] | ||
else | ||
params | ||
end | ||
|
||
if mapping.to.allow_authorization_to_set_auth_token | ||
token = ActionController::HttpAuthentication::Token.token_and_options(request) | ||
|
||
if token | ||
return_params.merge! auth_key => token.first | ||
end | ||
end | ||
|
||
return_params | ||
end | ||
|
||
# Overwrite authentication keys to use token_authentication_key. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Can we call this configuration option something like
allow_token_authenticatable_via_headers
or something like it?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 like that much better -- fixed!