josso-client 0.1 → 0.1.1
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.
- data/config/josso_config.yml +10 -0
- data/lib/{main.rb → josso-client.rb} +18 -20
- data/rails/init.rb +3 -0
- metadata +9 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## YAML Template.
|
|
2
|
+
development:
|
|
3
|
+
josso_root: http://www.yourjossoserver.com/josso/
|
|
4
|
+
partner_application_entry_url: http://localhost:3000
|
|
5
|
+
test:
|
|
6
|
+
josso_root: http://www.yourjossoserver.com/josso/
|
|
7
|
+
partner_application_entry_url: http://localhost:3000
|
|
8
|
+
production:
|
|
9
|
+
josso_root: http://www.yourjossoserver.com/josso/
|
|
10
|
+
partner_application_entry_url: http://localhost:3000
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
require 'josso_agent.rb'
|
|
2
2
|
|
|
3
3
|
module Main
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
mattr_accessor :APP_CONFIG
|
|
5
6
|
|
|
6
7
|
def self.included(base_class)
|
|
8
|
+
#
|
|
9
|
+
# test for override config file
|
|
10
|
+
#
|
|
11
|
+
if File.exist?(RAILS_ROOT + '/config/josso_config.yml')
|
|
12
|
+
self.APP_CONFIG = YAML.load_file(RAILS_ROOT + '/config/josso_config.yml')[RAILS_ENV]
|
|
13
|
+
else
|
|
14
|
+
self.APP_CONFIG = YAML.load_file(File.join(File.dirname(__FILE__), '../config/josso_config.yml'))[RAILS_ENV]
|
|
15
|
+
end
|
|
7
16
|
base_class.extend(ClassMethods)
|
|
8
17
|
end
|
|
9
18
|
|
|
@@ -13,18 +22,6 @@ module Main
|
|
|
13
22
|
def inject_josso_agent
|
|
14
23
|
before_filter :authorize
|
|
15
24
|
end
|
|
16
|
-
|
|
17
|
-
# look up roles for user
|
|
18
|
-
def get_roles
|
|
19
|
-
jossoagent = Jossoagent.new(APP_CONFIG['josso_root'] + 'services/SSOIdentityManager', APP_CONFIG['josso_root'] + 'services/SSOIdentityProvider')
|
|
20
|
-
user = jossoagent.find_user_in_session(session[:josso_session_id])
|
|
21
|
-
|
|
22
|
-
if user.nil?
|
|
23
|
-
return nil
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
return jossoagent.find_roles_by_username(user)
|
|
27
|
-
end
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
private
|
|
@@ -44,13 +41,13 @@ module Main
|
|
|
44
41
|
def login(partner_application_entry_url, josso_assertion_id)
|
|
45
42
|
begin
|
|
46
43
|
if (josso_assertion_id.nil?)
|
|
47
|
-
redirect_to APP_CONFIG['josso_root'] + "signon/login.do?josso_back_to=" + partner_application_entry_url
|
|
44
|
+
redirect_to self.APP_CONFIG['josso_root'] + "signon/login.do?josso_back_to=" + partner_application_entry_url
|
|
48
45
|
else
|
|
49
|
-
jossoagent = Jossoagent.new(APP_CONFIG['josso_root'] + 'services/SSOIdentityManager', APP_CONFIG['josso_root'] + 'services/SSOIdentityProvider')
|
|
46
|
+
jossoagent = Jossoagent.new(self.APP_CONFIG['josso_root'] + 'services/SSOIdentityManager', self.APP_CONFIG['josso_root'] + 'services/SSOIdentityProvider')
|
|
50
47
|
josso_session_id = jossoagent.get_josso_session_id(josso_assertion_id)
|
|
51
48
|
if (josso_session_id.nil?)
|
|
52
49
|
reset_session
|
|
53
|
-
redirect_to APP_CONFIG['josso_root'] + "signon/login.do?josso_back_to=" + partner_application_entry_url
|
|
50
|
+
redirect_to self.APP_CONFIG['josso_root'] + "signon/login.do?josso_back_to=" + partner_application_entry_url
|
|
54
51
|
# login_error('Sorry! Generate josso_session_id error.')
|
|
55
52
|
return false
|
|
56
53
|
end
|
|
@@ -58,11 +55,12 @@ module Main
|
|
|
58
55
|
sso_user = jossoagent.find_user_in_session(josso_session_id)
|
|
59
56
|
if (sso_user.nil?)
|
|
60
57
|
reset_session
|
|
61
|
-
redirect_to APP_CONFIG['josso_root'] + "signon/login.do?josso_back_to=" + partner_application_entry_url
|
|
58
|
+
redirect_to self.APP_CONFIG['josso_root'] + "signon/login.do?josso_back_to=" + partner_application_entry_url
|
|
62
59
|
# login_error('Sorry! Fetching sso_user error.')
|
|
63
60
|
return false
|
|
64
61
|
else
|
|
65
62
|
session[:username] = sso_user.name
|
|
63
|
+
session[:roles] = jossoagent.find_roles_by_username(sso_user)
|
|
66
64
|
session[:session_timer_at] = Time.now.to_i
|
|
67
65
|
end
|
|
68
66
|
redirect_to partner_application_entry_url
|
|
@@ -91,7 +89,7 @@ module Main
|
|
|
91
89
|
def logout()
|
|
92
90
|
begin
|
|
93
91
|
if(!session[:josso_session_id].nil?)
|
|
94
|
-
jossoagent = Jossoagent.new(APP_CONFIG['josso_root'] + 'services/SSOIdentityManager', APP_CONFIG['josso_root'] + 'services/SSOIdentityProvider')
|
|
92
|
+
jossoagent = Jossoagent.new(self.APP_CONFIG['josso_root'] + 'services/SSOIdentityManager', self.APP_CONFIG['josso_root'] + 'services/SSOIdentityProvider')
|
|
95
93
|
jossoagent.logout(session[:josso_session_id])
|
|
96
94
|
end
|
|
97
95
|
rescue Exception => e
|
|
@@ -99,12 +97,12 @@ module Main
|
|
|
99
97
|
ensure
|
|
100
98
|
#redirect to unique error page of rece system
|
|
101
99
|
reset_session
|
|
102
|
-
redirect_to APP_CONFIG['partner_application_entry_url']
|
|
100
|
+
redirect_to self.APP_CONFIG['partner_application_entry_url']
|
|
103
101
|
end
|
|
104
102
|
end
|
|
105
103
|
|
|
106
104
|
def login_error(error_message)
|
|
107
105
|
flash[:error_login] = error_message
|
|
108
|
-
@redirect_to_url = APP_CONFIG['josso_root'] + 'signon/login.do'
|
|
106
|
+
@redirect_to_url = self.APP_CONFIG['josso_root'] + 'signon/login.do'
|
|
109
107
|
end
|
|
110
108
|
end
|
data/rails/init.rb
ADDED
metadata
CHANGED
|
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 1
|
|
8
|
-
|
|
8
|
+
- 1
|
|
9
|
+
version: 0.1.1
|
|
9
10
|
platform: ruby
|
|
10
11
|
authors:
|
|
11
12
|
- Peter C Peterson
|
|
@@ -26,12 +27,12 @@ dependencies:
|
|
|
26
27
|
- !ruby/object:Gem::Version
|
|
27
28
|
segments:
|
|
28
29
|
- 2
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
version: 2.
|
|
30
|
+
- 0
|
|
31
|
+
- 0
|
|
32
|
+
version: 2.0.0
|
|
32
33
|
type: :runtime
|
|
33
34
|
version_requirements: *id001
|
|
34
|
-
description: JOSSO client for Rails
|
|
35
|
+
description: JOSSO client for Rails.
|
|
35
36
|
email: peter@saborgato.com
|
|
36
37
|
executables: []
|
|
37
38
|
|
|
@@ -44,8 +45,8 @@ files:
|
|
|
44
45
|
- lib/bak_sso_identity_manager.rb
|
|
45
46
|
- lib/bak_sso_identity_provider.rb
|
|
46
47
|
- lib/bak_wsdl_classes.rb
|
|
48
|
+
- lib/josso-client.rb
|
|
47
49
|
- lib/josso_agent.rb
|
|
48
|
-
- lib/main.rb
|
|
49
50
|
- lib/sso_identity_manager.rb
|
|
50
51
|
- lib/sso_identity_manager_classes.rb
|
|
51
52
|
- lib/sso_identity_provider.rb
|
|
@@ -53,6 +54,8 @@ files:
|
|
|
53
54
|
- lib/SSOIdentityManagerServiceClient.rb
|
|
54
55
|
- lib/SSOIdentityProviderServiceClient.rb
|
|
55
56
|
- test/josso_cllient_test.rb
|
|
57
|
+
- rails/init.rb
|
|
58
|
+
- config/josso_config.yml
|
|
56
59
|
has_rdoc: true
|
|
57
60
|
homepage: http://engineersatlarge.com
|
|
58
61
|
licenses: []
|