devise_oauth2_rails4 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/devise/oauth2/authorization.rb +58 -0
- data/lib/devise/oauth2/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad0e15ec79488248298982fcf833bd85b03358d5
|
4
|
+
data.tar.gz: b26a39c3065e052a1fe782d33237347d1ca6e320
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62ccff4b3461bf7592b9915a7a81e9d12b14f8520514b2053bfbf943afaface7225d4f86e1d526133d396ae5e26e693a52e3e9a669aeaea65490b380e038accb
|
7
|
+
data.tar.gz: 84dd9b90a0d08724d437e136f5eda3cc4ec4a07c34610ba4cc63968bba91c3426fa7dda2bebabbbedb110c215970ee5c02da99663f75528765829976c754e395
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Devise
|
2
|
+
module Oauth2
|
3
|
+
module Authorization
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def current_oauth2_client(opts: { secure: false })
|
7
|
+
return @secure_client ||= Client.find_by(secret: client_secret) if opts[:secure]
|
8
|
+
return @secure_client ||= Client.find_by(id: current_access_token.client_id) if access_token?
|
9
|
+
@client ||= Client.find_by('identifier = :client_id OR secret = :secret', client_id: client_id, secret: client_secret) if client_credentials?
|
10
|
+
end
|
11
|
+
|
12
|
+
def current_access_token
|
13
|
+
@access_token ||= AccessToken.find_by(token: access_token)
|
14
|
+
end
|
15
|
+
|
16
|
+
def oauth2_client_signed_in?
|
17
|
+
!!@client
|
18
|
+
end
|
19
|
+
|
20
|
+
def access_token_signed_in?
|
21
|
+
!!@access_token
|
22
|
+
end
|
23
|
+
|
24
|
+
def client_credentials
|
25
|
+
client_id? || client_secret?
|
26
|
+
end
|
27
|
+
|
28
|
+
def client_credentials?
|
29
|
+
!!client_credentials
|
30
|
+
end
|
31
|
+
|
32
|
+
def client_secret
|
33
|
+
params[:client_secret]
|
34
|
+
end
|
35
|
+
|
36
|
+
def client_secret?
|
37
|
+
!!client_secret
|
38
|
+
end
|
39
|
+
|
40
|
+
def client_id
|
41
|
+
params[:client_id]
|
42
|
+
end
|
43
|
+
|
44
|
+
def client_id?
|
45
|
+
!!params[:client_id]
|
46
|
+
end
|
47
|
+
|
48
|
+
def access_token
|
49
|
+
params[:access_token]
|
50
|
+
end
|
51
|
+
|
52
|
+
def access_token?
|
53
|
+
!!access_token
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_oauth2_rails4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Wheeler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- LICENSE.txt
|
167
167
|
- README.md
|
168
168
|
- Rakefile
|
169
|
+
- app/controllers/devise/oauth2/authorization.rb
|
169
170
|
- app/controllers/devise/oauth2/authorizations_controller.rb
|
170
171
|
- app/controllers/devise/oauth2/tokens_controller.rb
|
171
172
|
- app/helpers/permissions_helper.rb
|