cmsso 0.3.1 → 0.3.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/CHANGELOG.md +5 -0
- data/README.md +93 -0
- data/app/models/cmsso/member.rb +18 -17
- data/lib/cmsso/version.rb +1 -1
- metadata +28 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41666d204d02998cf708a5b46a2d562ed67be822
|
4
|
+
data.tar.gz: 6e38e785a9a5fd7a20182c70771fd9c37b40fcec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afcb28563e46baca814628c995634a43e489123dc584b423e27701b425b191c6e2aa33d3267a03c21620423e7897259a1c2b8755f040ba356875851827fdbe9b
|
7
|
+
data.tar.gz: 0900402a2434c27f30e16add07c99c26aa38b38fef932cb266858ab62b8e4e02a88dcdedb4533a5b1c881739d632c950d1f74e737ff3b3101a1abfe9f525ca50
|
data/CHANGELOG.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
cmsso
|
2
|
+
=====
|
3
|
+
|
4
|
+
Company specific Single Sign On for rails applications.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Simply add cmsso to your Gemfile and bundle it up.
|
9
|
+
|
10
|
+
```Ruby
|
11
|
+
gem 'cmsso'
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Configure cmsso gem with an initializer.
|
17
|
+
|
18
|
+
```Ruby
|
19
|
+
Cmsso.configure do |config|
|
20
|
+
config.module_key = 'my_module_key'
|
21
|
+
|
22
|
+
# optional settings
|
23
|
+
config.base_uri = "http://cmservice-chbs#{environment}.{company}.net:3056/persons"
|
24
|
+
config.proxy = "proxy.{company}.net:2010"
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
This is how your application controller could look like.
|
29
|
+
|
30
|
+
```Ruby
|
31
|
+
class ApplicationController < ActionController::Base
|
32
|
+
include Cmsso
|
33
|
+
protect_from_forgery
|
34
|
+
before_filter :authorize
|
35
|
+
include ApplicationHelper
|
36
|
+
helper_method :current_user
|
37
|
+
|
38
|
+
def current_user
|
39
|
+
@current_user ||= current_user_from_session || current_user_from_cmsso
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def current_user_from_session
|
45
|
+
session[:person]
|
46
|
+
end
|
47
|
+
|
48
|
+
def current_user_from_cmsso
|
49
|
+
person = Cmsso::Member.find(request.headers) || Cmsso::Member.create(request.headers)
|
50
|
+
|
51
|
+
if person
|
52
|
+
session[:person] = person
|
53
|
+
else
|
54
|
+
flash.now[:error] = Cmsso::Member.note
|
55
|
+
AL.warn(Cmsso::Member.note)
|
56
|
+
return Cmsso::Member.new({full_name: "Unknown"})
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def authorize
|
61
|
+
current_user
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
Cmsso::Member.create will create the user with a guest role. This method call is optional.
|
68
|
+
|
69
|
+
In views you can check roles as follows.
|
70
|
+
|
71
|
+
```Ruby
|
72
|
+
current_user.administrator? # true if a user has adminintrator role
|
73
|
+
current_user.operator? # true if a user has operator role
|
74
|
+
current_user.user? # true if a user has user roles
|
75
|
+
current_user.guest? # true if a user has guest role
|
76
|
+
```
|
77
|
+
|
78
|
+
To display the user name in a view do the following:
|
79
|
+
|
80
|
+
```Ruby
|
81
|
+
current_user.full_name
|
82
|
+
```
|
83
|
+
|
84
|
+
### Note
|
85
|
+
uses MIT-LICENSE.
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
1. Fork it
|
90
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
91
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
92
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
93
|
+
5. Create new Pull Request
|
data/app/models/cmsso/member.rb
CHANGED
@@ -9,6 +9,7 @@ module Cmsso
|
|
9
9
|
attr_accessor :first_name
|
10
10
|
attr_accessor :last_name
|
11
11
|
attr_accessor :email
|
12
|
+
attr_accessor :time_zone
|
12
13
|
attr_accessor :roles
|
13
14
|
attr_accessor :reference
|
14
15
|
attr_accessor :status
|
@@ -34,7 +35,7 @@ module Cmsso
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def method_missing(method)
|
37
|
-
@roles.include?(method[0..-2].to_sym)
|
38
|
+
@roles.include?(method[0..-2].to_sym)
|
38
39
|
end
|
39
40
|
|
40
41
|
def full_name
|
@@ -56,8 +57,8 @@ module Cmsso
|
|
56
57
|
|
57
58
|
# call service
|
58
59
|
person = nil
|
59
|
-
|
60
|
-
# set proxy as defined during configuration
|
60
|
+
|
61
|
+
# set proxy as defined during configuration
|
61
62
|
ENV['http_proxy'] = Cmsso.configuration.proxy if ENV
|
62
63
|
|
63
64
|
begin
|
@@ -73,16 +74,16 @@ module Cmsso
|
|
73
74
|
|
74
75
|
end
|
75
76
|
|
76
|
-
# parsing error
|
77
|
+
# parsing error
|
77
78
|
rescue JSON::ParserError => e
|
78
|
-
@@type, @@note = :parse,"Error while parsing role service response"
|
79
|
+
@@type, @@note = :parse,"Error while parsing role service response"
|
79
80
|
return nil
|
80
81
|
|
81
82
|
# service specific
|
82
83
|
rescue SocketError, Errno::ECONNREFUSED => e
|
83
84
|
@@type, @@note = :service,"Error while calling role service: #{e.to_s}"
|
84
85
|
return nil
|
85
|
-
|
86
|
+
|
86
87
|
# unexpected exceptions
|
87
88
|
rescue => e
|
88
89
|
@@type, @@note = :unexpected,"Error while calling role service: #{e.to_s}"
|
@@ -96,11 +97,11 @@ module Cmsso
|
|
96
97
|
# get person reference from http header
|
97
98
|
person_from_header = get_person_from_header(headers)
|
98
99
|
return nil unless person_from_header
|
99
|
-
|
100
|
+
|
100
101
|
# call service
|
101
102
|
person = nil
|
102
|
-
|
103
|
-
# set proxy as defined during configuration
|
103
|
+
|
104
|
+
# set proxy as defined during configuration
|
104
105
|
ENV['http_proxy'] = Cmsso.configuration.proxy
|
105
106
|
|
106
107
|
|
@@ -111,7 +112,7 @@ module Cmsso
|
|
111
112
|
RestClient.put Cmsso.configuration.base_uri, request, :content_type => :json do |response,request,result|
|
112
113
|
# parse reponse and return person object
|
113
114
|
person = Member.new(JSON.parse(response)["response"]["persons"][0])
|
114
|
-
|
115
|
+
|
115
116
|
# check about invalid status
|
116
117
|
unless person.status == 'valid'
|
117
118
|
@@type, @@note = :role_or_person,person.note
|
@@ -119,17 +120,17 @@ module Cmsso
|
|
119
120
|
end
|
120
121
|
|
121
122
|
end
|
122
|
-
|
123
|
-
# parsing error
|
123
|
+
|
124
|
+
# parsing error
|
124
125
|
rescue JSON::ParserError => e
|
125
|
-
@@type, @@note = :parse,"Error while parsing role service response"
|
126
|
+
@@type, @@note = :parse,"Error while parsing role service response"
|
126
127
|
return nil
|
127
128
|
|
128
129
|
# service specific
|
129
130
|
rescue SocketError, Errno::ECONNREFUSED => e
|
130
131
|
@@type, @@note = :service,"Error while calling role service: #{e.to_s}"
|
131
132
|
return nil
|
132
|
-
|
133
|
+
|
133
134
|
# unexpected exceptions
|
134
135
|
rescue => e
|
135
136
|
@@type, @@note = :unexpected,"Error while calling role service: #{e.to_s}"
|
@@ -147,13 +148,13 @@ module Cmsso
|
|
147
148
|
if headers["HTTP_NIBR521"].nil? || headers["HTTP_NIBR521"].size == 0
|
148
149
|
@@type, @@note = :header, "Person could not be authenticated. Is Authentication System (Vordel) running fine?"
|
149
150
|
return nil
|
150
|
-
else
|
151
|
+
else
|
151
152
|
person.reference = headers["HTTP_NIBR521"].downcase
|
152
153
|
person.first_name = headers["HTTP_NIBRFIRST"]
|
153
154
|
|
154
155
|
if headers["HTTP_NIBRLAST"].nil? || headers["HTTP_NIBRLAST"].size == 0 || headers["HTTP_NIBRLAST"] =~ /^null$/
|
155
156
|
person.last_name = person.reference
|
156
|
-
else
|
157
|
+
else
|
157
158
|
person.last_name = headers["HTTP_NIBRLAST"]
|
158
159
|
end
|
159
160
|
|
@@ -173,4 +174,4 @@ module Cmsso
|
|
173
174
|
|
174
175
|
end
|
175
176
|
|
176
|
-
end
|
177
|
+
end
|
data/lib/cmsso/version.rb
CHANGED
metadata
CHANGED
@@ -1,30 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmsso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Steiner
|
8
|
-
- Patrick Kaddu
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-01-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 12.0.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 12.0.0
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: rest-client
|
16
29
|
requirement: !ruby/object:Gem::Requirement
|
17
30
|
requirements:
|
18
|
-
- -
|
31
|
+
- - "~>"
|
19
32
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
33
|
+
version: 2.0.0
|
21
34
|
type: :runtime
|
22
35
|
prerelease: false
|
23
36
|
version_requirements: !ruby/object:Gem::Requirement
|
24
37
|
requirements:
|
25
|
-
- -
|
38
|
+
- - "~>"
|
26
39
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
40
|
+
version: 2.0.0
|
28
41
|
description: CM Single Sign On
|
29
42
|
email:
|
30
43
|
- thomas.steiner@ikey.ch
|
@@ -32,13 +45,15 @@ executables: []
|
|
32
45
|
extensions: []
|
33
46
|
extra_rdoc_files: []
|
34
47
|
files:
|
48
|
+
- CHANGELOG.md
|
49
|
+
- MIT-LICENSE
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
35
52
|
- app/models/cmsso/member.rb
|
53
|
+
- lib/cmsso.rb
|
36
54
|
- lib/cmsso/configuration.rb
|
37
55
|
- lib/cmsso/engine.rb
|
38
56
|
- lib/cmsso/version.rb
|
39
|
-
- lib/cmsso.rb
|
40
|
-
- MIT-LICENSE
|
41
|
-
- Rakefile
|
42
57
|
homepage: http://github.com/thomis/cmsso
|
43
58
|
licenses:
|
44
59
|
- MIT
|
@@ -50,17 +65,17 @@ require_paths:
|
|
50
65
|
- app
|
51
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
67
|
requirements:
|
53
|
-
- -
|
68
|
+
- - ">="
|
54
69
|
- !ruby/object:Gem::Version
|
55
70
|
version: '0'
|
56
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
72
|
requirements:
|
58
|
-
- -
|
73
|
+
- - ">="
|
59
74
|
- !ruby/object:Gem::Version
|
60
75
|
version: '0'
|
61
76
|
requirements: []
|
62
77
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.5.1
|
64
79
|
signing_key:
|
65
80
|
specification_version: 4
|
66
81
|
summary: CM Signle Sign On
|