omniauth-colorgy-oauth2 0.1.2 → 0.1.3
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/README.md +27 -1
- data/app/controllers/concerns/colorgy_devise_sso_manager.rb +20 -2
- data/lib/omniauth/colorgy_oauth2/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 550b9ca1c5c9966734626c78efa3a7f29be9ec1f
|
4
|
+
data.tar.gz: 8834455bc5bc5a553dc940c2888f3c41e33a841a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01c5bfd083fed47f74d73d94c442f8d9287d62d106042b77ebf64aae5bb675c5d66b688de7210aba0b63206068936c24304a23cc0089e612240fa9f5618f715c
|
7
|
+
data.tar.gz: a0e0357e89ea1b3bef5d348c987029156f60375696ff1e7636439910b8374c523ac98a9d833eeae1dec0599426ed3063c4db68258a2b8961e3bf8b38ff55c212
|
data/README.md
CHANGED
@@ -125,7 +125,7 @@ config.omniauth :colorgy, ENV['APP_ID'], ENV['APP_SECRET'],
|
|
125
125
|
|
126
126
|
## Single-Sign On/Off (SSO) Support
|
127
127
|
|
128
|
-
_(Optional)_
|
128
|
+
_(Optional, only if you want a single sing in/out status synced with Colorgy core.)_
|
129
129
|
|
130
130
|
The Colorgy SSO system is implemented using **OAuth 2.0** as the authorization protocol and **Sign-on Status Tokens (SST)** as credential of the sign-on status of the user, achieving sign in and out seamlessly controlled by a central server.
|
131
131
|
|
@@ -165,6 +165,19 @@ rails g migration add_refreshed_at_to_users refreshed_at:datetime
|
|
165
165
|
rake db:migrate
|
166
166
|
```
|
167
167
|
|
168
|
+
Make sure it is updated while each core sign in, usually in `app/models/user.rb`:
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
def self.from_colorgy(auth)
|
172
|
+
# ...
|
173
|
+
|
174
|
+
user.refreshed_at = Time.now
|
175
|
+
user.save!
|
176
|
+
|
177
|
+
# ...
|
178
|
+
end
|
179
|
+
```
|
180
|
+
|
168
181
|
Then just include `ColorgyDeviseSSOManager` in your ApplicationController and all the rest is done:
|
169
182
|
|
170
183
|
```ruby
|
@@ -190,6 +203,19 @@ Now that users on your app will be signing in/out synchronizedly with Colorgy co
|
|
190
203
|
<%= link_to("Log Out", sign_out_url, method: :delete) %>
|
191
204
|
```
|
192
205
|
|
206
|
+
If SSO functionality needs to be turned off temporary, call the `sso_off!` method at `before_filter` like this:
|
207
|
+
|
208
|
+
```ruby
|
209
|
+
class ApplicationController < ActionController::Base
|
210
|
+
# ...
|
211
|
+
|
212
|
+
before_filter :sso_off!
|
213
|
+
|
214
|
+
# ...
|
215
|
+
end
|
216
|
+
```
|
217
|
+
|
218
|
+
The SSO functionality will be disabled automatically in testing environment (`Rails.env.test?`) by the way.
|
193
219
|
|
194
220
|
## Development
|
195
221
|
|
@@ -4,21 +4,38 @@ module ColorgyDeviseSSOManager
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
@@sst_verification_method = 'RS256'
|
7
|
+
@@sso_enabled = true
|
7
8
|
|
8
9
|
included do
|
9
10
|
before_filter :verify_sst
|
11
|
+
before_action :sign_out_if_needed
|
10
12
|
helper_method :sign_out_url, :logout_url
|
11
13
|
end
|
12
14
|
|
13
|
-
#
|
15
|
+
# Helper to get the core sign-out URL
|
14
16
|
def sign_out_url
|
15
|
-
|
17
|
+
if @@sso_enabled
|
18
|
+
"#{core_url}/logout"
|
19
|
+
else
|
20
|
+
"#{root_path}?logout=true"
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
24
|
def logout_url
|
19
25
|
sign_out_url
|
20
26
|
end
|
21
27
|
|
28
|
+
# Sign the user out if needed
|
29
|
+
def sign_out_if_needed
|
30
|
+
return unless !@@sso_enabled && params[:logout] == 'true'
|
31
|
+
sign_out :user
|
32
|
+
end
|
33
|
+
|
34
|
+
# Turn off SSO
|
35
|
+
def sso_off!
|
36
|
+
@@sso_enabled = false
|
37
|
+
end
|
38
|
+
|
22
39
|
private
|
23
40
|
|
24
41
|
# Getter of the core domain
|
@@ -66,6 +83,7 @@ module ColorgyDeviseSSOManager
|
|
66
83
|
def verify_sst
|
67
84
|
# Skip this on test and auth callbacks
|
68
85
|
return if Rails.env.test?
|
86
|
+
return unless @@sso_enabled
|
69
87
|
return if controller_name == 'omniauth_callbacks'
|
70
88
|
|
71
89
|
# Get the sst string from cookie
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-colorgy-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|