omniauth-saml 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of omniauth-saml might be problematic. Click here for more details.

data/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ A generic SAML strategy for OmniAuth.
4
4
 
5
5
  https://github.com/PracticallyGreen/omniauth-saml
6
6
 
7
+
8
+ ## 1.1.0 (2013-11-07)
9
+
10
+ * no longer set a default `name_identifier_format`
11
+ * pass strategy options to the underlying ruby-saml library
12
+ * fallback to omniauth callback url if `assertion_consumer_service_url` is not set
13
+ * add `idp_sso_target_url_runtime_params` option
14
+
7
15
  ## 1.0.0 (2012-11-12)
8
16
 
9
17
  * remove SAML code and port to ruby-saml gem
data/README.md CHANGED
@@ -16,12 +16,13 @@ Use the SAML strategy as a middleware in your application:
16
16
  ```ruby
17
17
  require 'omniauth'
18
18
  use OmniAuth::Strategies::SAML,
19
- :assertion_consumer_service_url => "consumer_service_url",
20
- :issuer => "issuer",
21
- :idp_sso_target_url => "idp_sso_target_url",
22
- :idp_cert => "-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----",
23
- :idp_cert_fingerprint => "E7:91:B2:E1:...",
24
- :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
19
+ :assertion_consumer_service_url => "consumer_service_url",
20
+ :issuer => "issuer",
21
+ :idp_sso_target_url => "idp_sso_target_url",
22
+ :idp_sso_target_url_runtime_params => {:original_request_param => :mapped_idp_param},
23
+ :idp_cert => "-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----",
24
+ :idp_cert_fingerprint => "E7:91:B2:E1:...",
25
+ :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
25
26
  ```
26
27
 
27
28
  or in your Rails application:
@@ -37,12 +38,13 @@ and in `config/initializers/omniauth.rb`:
37
38
  ```ruby
38
39
  Rails.application.config.middleware.use OmniAuth::Builder do
39
40
  provider :saml,
40
- :assertion_consumer_service_url => "consumer_service_url",
41
- :issuer => "rails-application",
42
- :idp_sso_target_url => "idp_sso_target_url",
43
- :idp_cert => "-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----",
44
- :idp_cert_fingerprint => "E7:91:B2:E1:...",
45
- :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
41
+ :assertion_consumer_service_url => "consumer_service_url",
42
+ :issuer => "rails-application",
43
+ :idp_sso_target_url => "idp_sso_target_url",
44
+ :idp_sso_target_url_runtime_params => {:original_request_param => :mapped_idp_param},
45
+ :idp_cert => "-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----",
46
+ :idp_cert_fingerprint => "E7:91:B2:E1:...",
47
+ :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
46
48
  end
47
49
  ```
48
50
 
@@ -51,8 +53,8 @@ For IdP-initiated SSO, users should directly access the IdP SSO target URL. Set
51
53
  ## Options
52
54
 
53
55
  * `:assertion_consumer_service_url` - The URL at which the SAML assertion should be
54
- received. With OmniAuth this is typically `http://example.com/auth/callback`.
55
- **Required**.
56
+ received. If not provided, defaults to the OmniAuth callback URL (typically
57
+ `http://example.com/auth/saml/callback`). Optional.
56
58
 
57
59
  * `:issuer` - The name of your application. Some identity providers might need this
58
60
  to establish the identity of the service provider requesting the login. **Required**.
@@ -60,6 +62,12 @@ For IdP-initiated SSO, users should directly access the IdP SSO target URL. Set
60
62
  * `:idp_sso_target_url` - The URL to which the authentication request should be sent.
61
63
  This would be on the identity provider. **Required**.
62
64
 
65
+ * `:idp_sso_target_url_runtime_params` - A dynamic mapping of request params that exist
66
+ during the request phase of OmniAuth that should to be sent to the IdP after a specific
67
+ mapping. So for example, a param `original_request_param` with value `original_param_value`,
68
+ could be sent to the IdP on the login request as `mapped_idp_param` with value
69
+ `original_param_value`. Optional.
70
+
63
71
  * `:idp_cert` - The identity provider's certificate in PEM format. Takes precedence
64
72
  over the fingerprint option below. This option or `:idp_cert_fingerprint` must
65
73
  be present.
@@ -68,27 +76,27 @@ For IdP-initiated SSO, users should directly access the IdP SSO target URL. Set
68
76
  "90:CC:16:F0:8D:...". This is provided from the identity provider when setting up
69
77
  the relationship. This option or `:idp_cert` must be present.
70
78
 
71
- * `:name_identifier_format` - Describes the format of the username required by this
72
- application. If you need the email address, use "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress".
73
- See http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf section 8.3 for
79
+ * `:name_identifier_format` - Used during SP-initiated SSO. Describes the format of
80
+ the username required by this application. If you need the email address, use
81
+ "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress". See
82
+ http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf section 8.3 for
74
83
  other options. Note that the identity provider might not support all options.
75
- Used during SP-initiated SSO. Optional.
84
+ If not specified, the IdP is free to choose the name identifier format used
85
+ in the response. Optional.
76
86
 
77
87
  * See the `Onelogin::Saml::Settings` class in the [Ruby SAML gem](https://github.com/onelogin/ruby-saml) for additional supported options.
78
88
 
79
89
  ## Authors
80
90
 
81
- Authored by Raecoo Cao, Todd W Saxton, Ryan Wilcox, Rajiv Aaron Manglani, and Steven Anderson.
91
+ Authored by Raecoo Cao, Todd W Saxton, Ryan Wilcox, Rajiv Aaron Manglani, Steven Anderson, and Nikos Dimitrakopoulos.
82
92
 
83
93
  Maintained by [Rajiv Aaron Manglani](http://www.rajivmanglani.com/).
84
94
 
85
95
  ## License
86
96
 
87
- Copyright (c) 2011-2012 [Practically Green, Inc.](http://www.practicallygreen.com/).
97
+ Copyright (c) 2011-2013 [Practically Green, Inc.](http://www.practicallygreen.com/).
88
98
  All rights reserved. Released under the MIT license.
89
99
 
90
- Portions Copyright (c) 2007 Sun Microsystems Inc.
91
-
92
100
  Permission is hereby granted, free of charge, to any person obtaining a copy
93
101
  of this software and associated documentation files (the "Software"), to deal
94
102
  in the Software without restriction, including without limitation the rights
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module SAML
3
- VERSION = "1.0.0"
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -6,13 +6,22 @@ module OmniAuth
6
6
  class SAML
7
7
  include OmniAuth::Strategy
8
8
 
9
- option :name_identifier_format, "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
9
+ option :name_identifier_format, nil
10
+ option :idp_sso_target_url_runtime_params, {}
10
11
 
11
12
  def request_phase
12
- request = Onelogin::Saml::Authrequest.new
13
+ options[:assertion_consumer_service_url] ||= callback_url
14
+ runtime_request_parameters = options.delete(:idp_sso_target_url_runtime_params)
15
+
16
+ additional_params = {}
17
+ runtime_request_parameters.each_pair do |request_param_key, mapped_param_key|
18
+ additional_params[mapped_param_key] = request.params[request_param_key.to_s] if request.params.has_key?(request_param_key.to_s)
19
+ end if runtime_request_parameters
20
+
21
+ authn_request = Onelogin::Saml::Authrequest.new
13
22
  settings = Onelogin::Saml::Settings.new(options)
14
23
 
15
- redirect(request.create(settings))
24
+ redirect(authn_request.create(settings, additional_params))
16
25
  end
17
26
 
18
27
  def callback_phase
@@ -20,7 +29,7 @@ module OmniAuth
20
29
  raise OmniAuth::Strategies::SAML::ValidationError.new("SAML response missing")
21
30
  end
22
31
 
23
- response = Onelogin::Saml::Response.new(request.params['SAMLResponse'])
32
+ response = Onelogin::Saml::Response.new(request.params['SAMLResponse'], options)
24
33
  response.settings = Onelogin::Saml::Settings.new(options)
25
34
 
26
35
  @name_id = response.name_id
@@ -45,8 +54,8 @@ module OmniAuth
45
54
  {
46
55
  :name => @attributes[:name],
47
56
  :email => @attributes[:email] || @attributes[:mail],
48
- :first_name => @attributes[:first_name] || @attributes[:firstname],
49
- :last_name => @attributes[:last_name] || @attributes[:lastname]
57
+ :first_name => @attributes[:first_name] || @attributes[:firstname] || @attributes[:firstName],
58
+ :last_name => @attributes[:last_name] || @attributes[:lastname] || @attributes[:lastName]
50
59
  }
51
60
  end
52
61
 
@@ -16,22 +16,43 @@ describe OmniAuth::Strategies::SAML, :type => :strategy do
16
16
  let(:auth_hash){ last_request.env['omniauth.auth'] }
17
17
  let(:saml_options) do
18
18
  {
19
- :assertion_consumer_service_url => "http://localhost:3000/auth/saml/callback",
20
- :issuer => "https://saml.issuer.url/issuers/29490",
21
- :idp_sso_target_url => "https://idp.sso.target_url/signon/29490",
22
- :idp_cert_fingerprint => "C1:59:74:2B:E8:0C:6C:A9:41:0F:6E:83:F6:D1:52:25:45:58:89:FB",
23
- :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
19
+ :assertion_consumer_service_url => "http://localhost:3000/auth/saml/callback",
20
+ :issuer => "https://saml.issuer.url/issuers/29490",
21
+ :idp_sso_target_url => "https://idp.sso.target_url/signon/29490",
22
+ :idp_cert_fingerprint => "C1:59:74:2B:E8:0C:6C:A9:41:0F:6E:83:F6:D1:52:25:45:58:89:FB",
23
+ :idp_sso_target_url_runtime_params => {:original_param_key => :mapped_param_key},
24
+ :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
24
25
  }
25
26
  end
26
27
  let(:strategy) { [OmniAuth::Strategies::SAML, saml_options] }
27
28
 
28
29
  describe 'GET /auth/saml' do
29
- before do
30
- get '/auth/saml'
30
+ context 'without idp runtime params present' do
31
+ before do
32
+ get '/auth/saml'
33
+ end
34
+
35
+ it 'should get authentication page' do
36
+ last_response.should be_redirect
37
+ last_response.location.should match /https:\/\/idp.sso.target_url\/signon\/29490/
38
+ last_response.location.should match /\?SAMLRequest=/
39
+ last_response.location.should_not match /mapped_param_key/
40
+ last_response.location.should_not match /original_param_key/
41
+ end
31
42
  end
32
43
 
33
- it 'should get authentication page' do
34
- last_response.should be_redirect
44
+ context 'with idp runtime params' do
45
+ before do
46
+ get '/auth/saml', 'original_param_key' => 'original_param_value', 'mapped_param_key' => 'mapped_param_value'
47
+ end
48
+
49
+ it 'should get authentication page' do
50
+ last_response.should be_redirect
51
+ last_response.location.should match /https:\/\/idp.sso.target_url\/signon\/29490/
52
+ last_response.location.should match /\?SAMLRequest=/
53
+ last_response.location.should match /\&mapped_param_key=original_param_value/
54
+ last_response.location.should_not match /original_param_key/
55
+ end
35
56
  end
36
57
  end
37
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-saml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,11 @@ authors:
9
9
  - Ryan Wilcox
10
10
  - Rajiv Aaron Manglani
11
11
  - Steven Anderson
12
+ - Nikos Dimitrakopoulos
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
- date: 2012-11-13 00:00:00.000000000 Z
16
+ date: 2013-11-11 00:00:00.000000000 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: omniauth
@@ -37,7 +38,7 @@ dependencies:
37
38
  requirements:
38
39
  - - ~>
39
40
  - !ruby/object:Gem::Version
40
- version: '0.6'
41
+ version: 0.7.2
41
42
  type: :runtime
42
43
  prerelease: false
43
44
  version_requirements: !ruby/object:Gem::Requirement
@@ -45,39 +46,7 @@ dependencies:
45
46
  requirements:
46
47
  - - ~>
47
48
  - !ruby/object:Gem::Version
48
- version: '0.6'
49
- - !ruby/object:Gem::Dependency
50
- name: guard
51
- requirement: !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- version: '1.0'
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
62
- - - ~>
63
- - !ruby/object:Gem::Version
64
- version: '1.0'
65
- - !ruby/object:Gem::Dependency
66
- name: guard-rspec
67
- requirement: !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ~>
71
- - !ruby/object:Gem::Version
72
- version: '2.1'
73
- type: :development
74
- prerelease: false
75
- version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ~>
79
- - !ruby/object:Gem::Version
80
- version: '2.1'
49
+ version: 0.7.2
81
50
  - !ruby/object:Gem::Dependency
82
51
  name: rspec
83
52
  requirement: !ruby/object:Gem::Requirement