sso_client 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/sso_client/omniauth_callbacks_controller.rb +8 -0
- data/app/controllers/sso_client/sessions_controller.rb +19 -0
- data/app/models/user.rb +32 -0
- data/config/initializers/devise.rb +75 -0
- data/config/routes.rb +10 -12
- data/db/migrate/20111212032401_recreate_users.rb +24 -0
- data/lib/sso_client/engine.rb +4 -5
- data/lib/sso_client/version.rb +1 -1
- metadata +44 -47
- data/app/assets/stylesheets/sso_client/application.css +0 -7
- data/app/controllers/sso_client/application_controller.rb +0 -25
- data/app/controllers/sso_client/home_controller.rb +0 -8
- data/app/controllers/sso_client/user_sessions_controller.rb +0 -30
- data/app/helpers/sso_client/application_helper.rb +0 -4
- data/app/models/sso_client/user.rb +0 -39
- data/app/views/layouts/sso_client/application.html.erb +0 -14
- data/app/views/sso_client/home/show.html.erb +0 -10
@@ -0,0 +1,8 @@
|
|
1
|
+
class SsoClient::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
+
def identity
|
3
|
+
user = User.from_omniauth(request.env['omniauth.auth'])
|
4
|
+
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Identity"
|
5
|
+
sign_in user, :event => :authentication
|
6
|
+
redirect_to stored_location_for(:user) || main_app.root_path
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class SsoClient::SessionsController < Devise::SessionsController
|
2
|
+
def new
|
3
|
+
redirect_to '/sso/auth/identity'
|
4
|
+
end
|
5
|
+
def destroy
|
6
|
+
sign_out :user
|
7
|
+
redirect_to "#{Settings['sso_provider.host']}/users/sign_out?redirect_uri=#{CGI.escape(redirect_uri)}"
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def redirect_uri
|
13
|
+
URI.parse(request.url).tap do | uri |
|
14
|
+
uri.path = main_app.root_path
|
15
|
+
uri.query = nil
|
16
|
+
end.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/app/models/user.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
devise :omniauthable, :trackable, :timeoutable
|
3
|
+
|
4
|
+
def self.from_omniauth(hash)
|
5
|
+
User.find_or_initialize_by_uid(hash['uid']).tap do |user|
|
6
|
+
user.update_attributes hash['info']
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
# == Schema Information
|
14
|
+
#
|
15
|
+
# Table name: users
|
16
|
+
#
|
17
|
+
# id :integer not null, primary key
|
18
|
+
# email :string(255) default(""), not null
|
19
|
+
# encrypted_password :string(128) default(""), not null
|
20
|
+
# reset_password_token :string(255)
|
21
|
+
# reset_password_sent_at :datetime
|
22
|
+
# remember_created_at :datetime
|
23
|
+
# sign_in_count :integer default(0)
|
24
|
+
# current_sign_in_at :datetime
|
25
|
+
# last_sign_in_at :datetime
|
26
|
+
# current_sign_in_ip :string(255)
|
27
|
+
# last_sign_in_ip :string(255)
|
28
|
+
# created_at :datetime
|
29
|
+
# updated_at :datetime
|
30
|
+
# name :string(255)
|
31
|
+
#
|
32
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
|
+
# Many of these configuration options can be set straight in your model.
|
3
|
+
Devise.setup do |config|
|
4
|
+
# ==> ORM configuration
|
5
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
6
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
7
|
+
# available as additional gems.
|
8
|
+
require 'devise/orm/active_record'
|
9
|
+
|
10
|
+
# ==> Configuration for :timeoutable
|
11
|
+
# The time you want to timeout the user session without activity. After this
|
12
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
13
|
+
# config.timeout_in = 30.minutes
|
14
|
+
|
15
|
+
# ==> Configuration for :lockable
|
16
|
+
# Defines which strategy will be used to lock an account.
|
17
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
18
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
19
|
+
# config.lock_strategy = :failed_attempts
|
20
|
+
|
21
|
+
# Defines which key will be used when locking and unlocking an account
|
22
|
+
# config.unlock_keys = [ :email ]
|
23
|
+
|
24
|
+
# Defines which strategy will be used to unlock an account.
|
25
|
+
# :email = Sends an unlock link to the user email
|
26
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
27
|
+
# :both = Enables both strategies
|
28
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
29
|
+
# config.unlock_strategy = :both
|
30
|
+
|
31
|
+
# Number of authentication tries before locking an account if lock_strategy
|
32
|
+
# is failed attempts.
|
33
|
+
# config.maximum_attempts = 20
|
34
|
+
|
35
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
36
|
+
# config.unlock_in = 1.hour
|
37
|
+
|
38
|
+
# ==> Configuration for :token_authenticatable
|
39
|
+
# Defines name of the authentication token params key
|
40
|
+
# config.token_authentication_key = :auth_token
|
41
|
+
|
42
|
+
# If true, authentication through token does not store user in session and needs
|
43
|
+
# to be supplied on each request. Useful if you are using the token as API token.
|
44
|
+
# config.stateless_token = false
|
45
|
+
|
46
|
+
# ==> Scopes configuration
|
47
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
48
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
49
|
+
# are using only default views.
|
50
|
+
# config.scoped_views = false
|
51
|
+
|
52
|
+
# Configure the default scope given to Warden. By default it's the first
|
53
|
+
# devise role declared in your routes (usually :user).
|
54
|
+
# config.default_scope = :user
|
55
|
+
|
56
|
+
# Configure sign_out behavior.
|
57
|
+
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
|
58
|
+
# The default is true, which means any logout action will sign out all active scopes.
|
59
|
+
# config.sign_out_all_scopes = true
|
60
|
+
|
61
|
+
# ==> Navigation configuration
|
62
|
+
# Lists the formats that should be treated as navigational. Formats like
|
63
|
+
# :html, should redirect to the sign in page when the user does not have
|
64
|
+
# access, but formats like :xml or :json, should return 401.
|
65
|
+
#
|
66
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
67
|
+
# should add them to the navigational formats lists.
|
68
|
+
#
|
69
|
+
# The :"*/*" and "*/*" formats below is required to match Internet
|
70
|
+
# Explorer requests.
|
71
|
+
# config.navigational_formats = [:"*/*", "*/*", :html]
|
72
|
+
|
73
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
74
|
+
config.sign_out_via = :delete
|
75
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
SsoClient::Engine.routes.draw do
|
2
|
-
root :to => 'home#show'
|
3
|
-
|
4
|
-
# omniauth
|
5
|
-
get "/:provider/callback", :to => 'user_sessions#create'
|
6
|
-
get "/failure", :to => 'user_sessions#failure'
|
7
|
-
|
8
|
-
# logout
|
9
|
-
get "/logout", :to => 'user_sessions#destroy', :as => :logout
|
10
|
-
end
|
11
|
-
|
12
1
|
Rails.application.routes.draw do
|
13
|
-
|
2
|
+
devise_for :users,
|
3
|
+
:path => 'sso',
|
4
|
+
:skip => [:registrations, :passwords, :confirmations],
|
5
|
+
:controllers => {:omniauth_callbacks => "sso_client/omniauth_callbacks"} do
|
6
|
+
get '/sso/sign_in' => redirect('/sso/auth/identity'), :as => :new_user_session
|
7
|
+
get "/sso/sign_out", :to => "sso_client/sessions#destroy"
|
8
|
+
end
|
9
|
+
|
10
|
+
get '/sso/auth/identity', :as => :sign_on
|
11
|
+
get "/sso/sign_out", :as => :sign_out
|
14
12
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class RecreateUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
drop_table :users rescue nil
|
4
|
+
|
5
|
+
create_table :users do | t |
|
6
|
+
t.string :uid # omniauth[:uid]
|
7
|
+
t.text :name, # omniauth[:info]
|
8
|
+
:email,
|
9
|
+
:nickname,
|
10
|
+
:first_name,
|
11
|
+
:last_name,
|
12
|
+
:location,
|
13
|
+
:description,
|
14
|
+
:image,
|
15
|
+
:phone,
|
16
|
+
:urls
|
17
|
+
t.text :raw_info # omniauth[:extra]
|
18
|
+
t.trackable
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
|
22
|
+
add_index :users, :uid
|
23
|
+
end
|
24
|
+
end
|
data/lib/sso_client/engine.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'devise'
|
2
2
|
require File.expand_path("../../../lib/omniauth/strategies/identity", __FILE__)
|
3
3
|
|
4
4
|
module SsoClient
|
@@ -9,11 +9,10 @@ module SsoClient
|
|
9
9
|
raise 'Please specify sso_provider.host in settings.yml' unless defined?(Settings) && Settings[:sso_provider]
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
config.
|
12
|
+
initializer "sso_client.devise", :before => 'devise.omniauth' do |app|
|
13
|
+
Devise.setup do |config|
|
14
|
+
config.omniauth :identity, Settings['sso_provider.app_id'], Settings['sso_provider.app_secret'], :client_options => {:site => Settings['sso_provider.host']}
|
15
15
|
end
|
16
|
-
provider :identity, Settings['sso_provider.app_id'], Settings['sso_provider.app_secret'], :client_options => {:site => Settings['sso_provider.host']}
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
data/lib/sso_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sso_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &5090740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *5090740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: configliere
|
27
|
-
requirement: &
|
27
|
+
requirement: &5090100 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,32 +32,32 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *5090100
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: devise
|
38
|
+
requirement: &5088780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *5088780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name: omniauth
|
49
|
-
requirement: &
|
48
|
+
name: omniauth
|
49
|
+
requirement: &5085300 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.0.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *5085300
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement: &
|
59
|
+
name: omniauth-oauth2
|
60
|
+
requirement: &5122140 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *5122140
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fabrication
|
71
|
-
requirement: &
|
71
|
+
requirement: &5121140 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *5121140
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: guard-rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &5120280 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *5120280
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: guard-spork
|
93
|
-
requirement: &
|
93
|
+
requirement: &5119600 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *5119600
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: libnotify
|
104
|
-
requirement: &
|
104
|
+
requirement: &5118640 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *5118640
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rb-inotify
|
115
|
-
requirement: &
|
115
|
+
requirement: &5117420 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *5117420
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: rspec-rails
|
126
|
-
requirement: &
|
126
|
+
requirement: &5116020 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ~>
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: 2.6.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *5116020
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: shoulda-matchers
|
137
|
-
requirement: &
|
137
|
+
requirement: &5114540 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *5114540
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: spork
|
148
|
-
requirement: &
|
148
|
+
requirement: &5149020 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ~>
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: 0.9.0.rc9
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *5149020
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: sqlite3
|
159
|
-
requirement: &
|
159
|
+
requirement: &5147260 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
version: '0'
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *5147260
|
168
168
|
description: Client gem for connecting to SSO server (http://github.com/openteam/sso_server)
|
169
169
|
email:
|
170
170
|
- lda@openteam.ru
|
@@ -172,15 +172,12 @@ executables: []
|
|
172
172
|
extensions: []
|
173
173
|
extra_rdoc_files: []
|
174
174
|
files:
|
175
|
-
- app/
|
176
|
-
- app/
|
177
|
-
- app/
|
178
|
-
-
|
179
|
-
- app/controllers/sso_client/application_controller.rb
|
180
|
-
- app/controllers/sso_client/user_sessions_controller.rb
|
181
|
-
- app/views/sso_client/home/show.html.erb
|
182
|
-
- app/views/layouts/sso_client/application.html.erb
|
175
|
+
- app/models/user.rb
|
176
|
+
- app/controllers/sso_client/sessions_controller.rb
|
177
|
+
- app/controllers/sso_client/omniauth_callbacks_controller.rb
|
178
|
+
- config/initializers/devise.rb
|
183
179
|
- config/routes.rb
|
180
|
+
- db/migrate/20111212032401_recreate_users.rb
|
184
181
|
- lib/omniauth/strategies/identity.rb
|
185
182
|
- lib/sso_client/engine.rb
|
186
183
|
- lib/sso_client/version.rb
|
@@ -203,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
203
200
|
version: '0'
|
204
201
|
segments:
|
205
202
|
- 0
|
206
|
-
hash:
|
203
|
+
hash: 1651071190687628169
|
207
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
205
|
none: false
|
209
206
|
requirements:
|
@@ -212,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
209
|
version: '0'
|
213
210
|
segments:
|
214
211
|
- 0
|
215
|
-
hash:
|
212
|
+
hash: 1651071190687628169
|
216
213
|
requirements: []
|
217
214
|
rubyforge_project:
|
218
215
|
rubygems_version: 1.8.11
|
@@ -1,7 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
-
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
-
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
-
*= require_self
|
6
|
-
*= require_tree .
|
7
|
-
*/
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module SsoClient
|
2
|
-
class ApplicationController < ActionController::Base
|
3
|
-
protect_from_forgery
|
4
|
-
helper_method :current_user
|
5
|
-
|
6
|
-
protected
|
7
|
-
|
8
|
-
def login_required
|
9
|
-
if !current_user
|
10
|
-
respond_to do |format|
|
11
|
-
format.html {
|
12
|
-
redirect_to "#{sso_client.root_path}identity"
|
13
|
-
}
|
14
|
-
format.json {
|
15
|
-
render :json => { 'error' => 'Access Denied' }.to_json
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def current_user
|
22
|
-
session[:user]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module SsoClient
|
2
|
-
class UserSessionsController < ApplicationController
|
3
|
-
before_filter :login_required, :only => :destroy
|
4
|
-
|
5
|
-
respond_to :html
|
6
|
-
|
7
|
-
# Omniauth callback method
|
8
|
-
def create
|
9
|
-
session[:user] = User.from_omniauth(request.env['omniauth.auth'])
|
10
|
-
|
11
|
-
flash[:notice] = "Successfully logged in"
|
12
|
-
redirect_to main_app.root_path
|
13
|
-
end
|
14
|
-
|
15
|
-
# Omniauth failure callback
|
16
|
-
def failure
|
17
|
-
flash[:notice] = params[:message]
|
18
|
-
redirect_to main_app.root_path
|
19
|
-
end
|
20
|
-
|
21
|
-
# logout - Clear our rack session BUT essentially redirect to the provider
|
22
|
-
# to clean up the Devise session from there too !
|
23
|
-
def destroy
|
24
|
-
session[:user] = nil
|
25
|
-
|
26
|
-
flash[:notice] = 'You have successfully signed out!'
|
27
|
-
redirect_to "#{Settings['sso_provider.host']}/users/sign_out"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'modest_model'
|
2
|
-
require 'modest_model/tenacity'
|
3
|
-
|
4
|
-
module SsoClient
|
5
|
-
class User < ModestModel::Base
|
6
|
-
include ModestModel::Tenacity
|
7
|
-
|
8
|
-
attributes :id, :name, :nickname, :email, :first_name, :last_name, :raw_info
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def from_omniauth(omniauth)
|
12
|
-
User.new(omniauth['info']).tap do | user |
|
13
|
-
user.attributes = omniauth['extra']
|
14
|
-
user.id = omniauth['uid']
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def current
|
19
|
-
Thread.current[:user]
|
20
|
-
end
|
21
|
-
|
22
|
-
def current_id
|
23
|
-
current.id if current
|
24
|
-
end
|
25
|
-
|
26
|
-
def current=(user)
|
27
|
-
Thread.current[:user] = user
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def new_record?
|
32
|
-
false
|
33
|
-
end
|
34
|
-
|
35
|
-
def persisted?
|
36
|
-
!new_record?
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>SsoClient</title>
|
5
|
-
<%= stylesheet_link_tag "sso_client/application" %>
|
6
|
-
<%= javascript_include_tag "sso_client/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<% if flash[:notice] %>
|
2
|
-
<p><%=flash[:notice] %> </p>
|
3
|
-
<% flash[:notice] = nil %>
|
4
|
-
<% end %>
|
5
|
-
<% if not current_user %>
|
6
|
-
<%= link_to 'login', login_path %>
|
7
|
-
<% else %>
|
8
|
-
<h1>Hello <%= current_user.name %>!</h1>
|
9
|
-
<%= link_to 'logout', logout_path %>
|
10
|
-
<% end %>
|