warden-token 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/warden/strategies/token.rb +11 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 448c7f84e932e3474a30c8299658326fce8137e1
|
4
|
+
data.tar.gz: 872b5a219db7ebea577f3d6dfe8413ed4d7ad5a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 349d4c232fe0f67e0605622f022dbcebeabce5ef6dcc26bacb9422867bc7cc07aa901f1692ab74088323a4dc4cc77206be9166cff191d64060d63ebe1f123f4a
|
7
|
+
data.tar.gz: f0029f5a18efb17340b64cfc7d0338612f43e8451d209a9e17f3d4bef9899cae21ec4591bcd6ceaea9522dccad72c3fb76e27d08a2c3ecdd297fa70629528a14
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "warden"
|
2
2
|
|
3
3
|
class Warden::Strategies::Token < ::Warden::Strategies::Base
|
4
|
-
VERSION = "0.
|
4
|
+
VERSION = "0.2.0"
|
5
5
|
|
6
6
|
attr_reader :id, :token
|
7
7
|
|
@@ -11,7 +11,9 @@ class Warden::Strategies::Token < ::Warden::Strategies::Base
|
|
11
11
|
if request.authorization && request.authorization =~ /^Basic (.*)$/m
|
12
12
|
@id, @token = Base64.decode64($1).split(/:/, 2)
|
13
13
|
else
|
14
|
-
|
14
|
+
uid = config[:user_id_param] || :user_id
|
15
|
+
token = config[:user_token_param] || :token
|
16
|
+
@id, @token = params[uid], params[token]
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -21,13 +23,19 @@ class Warden::Strategies::Token < ::Warden::Strategies::Base
|
|
21
23
|
|
22
24
|
def authenticate!
|
23
25
|
user = User.where(id: id).first
|
24
|
-
|
26
|
+
token = user.send(config[:token_name])
|
27
|
+
if user && secure_compare(token)
|
25
28
|
success!(user)
|
26
29
|
else
|
27
30
|
fail!("Invalid user id or token")
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
34
|
+
# Returns the configuration data for the default user scope.
|
35
|
+
def config
|
36
|
+
env["warden"].config[:scope_defaults][:user][:config]
|
37
|
+
end
|
38
|
+
|
31
39
|
private
|
32
40
|
|
33
41
|
# Taken from [Devise](https://github.com/plataformatec/devise).
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden-token
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Margison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: warden
|
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
55
|
version: '0'
|
56
56
|
requirements: []
|
57
57
|
rubyforge_project:
|
58
|
-
rubygems_version: 2.
|
58
|
+
rubygems_version: 2.3.0
|
59
59
|
signing_key:
|
60
60
|
specification_version: 4
|
61
61
|
summary: Simple token authentication strategy for Warden.
|