forked from lynndylanhurley/devise_token_auth
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract the
provider
from the uid
param.
Previously, the `provider` was concatenated to the `uid` and passed around between requests via a single `uid` parameter. This combined `uid` was split back apart when querying for the resource_class via its authentications. Instead of concatenating and then splitting, use an additional `provider` param in conjunction with the existing `uid` param.
- Loading branch information
Showing
7 changed files
with
31 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,11 +43,13 @@ def set_user_by_token(mapping=nil) | |
|
||
# gets the headers names, which was set in the initialize file | ||
uid_name = DeviseTokenAuth.headers_names[:'uid'] | ||
provider_name = DeviseTokenAuth.headers_names[:'provider'] | ||
access_token_name = DeviseTokenAuth.headers_names[:'access-token'] | ||
client_name = DeviseTokenAuth.headers_names[:'client'] | ||
|
||
# parse header for values necessary for authentication | ||
uid = request.headers[uid_name] || params[uid_name] | ||
provider = request.headers[provider_name] || params[provider_name] | ||
@token ||= request.headers[access_token_name] || params[access_token_name] | ||
@client_id ||= request.headers[client_name] || params[client_name] | ||
|
||
|
@@ -80,8 +82,7 @@ def set_user_by_token(mapping=nil) | |
# NOTE: By searching for the user by an identifier instead of by token, we | ||
# mitigate timing attacks | ||
# | ||
@provider_id, @provider = uid.split # e.g. ["12345", "facebook"] or ["[email protected]", "email"] | ||
resource = rc.find_resource(@provider_id, @provider) | ||
resource = rc.find_resource(uid, provider) | ||
|
||
if resource && resource.valid_token?(@token, @client_id) | ||
# sign_in with bypass: true will be deprecated in the next version of Devise | ||
|
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
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