rack-saml 0.1.1 → 0.1.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/lib/rack-saml/version.rb +1 -2
- data/lib/rack/saml.rb +22 -28
- 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: 351da5cbd3ac2dee0229017a33144a4263d1ed2d
|
4
|
+
data.tar.gz: 71724a4318c0f7765f32346bcfa0e61ad7b017fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a70cc5feb6435a22310849406420d3ad3fc8faab1e0f1218c38656d428ae89b0141d96c1f8125787d588ffb8b2b617c43ce7274c8b183ce862c2a4a55a5beff
|
7
|
+
data.tar.gz: 062c93f2dc4060cbe67dcd86dfd5947efaade19dff67689372307cf1d178b79e84dbc5a967c374e368a804324459757fc7cc46716fe7a5d2eb18c4cb31099fba
|
data/lib/rack-saml/version.rb
CHANGED
data/lib/rack/saml.rb
CHANGED
@@ -18,15 +18,15 @@ module Rack
|
|
18
18
|
# 'rack_saml' => {
|
19
19
|
# 'ds.session' => {
|
20
20
|
# 'sid' => temporally_generated_hash,
|
21
|
-
# '
|
21
|
+
# 'expires' => xxxxx # timestamp (string)
|
22
22
|
# }
|
23
23
|
# 'saml_authreq.session' => {
|
24
24
|
# 'sid' => temporally_generated_hash,
|
25
|
-
# '
|
25
|
+
# 'expires' => xxxxx # timestamp (string)
|
26
26
|
# }
|
27
27
|
# 'saml_res.session' => {
|
28
28
|
# 'sid' => temporally_generated_hash,
|
29
|
-
# '
|
29
|
+
# 'expires' => xxxxx, # timestamp (string)
|
30
30
|
# 'env' => {}
|
31
31
|
# }
|
32
32
|
# }
|
@@ -39,41 +39,35 @@ module Rack
|
|
39
39
|
class ValidationError < StandardError
|
40
40
|
end
|
41
41
|
|
42
|
+
FILE_TYPE = [:config, :metadata, :attribute_map]
|
43
|
+
FILE_NAME = {
|
44
|
+
:config => 'rack-saml.yml',
|
45
|
+
:metadata => 'metadata.yml',
|
46
|
+
:attribute_map => 'attribute-map.yml'
|
47
|
+
}
|
48
|
+
|
42
49
|
def default_config_path(config_file)
|
43
50
|
::File.expand_path("../../../config/#{config_file}", __FILE__)
|
44
51
|
end
|
45
52
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
default_config_path('metadata.yml')
|
52
|
-
end
|
53
|
-
|
54
|
-
def default_attribute_map
|
55
|
-
default_config_path('attribute-map.yml')
|
53
|
+
def load_file(type)
|
54
|
+
if @opts[type].nil? || !::File.exists?(@opts[type])
|
55
|
+
@opts[type] = default_config_path(FILE_NAME[type])
|
56
|
+
end
|
57
|
+
eval "@#{type} = YAML.load_file(@opts[:#{type}])"
|
56
58
|
end
|
57
59
|
|
58
60
|
def initialize app, opts = {}
|
59
61
|
@app = app
|
60
62
|
@opts = opts
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
+
FILE_TYPE.each do |type|
|
65
|
+
load_file(type)
|
64
66
|
end
|
65
|
-
|
67
|
+
|
66
68
|
if @config['assertion_handler'].nil?
|
67
69
|
raise ArgumentError, "'assertion_handler' parameter should be specified in the :config file"
|
68
70
|
end
|
69
|
-
if @opts[:metadata].nil? || !::File.exists?(@opts[:metadata])
|
70
|
-
@opts[:metadata] = default_metadata
|
71
|
-
end
|
72
|
-
@metadata = YAML.load_file(@opts[:metadata])
|
73
|
-
if @opts[:attribute_map].nil? || !::File.exists?(@opts[:attribute_map])
|
74
|
-
@opts[:attribute_map] = default_attribute_map
|
75
|
-
end
|
76
|
-
@attribute_map = YAML.load_file(@opts[:attribute_map])
|
77
71
|
end
|
78
72
|
|
79
73
|
class Session
|
@@ -102,7 +96,7 @@ module Rack
|
|
102
96
|
def start(type, timeout = 300)
|
103
97
|
sid = nil
|
104
98
|
if timeout.nil?
|
105
|
-
period =
|
99
|
+
period = Time.now + 300
|
106
100
|
else
|
107
101
|
period = Time.now + timeout
|
108
102
|
end
|
@@ -115,7 +109,7 @@ module Rack
|
|
115
109
|
sid = generate_sid
|
116
110
|
end
|
117
111
|
@session["#{type}.session"]['sid'] = sid
|
118
|
-
@session["#{type}.session"]['
|
112
|
+
@session["#{type}.session"]['expires'] = period.to_s
|
119
113
|
@session["#{type}.session"]
|
120
114
|
end
|
121
115
|
|
@@ -130,11 +124,11 @@ module Rack
|
|
130
124
|
def is_valid?(type, sid = nil)
|
131
125
|
session = @session["#{type}.session"]
|
132
126
|
return false if session['sid'].nil? # no valid session
|
133
|
-
if session['
|
127
|
+
if session['expires'].nil? # no expiration
|
134
128
|
return true if sid.nil? # no sid check
|
135
129
|
return true if session['sid'] == sid # sid check
|
136
130
|
else
|
137
|
-
if Time.now < Time.parse(session['
|
131
|
+
if Time.now < Time.parse(session['expires']) # before expiration
|
138
132
|
return true if sid.nil? # no sid check
|
139
133
|
return true if session['sid'] == sid # sid check
|
140
134
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-saml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toyokazu Akiyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|