saml_idp 0.12.0 → 0.15.0
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 +24 -53
- data/lib/saml_idp/assertion_builder.rb +28 -3
- data/lib/saml_idp/configurator.rb +2 -0
- data/lib/saml_idp/controller.rb +14 -10
- data/lib/saml_idp/encryptor.rb +0 -1
- data/lib/saml_idp/request.rb +4 -3
- data/lib/saml_idp/response_builder.rb +12 -6
- data/lib/saml_idp/saml_response.rb +52 -30
- data/lib/saml_idp/version.rb +1 -1
- data/lib/saml_idp.rb +1 -1
- data/saml_idp.gemspec +30 -29
- data/spec/lib/saml_idp/assertion_builder_spec.rb +143 -0
- data/spec/lib/saml_idp/configurator_spec.rb +1 -0
- data/spec/lib/saml_idp/request_spec.rb +43 -9
- data/spec/lib/saml_idp/saml_response_spec.rb +103 -11
- data/spec/rails_app/app/controllers/saml_controller.rb +1 -5
- data/spec/rails_app/app/controllers/saml_idp_controller.rb +55 -3
- data/{app → spec/rails_app/app}/views/saml_idp/idp/new.html.erb +1 -5
- data/{app → spec/rails_app/app}/views/saml_idp/idp/saml_post.html.erb +1 -1
- data/spec/rails_app/config/application.rb +1 -0
- data/spec/rails_app/config/boot.rb +1 -1
- data/spec/rails_app/config/environments/development.rb +2 -0
- data/spec/spec_helper.rb +1 -1
- metadata +68 -54
- data/app/controllers/saml_idp/idp_controller.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4da444f25fd4d8cb2b53d847ee3ffa44adab3b2c4b64be57a6935c0922acf1a8
|
4
|
+
data.tar.gz: ff0beb64e76c37a0bbcb098f0bd5a50b4d15ff124d63d9c01d421f4693f6fa2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fe91e27e817106e66738c73c670ce064c18b18e9528f7aef3c2a4dc87658c9262877b7a62f491c29ff371d39e0306721bc1f97af7ec3fb6fd1d23b8550b32ce
|
7
|
+
data.tar.gz: d6ee196976da4fe1af818bca3183632372ef2e1e3059891e75a13dc39caa9fb86c3d312c384d926877f9e14cfbd751d566d517742e72e0bb77e276e446a88aed
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Ruby SAML Identity Provider (IdP)
|
2
2
|
|
3
|
-
Forked from https://github.com/lawrencepit/ruby-saml-idp
|
3
|
+
Forked from <https://github.com/lawrencepit/ruby-saml-idp>
|
4
4
|
|
5
5
|
[](https://travis-ci.org/saml-idp/saml_idp)
|
6
6
|
[](http://badge.fury.io/rb/saml_idp)
|
@@ -13,13 +13,15 @@ protocol. It provides a means for managing authentication requests and confirmat
|
|
13
13
|
This was originally setup by @lawrencepit to test SAML Clients. I took it closer to a real
|
14
14
|
SAML IDP implementation.
|
15
15
|
|
16
|
-
|
16
|
+
## Installation and Usage
|
17
17
|
|
18
18
|
Add this to your Gemfile:
|
19
19
|
|
20
|
+
```ruby
|
20
21
|
gem 'saml_idp'
|
22
|
+
```
|
21
23
|
|
22
|
-
|
24
|
+
### Not using rails?
|
23
25
|
|
24
26
|
Include `SamlIdp::Controller` and see the examples that use rails. It should be straightforward for you.
|
25
27
|
|
@@ -27,57 +29,24 @@ Basically you call `decode_request(params[:SAMLRequest])` on an incoming request
|
|
27
29
|
`saml_acs_url` to determine the source for which you need to authenticate a user. How you authenticate
|
28
30
|
a user is entirely up to you.
|
29
31
|
|
30
|
-
Once a user has successfully authenticated on your system send the Service Provider a
|
32
|
+
Once a user has successfully authenticated on your system send the Service Provider a SAMLResponse by
|
31
33
|
posting to `saml_acs_url` the parameter `SAMLResponse` with the return value from a call to
|
32
34
|
`encode_response(user_email)`.
|
33
35
|
|
34
|
-
|
36
|
+
### Using rails?
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
```ruby
|
39
|
-
get '/saml/auth' => 'saml_idp#new'
|
40
|
-
get '/saml/metadata' => 'saml_idp#show'
|
41
|
-
post '/saml/auth' => 'saml_idp#create'
|
42
|
-
match '/saml/logout' => 'saml_idp#logout', via: [:get, :post, :delete]
|
43
|
-
```
|
38
|
+
Check out our Wiki page for Rails integration
|
39
|
+
[Rails Integration guide](https://github.com/saml-idp/saml_idp/wiki/Rails_Integration)
|
44
40
|
|
45
|
-
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
class SamlIdpController < SamlIdp::IdpController
|
49
|
-
def idp_authenticate(email, password) # not using params intentionally
|
50
|
-
user = User.by_email(email).first
|
51
|
-
user && user.valid_password?(password) ? user : nil
|
52
|
-
end
|
53
|
-
private :idp_authenticate
|
54
|
-
|
55
|
-
def idp_make_saml_response(found_user) # not using params intentionally
|
56
|
-
# NOTE encryption is optional
|
57
|
-
encode_response found_user, encryption: {
|
58
|
-
cert: saml_request.service_provider.cert,
|
59
|
-
block_encryption: 'aes256-cbc',
|
60
|
-
key_transport: 'rsa-oaep-mgf1p'
|
61
|
-
}
|
62
|
-
end
|
63
|
-
private :idp_make_saml_response
|
64
|
-
|
65
|
-
def idp_logout
|
66
|
-
user = User.by_email(saml_request.name_id)
|
67
|
-
user.logout
|
68
|
-
end
|
69
|
-
private :idp_logout
|
70
|
-
end
|
71
|
-
```
|
72
|
-
|
73
|
-
## Configuration
|
41
|
+
### Configuration
|
74
42
|
|
75
43
|
#### Signed assertions and Signed Response
|
76
44
|
|
77
|
-
By default SAML Assertion will be signed with an algorithm which defined to `config.algorithm
|
45
|
+
By default SAML Assertion will be signed with an algorithm which defined to `config.algorithm`, because SAML assertions contain secure information used for authentication such as NameID.
|
46
|
+
Besides that, signing assertions could be optional and can be defined with `config.signed_assertion` option. Setting this configuration flag to `false` will add raw assertions on the response instead of signed ones. If the response is encrypted the `config.signed_assertion` will be ignored and all assertions will be signed.
|
78
47
|
|
79
48
|
Signing SAML Response is optional, but some security perspective SP services might require Response message itself must be signed.
|
80
|
-
For that, you can enable it with `
|
49
|
+
For that, you can enable it with `signed_message: true` option for `encode_response(user_email, signed_message: true)` method. [More about SAML spec](https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf#page=68)
|
81
50
|
|
82
51
|
#### Signing algorithm
|
83
52
|
|
@@ -117,7 +86,9 @@ CERT
|
|
117
86
|
# config.attribute_service_location = "#{base}/saml/attributes"
|
118
87
|
# config.single_service_post_location = "#{base}/saml/auth"
|
119
88
|
# config.session_expiry = 86400 # Default: 0 which means never
|
120
|
-
# config.
|
89
|
+
# config.signed_assertion = false # Default: true which means signed assertions on the SAML Response
|
90
|
+
# config.compress = true # Default: false which means the SAML Response is not being compressed
|
91
|
+
# config.logger = ::Logger.new($stdout) # Default: if in Rails context - Rails.logger, else ->(msg) { puts msg }. Works with either a Ruby Logger or a lambda
|
121
92
|
|
122
93
|
# Principal (e.g. User) is passed in when you `encode_response`
|
123
94
|
#
|
@@ -230,7 +201,7 @@ CERT
|
|
230
201
|
end
|
231
202
|
```
|
232
203
|
|
233
|
-
|
204
|
+
## Keys and Secrets
|
234
205
|
|
235
206
|
To generate the SAML Response it uses a default X.509 certificate and secret key... which isn't so secret.
|
236
207
|
You can find them in `SamlIdp::Default`. The X.509 certificate is valid until year 2032.
|
@@ -241,31 +212,31 @@ and `SamlIdp.config.secret_key` properties.
|
|
241
212
|
|
242
213
|
The fingerprint to use, if you use the default X.509 certificate of this gem, is:
|
243
214
|
|
244
|
-
```
|
245
|
-
9E:65:2E:03:06:8D:80:F2:86:C7:6C:77:A1:D9:14:97:0A:4D:F4:4D
|
215
|
+
```bash
|
216
|
+
9E:65:2E:03:06:8D:80:F2:86:C7:6C:77:A1:D9:14:97:0A:4D:F4:4D
|
246
217
|
```
|
247
218
|
|
248
|
-
|
219
|
+
## Fingerprint
|
249
220
|
|
250
221
|
The gem provides an helper to generate a fingerprint for a X.509 certificate.
|
251
222
|
The second parameter is optional and default to your configuration `SamlIdp.config.algorithm`
|
252
223
|
|
253
224
|
```ruby
|
254
|
-
Fingerprint.certificate_digest(x509_cert, :sha512)
|
225
|
+
SamlIdp::Fingerprint.certificate_digest(x509_cert, :sha512)
|
255
226
|
```
|
256
227
|
|
257
|
-
|
228
|
+
## Service Providers
|
258
229
|
|
259
230
|
To act as a Service Provider which generates SAML Requests and can react to SAML Responses use the
|
260
231
|
excellent [ruby-saml](https://github.com/onelogin/ruby-saml) gem.
|
261
232
|
|
262
|
-
|
233
|
+
## Author
|
263
234
|
|
264
235
|
Jon Phenow, jon@jphenow.com, jphenow.com, @jphenow
|
265
236
|
|
266
237
|
Lawrence Pit, lawrence.pit@gmail.com, lawrencepit.com, @lawrencepit
|
267
238
|
|
268
|
-
|
239
|
+
## Copyright
|
269
240
|
|
270
241
|
Copyright (c) 2012 Sport Ngin.
|
271
242
|
Portions Copyright (c) 2010 OneLogin, LLC
|
@@ -16,10 +16,26 @@ module SamlIdp
|
|
16
16
|
attr_accessor :expiry
|
17
17
|
attr_accessor :encryption_opts
|
18
18
|
attr_accessor :session_expiry
|
19
|
+
attr_accessor :name_id_formats_opts
|
20
|
+
attr_accessor :asserted_attributes_opts
|
19
21
|
|
20
22
|
delegate :config, to: :SamlIdp
|
21
23
|
|
22
|
-
def initialize(
|
24
|
+
def initialize(
|
25
|
+
reference_id,
|
26
|
+
issuer_uri,
|
27
|
+
principal,
|
28
|
+
audience_uri,
|
29
|
+
saml_request_id,
|
30
|
+
saml_acs_url,
|
31
|
+
raw_algorithm,
|
32
|
+
authn_context_classref,
|
33
|
+
expiry=60*60,
|
34
|
+
encryption_opts=nil,
|
35
|
+
session_expiry=nil,
|
36
|
+
name_id_formats_opts = nil,
|
37
|
+
asserted_attributes_opts = nil
|
38
|
+
)
|
23
39
|
self.reference_id = reference_id
|
24
40
|
self.issuer_uri = issuer_uri
|
25
41
|
self.principal = principal
|
@@ -31,6 +47,8 @@ module SamlIdp
|
|
31
47
|
self.expiry = expiry
|
32
48
|
self.encryption_opts = encryption_opts
|
33
49
|
self.session_expiry = session_expiry.nil? ? config.session_expiry : session_expiry
|
50
|
+
self.name_id_formats_opts = name_id_formats_opts
|
51
|
+
self.asserted_attributes_opts = asserted_attributes_opts
|
34
52
|
end
|
35
53
|
|
36
54
|
def fresh
|
@@ -98,7 +116,9 @@ module SamlIdp
|
|
98
116
|
end
|
99
117
|
|
100
118
|
def asserted_attributes
|
101
|
-
if
|
119
|
+
if asserted_attributes_opts.present? && !asserted_attributes_opts.empty?
|
120
|
+
asserted_attributes_opts
|
121
|
+
elsif principal.respond_to?(:asserted_attributes)
|
102
122
|
principal.send(:asserted_attributes)
|
103
123
|
elsif !config.attributes.nil? && !config.attributes.empty?
|
104
124
|
config.attributes
|
@@ -139,10 +159,15 @@ module SamlIdp
|
|
139
159
|
private :name_id_getter
|
140
160
|
|
141
161
|
def name_id_format
|
142
|
-
@name_id_format ||= NameIdFormatter.new(
|
162
|
+
@name_id_format ||= NameIdFormatter.new(name_id_formats).chosen
|
143
163
|
end
|
144
164
|
private :name_id_format
|
145
165
|
|
166
|
+
def name_id_formats
|
167
|
+
@name_id_formats ||= (name_id_formats_opts || config.name_id.formats)
|
168
|
+
end
|
169
|
+
private :name_id_formats
|
170
|
+
|
146
171
|
def reference_string
|
147
172
|
"_#{reference_id}"
|
148
173
|
end
|
@@ -22,6 +22,7 @@ module SamlIdp
|
|
22
22
|
attr_accessor :service_provider
|
23
23
|
attr_accessor :assertion_consumer_service_hosts
|
24
24
|
attr_accessor :session_expiry
|
25
|
+
attr_accessor :logger
|
25
26
|
|
26
27
|
def initialize
|
27
28
|
self.x509_certificate = Default::X509_CERTIFICATE
|
@@ -34,6 +35,7 @@ module SamlIdp
|
|
34
35
|
self.service_provider.persisted_metadata_getter = ->(id, service_provider) { }
|
35
36
|
self.session_expiry = 0
|
36
37
|
self.attributes = {}
|
38
|
+
self.logger = defined?(::Rails) ? Rails.logger : ->(msg) { puts msg }
|
37
39
|
end
|
38
40
|
|
39
41
|
# formats
|
data/lib/saml_idp/controller.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
require 'openssl'
|
3
2
|
require 'base64'
|
4
3
|
require 'time'
|
@@ -36,13 +35,8 @@ module SamlIdp
|
|
36
35
|
def validate_saml_request(raw_saml_request = params[:SAMLRequest])
|
37
36
|
decode_request(raw_saml_request)
|
38
37
|
return true if valid_saml_request?
|
39
|
-
|
40
|
-
|
41
|
-
head :forbidden
|
42
|
-
else
|
43
|
-
render nothing: true, status: :forbidden
|
44
|
-
end
|
45
|
-
end
|
38
|
+
|
39
|
+
head :forbidden if defined?(::Rails)
|
46
40
|
false
|
47
41
|
end
|
48
42
|
|
@@ -64,7 +58,13 @@ module SamlIdp
|
|
64
58
|
expiry = opts[:expiry] || 60*60
|
65
59
|
session_expiry = opts[:session_expiry]
|
66
60
|
encryption_opts = opts[:encryption] || nil
|
61
|
+
name_id_formats_opts = opts[:name_id_formats] || nil
|
62
|
+
asserted_attributes_opts = opts[:attributes] || nil
|
67
63
|
signed_message_opts = opts[:signed_message] || false
|
64
|
+
name_id_formats_opts = opts[:name_id_formats] || nil
|
65
|
+
asserted_attributes_opts = opts[:attributes] || nil
|
66
|
+
signed_assertion_opts = opts[:signed_assertion] || true
|
67
|
+
compress_opts = opts[:compress] || false
|
68
68
|
|
69
69
|
SamlResponse.new(
|
70
70
|
reference_id,
|
@@ -79,11 +79,15 @@ module SamlIdp
|
|
79
79
|
expiry,
|
80
80
|
encryption_opts,
|
81
81
|
session_expiry,
|
82
|
-
|
82
|
+
name_id_formats_opts,
|
83
|
+
asserted_attributes_opts,
|
84
|
+
signed_assertion_opts,
|
85
|
+
signed_message_opts,
|
86
|
+
compress_opts
|
83
87
|
).build
|
84
88
|
end
|
85
89
|
|
86
|
-
def encode_logout_response(
|
90
|
+
def encode_logout_response(_principal, opts = {})
|
87
91
|
SamlIdp::LogoutResponseBuilder.new(
|
88
92
|
get_saml_response_id,
|
89
93
|
(opts[:issuer_uri] || issuer_uri),
|
data/lib/saml_idp/encryptor.rb
CHANGED
@@ -61,7 +61,6 @@ module SamlIdp
|
|
61
61
|
key_info.EncryptedKey Id: 'EK', xmlns: 'http://www.w3.org/2001/04/xmlenc#' do |enc_key|
|
62
62
|
enc_key.EncryptionMethod Algorithm: key_transport_ns
|
63
63
|
enc_key.tag! 'ds:KeyInfo', 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#' do |key_info2|
|
64
|
-
key_info2.tag! 'ds:KeyName'
|
65
64
|
key_info2.tag! 'ds:X509Data' do |x509_data|
|
66
65
|
x509_data.tag! 'ds:X509Certificate' do |x509_cert|
|
67
66
|
x509_cert << cert.to_s.gsub(/-+(BEGIN|END) CERTIFICATE-+/, '')
|
data/lib/saml_idp/request.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'saml_idp/xml_security'
|
2
2
|
require 'saml_idp/service_provider'
|
3
|
+
require 'logger'
|
3
4
|
module SamlIdp
|
4
5
|
class Request
|
5
6
|
def self.from_deflated_request(raw)
|
@@ -77,10 +78,10 @@ module SamlIdp
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def log(msg)
|
80
|
-
if
|
81
|
-
|
81
|
+
if config.logger.class <= ::Logger
|
82
|
+
config.logger.info msg
|
82
83
|
else
|
83
|
-
|
84
|
+
config.logger.call msg
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
@@ -23,21 +23,21 @@ module SamlIdp
|
|
23
23
|
self.raw_algorithm = raw_algorithm
|
24
24
|
end
|
25
25
|
|
26
|
-
def encoded(signed_message: false)
|
27
|
-
@encoded ||= signed_message ? encode_signed_message : encode_raw_message
|
26
|
+
def encoded(signed_message: false, compress: false)
|
27
|
+
@encoded ||= signed_message ? encode_signed_message(compress) : encode_raw_message(compress)
|
28
28
|
end
|
29
29
|
|
30
30
|
def raw
|
31
31
|
build
|
32
32
|
end
|
33
33
|
|
34
|
-
def encode_raw_message
|
35
|
-
Base64.strict_encode64(raw)
|
34
|
+
def encode_raw_message(compress)
|
35
|
+
Base64.strict_encode64(compress ? deflate(raw) : raw)
|
36
36
|
end
|
37
37
|
private :encode_raw_message
|
38
38
|
|
39
|
-
def encode_signed_message
|
40
|
-
Base64.strict_encode64(signed)
|
39
|
+
def encode_signed_message(compress)
|
40
|
+
Base64.strict_encode64(compress ? deflate(signed) : signed)
|
41
41
|
end
|
42
42
|
private :encode_signed_message
|
43
43
|
|
@@ -66,11 +66,17 @@ module SamlIdp
|
|
66
66
|
def response_id_string
|
67
67
|
"_#{response_id}"
|
68
68
|
end
|
69
|
+
alias_method :reference_id, :response_id
|
69
70
|
private :response_id_string
|
70
71
|
|
71
72
|
def now_iso
|
72
73
|
Time.now.utc.iso8601
|
73
74
|
end
|
74
75
|
private :now_iso
|
76
|
+
|
77
|
+
def deflate(inflated)
|
78
|
+
Zlib::Deflate.deflate(inflated, 9)[2..-5]
|
79
|
+
end
|
80
|
+
private :deflate
|
75
81
|
end
|
76
82
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'saml_idp/assertion_builder'
|
2
4
|
require 'saml_idp/response_builder'
|
3
5
|
module SamlIdp
|
4
6
|
class SamlResponse
|
5
|
-
attr_accessor :assertion_with_signature
|
6
7
|
attr_accessor :reference_id
|
7
8
|
attr_accessor :response_id
|
8
9
|
attr_accessor :issuer_uri
|
@@ -17,22 +18,32 @@ module SamlIdp
|
|
17
18
|
attr_accessor :expiry
|
18
19
|
attr_accessor :encryption_opts
|
19
20
|
attr_accessor :session_expiry
|
21
|
+
attr_accessor :name_id_formats_opts
|
22
|
+
attr_accessor :asserted_attributes_opts
|
20
23
|
attr_accessor :signed_message_opts
|
24
|
+
attr_accessor :signed_assertion_opts
|
25
|
+
attr_accessor :compression_opts
|
26
|
+
|
27
|
+
def initialize(
|
28
|
+
reference_id,
|
29
|
+
response_id,
|
30
|
+
issuer_uri,
|
31
|
+
principal,
|
32
|
+
audience_uri,
|
33
|
+
saml_request_id,
|
34
|
+
saml_acs_url,
|
35
|
+
algorithm,
|
36
|
+
authn_context_classref,
|
37
|
+
expiry = 60 * 60,
|
38
|
+
encryption_opts = nil,
|
39
|
+
session_expiry = 0,
|
40
|
+
name_id_formats_opts = nil,
|
41
|
+
asserted_attributes_opts = nil,
|
42
|
+
signed_message_opts = false,
|
43
|
+
signed_assertion_opts = true,
|
44
|
+
compression_opts = false
|
45
|
+
)
|
21
46
|
|
22
|
-
def initialize(reference_id,
|
23
|
-
response_id,
|
24
|
-
issuer_uri,
|
25
|
-
principal,
|
26
|
-
audience_uri,
|
27
|
-
saml_request_id,
|
28
|
-
saml_acs_url,
|
29
|
-
algorithm,
|
30
|
-
authn_context_classref,
|
31
|
-
expiry=60*60,
|
32
|
-
encryption_opts=nil,
|
33
|
-
session_expiry=0,
|
34
|
-
signed_message_opts
|
35
|
-
)
|
36
47
|
self.reference_id = reference_id
|
37
48
|
self.response_id = response_id
|
38
49
|
self.issuer_uri = issuer_uri
|
@@ -48,26 +59,34 @@ module SamlIdp
|
|
48
59
|
self.encryption_opts = encryption_opts
|
49
60
|
self.session_expiry = session_expiry
|
50
61
|
self.signed_message_opts = signed_message_opts
|
62
|
+
self.name_id_formats_opts = name_id_formats_opts
|
63
|
+
self.asserted_attributes_opts = asserted_attributes_opts
|
64
|
+
self.signed_assertion_opts = signed_assertion_opts
|
65
|
+
self.name_id_formats_opts = name_id_formats_opts
|
66
|
+
self.asserted_attributes_opts = asserted_attributes_opts
|
67
|
+
self.compression_opts = compression_opts
|
51
68
|
end
|
52
69
|
|
53
70
|
def build
|
54
|
-
@
|
71
|
+
@build ||= encoded_message
|
55
72
|
end
|
56
73
|
|
57
74
|
def signed_assertion
|
58
75
|
if encryption_opts
|
59
76
|
assertion_builder.encrypt(sign: true)
|
60
|
-
|
77
|
+
elsif signed_assertion_opts
|
61
78
|
assertion_builder.signed
|
79
|
+
else
|
80
|
+
assertion_builder.raw
|
62
81
|
end
|
63
82
|
end
|
64
83
|
private :signed_assertion
|
65
84
|
|
66
85
|
def encoded_message
|
67
86
|
if signed_message_opts
|
68
|
-
response_builder.encoded(signed_message: true)
|
87
|
+
response_builder.encoded(signed_message: true, compress: compression_opts)
|
69
88
|
else
|
70
|
-
response_builder.encoded(signed_message: false)
|
89
|
+
response_builder.encoded(signed_message: false, compress: compression_opts)
|
71
90
|
end
|
72
91
|
end
|
73
92
|
private :encoded_message
|
@@ -78,17 +97,20 @@ module SamlIdp
|
|
78
97
|
private :response_builder
|
79
98
|
|
80
99
|
def assertion_builder
|
81
|
-
@assertion_builder ||=
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
100
|
+
@assertion_builder ||=
|
101
|
+
AssertionBuilder.new SecureRandom.uuid,
|
102
|
+
issuer_uri,
|
103
|
+
principal,
|
104
|
+
audience_uri,
|
105
|
+
saml_request_id,
|
106
|
+
saml_acs_url,
|
107
|
+
algorithm,
|
108
|
+
authn_context_classref,
|
109
|
+
expiry,
|
110
|
+
encryption_opts,
|
111
|
+
session_expiry,
|
112
|
+
name_id_formats_opts,
|
113
|
+
asserted_attributes_opts
|
92
114
|
end
|
93
115
|
private :assertion_builder
|
94
116
|
end
|
data/lib/saml_idp/version.rb
CHANGED
data/lib/saml_idp.rb
CHANGED
@@ -9,7 +9,7 @@ module SamlIdp
|
|
9
9
|
require 'saml_idp/metadata_builder'
|
10
10
|
require 'saml_idp/version'
|
11
11
|
require 'saml_idp/fingerprint'
|
12
|
-
require 'saml_idp/engine' if defined?(::Rails)
|
12
|
+
require 'saml_idp/engine' if defined?(::Rails)
|
13
13
|
|
14
14
|
def self.config
|
15
15
|
@config ||= SamlIdp::Configurator.new
|
data/saml_idp.gemspec
CHANGED
@@ -1,61 +1,62 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
+
require 'saml_idp/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
7
|
s.name = %q{saml_idp}
|
7
8
|
s.version = SamlIdp::VERSION
|
8
9
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = [
|
10
|
+
s.authors = ['Jon Phenow']
|
10
11
|
s.email = 'jon.phenow@sportngin.com'
|
11
12
|
s.homepage = 'https://github.com/saml-idp/saml_idp'
|
12
13
|
s.summary = 'SAML Indentity Provider for Ruby'
|
13
14
|
s.description = 'SAML IdP (Identity Provider) Library for Ruby'
|
14
|
-
s.date = Time.now.utc.strftime(
|
15
|
-
s.files = Dir['
|
16
|
-
s.required_ruby_version = '>= 2.
|
15
|
+
s.date = Time.now.utc.strftime('%Y-%m-%d')
|
16
|
+
s.files = Dir['lib/**/*', 'LICENSE', 'README.md', 'Gemfile', 'saml_idp.gemspec']
|
17
|
+
s.required_ruby_version = '>= 2.5'
|
17
18
|
s.license = 'MIT'
|
18
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
-
s.require_paths = [
|
21
|
+
s.require_paths = ['lib']
|
21
22
|
s.rdoc_options = ['--charset=UTF-8']
|
22
23
|
s.metadata = {
|
23
|
-
'homepage_uri'
|
24
|
-
'source_code_uri'
|
25
|
-
'bug_tracker_uri'
|
24
|
+
'homepage_uri' => 'https://github.com/saml-idp/saml_idp',
|
25
|
+
'source_code_uri' => 'https://github.com/saml-idp/saml_idp',
|
26
|
+
'bug_tracker_uri' => 'https://github.com/saml-idp/saml_idp/issues',
|
26
27
|
'documentation_uri' => "http://rdoc.info/gems/saml_idp/#{SamlIdp::VERSION}"
|
27
28
|
}
|
28
29
|
|
29
30
|
s.post_install_message = <<-INST
|
30
|
-
If you're just recently updating saml_idp - please be aware we've changed the default
|
31
|
-
certificate. See the PR and a description of why we've done this here:
|
32
|
-
https://github.com/saml-idp/saml_idp/pull/29
|
33
|
-
|
34
|
-
If you just need to see the certificate `bundle open saml_idp` and go to
|
35
|
-
`lib/saml_idp/default.rb`
|
31
|
+
If you're just recently updating saml_idp - please be aware we've changed the default
|
32
|
+
certificate. See the PR and a description of why we've done this here:
|
33
|
+
https://github.com/saml-idp/saml_idp/pull/29
|
36
34
|
|
37
|
-
|
38
|
-
|
35
|
+
If you just need to see the certificate `bundle open saml_idp` and go to
|
36
|
+
`lib/saml_idp/default.rb`
|
39
37
|
|
40
|
-
|
38
|
+
Similarly, please see the README about certificates - you should avoid using the
|
39
|
+
defaults in a Production environment. Post any issues you to github.
|
41
40
|
|
42
|
-
|
43
|
-
|
41
|
+
** New in Version 0.3.0 **
|
42
|
+
Encrypted Assertions require the xmlenc gem. See the example in the Controller
|
43
|
+
section of the README.
|
44
44
|
INST
|
45
45
|
|
46
|
-
s.add_dependency('activesupport', '>=
|
46
|
+
s.add_dependency('activesupport', '>= 5.2')
|
47
47
|
s.add_dependency('builder', '>= 3.0')
|
48
48
|
s.add_dependency('nokogiri', '>= 1.6.2')
|
49
|
+
s.add_dependency('rexml')
|
50
|
+
s.add_dependency('xmlenc', '>= 0.7.1')
|
49
51
|
|
52
|
+
s.add_development_dependency('activeresource', '>= 5.1')
|
53
|
+
s.add_development_dependency('appraisal')
|
54
|
+
s.add_development_dependency('byebug')
|
55
|
+
s.add_development_dependency('capybara', '>= 2.16')
|
56
|
+
s.add_development_dependency('rails', '>= 5.2')
|
50
57
|
s.add_development_dependency('rake')
|
51
|
-
s.add_development_dependency('simplecov')
|
52
58
|
s.add_development_dependency('rspec', '>= 3.7.0')
|
53
59
|
s.add_development_dependency('ruby-saml', '>= 1.7.2')
|
54
|
-
s.add_development_dependency('
|
55
|
-
s.add_development_dependency('activeresource', '>= 3.2')
|
56
|
-
s.add_development_dependency('capybara', '>= 2.16')
|
60
|
+
s.add_development_dependency('simplecov')
|
57
61
|
s.add_development_dependency('timecop', '>= 0.8')
|
58
|
-
s.add_development_dependency('xmlenc', '>= 0.6.4')
|
59
|
-
s.add_development_dependency('appraisal')
|
60
|
-
s.add_development_dependency('byebug')
|
61
62
|
end
|