Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add the soft option to SAML options #101

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

feat: Add the soft option to SAML options #101

wants to merge 2 commits into from

Conversation

quamen
Copy link

@quamen quamen commented Jun 1, 2016

When setting up the providr you can now set the soft option.

provider :saml,
issuer: 'Example',
idp_sso_target_url: 'example.com/sso',
idp_cert: 'mycert',
soft: true

The default is still false, but you can now over-ride this to turn
off raising of SAML validation errors.

This is useful when testing or in environment where you don't really
want to set up a real SAML server with signed requests etc.

@coveralls
Copy link

coveralls commented Jun 2, 2016

Coverage Status

Coverage increased (+0.9%) to 97.736% when pulling 785a1bd on CloverAU:feat/add-soft-option-to-saml-options into 146e469 on omniauth:master.

@md5 md5 mentioned this pull request Jun 25, 2016
@md5
Copy link
Contributor

md5 commented Jun 25, 2016

This looks fine to me. It shouldn't affect existing users. I do think that the option should be documented in README.md though.

@quamen
Copy link
Author

quamen commented Jun 26, 2016

@md5 I've update the README to include the soft option. Let me know if you think it needs more work or if I've missed a place where it should be documented.

@coveralls
Copy link

coveralls commented Jun 26, 2016

Coverage Status

Coverage increased (+0.9%) to 97.736% when pulling 5c6d2f2 on CloverAU:feat/add-soft-option-to-saml-options into 146e469 on omniauth:master.

@@ -125,6 +127,9 @@ The service provider metadata used to ease configuration of the SAML SP in the I
*Note*: All attributes can also be found in an array under `auth_hash[:extra][:raw_info]`,
so this setting should only be used to map attributes that are part of the OmniAuth info hash schema.

* `:soft` - Used to enable/disable the soft mode. When is set false (the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please put backticks around "false"? Same with "true" below.

@md5
Copy link
Contributor

md5 commented Jun 27, 2016

Thanks @quamen. I made some minor comments on the copy in the README.md. I think those additions are good, but I almost feel that it needs to be more strongly worded to make it very clear that soft should not be used in a production situation.

Also, would you mind amending your commit to have chore: in the commit message? For that matter, it might be good to just squash it into the previous commit.

@quamen
Copy link
Author

quamen commented Jun 27, 2016

@md5 I've updated the README and added chore: to the beginning of the commit message.

There wasn't an existing style for security style warnings that I could find so I went with bold warning about security in the README documentation for the soft flag.

@coveralls
Copy link

coveralls commented Jun 27, 2016

Coverage Status

Coverage increased (+0.9%) to 97.736% when pulling fbb9a40 on CloverAU:feat/add-soft-option-to-saml-options into 998eb57 on omniauth:master.

@@ -10,7 +10,7 @@ def self.inherited(subclass)
OmniAuth::Strategy.included(subclass)
end

OTHER_REQUEST_OPTIONS = [:skip_conditions, :allowed_clock_drift, :matches_request_id, :skip_subject_confirmation].freeze
OTHER_REQUEST_OPTIONS = [:skip_conditions, :allowed_clock_drift, :matches_request_id, :skip_subject_confirmation, :soft].freeze
Copy link
Contributor

@md5 md5 Jun 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line necessary? Looking at the ruby-saml source, it seems that soft gets picked up from settings.soft.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this should not be here. It's not necessary, since the soft option is already passed to ruby-saml in the settings hash.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now required after rebasing master.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just made the following changes to your branch and the specs still passed:

diff --git a/lib/omniauth/strategies/saml.rb b/lib/omniauth/strategies/saml.rb
index 01f0a59..a82e3c4 100644
--- a/lib/omniauth/strategies/saml.rb
+++ b/lib/omniauth/strategies/saml.rb
@@ -10,7 +10,7 @@ module OmniAuth
         OmniAuth::Strategy.included(subclass)
       end
 
-      OTHER_REQUEST_OPTIONS = [:skip_conditions, :allowed_clock_drift, :matches_request_id, :skip_subject_confirmation, :soft].freeze
+      OTHER_REQUEST_OPTIONS = [:skip_conditions, :allowed_clock_drift, :matches_request_id, :skip_subject_confirmation].freeze
 
       option :name_identifier_format, nil
       option :idp_sso_target_url_runtime_params, {}
@@ -29,6 +29,8 @@ module OmniAuth
       }
       option :slo_default_relay_state
       option :uid_attribute
+      # NOTE: This setting should *never* be set to true in a production environment
+      option :soft, false
 
       def request_phase
         options[:assertion_consumer_service_url] ||= callback_url
@@ -177,7 +179,6 @@ module OmniAuth
       def handle_response(raw_response, opts, settings)
         response = OneLogin::RubySaml::Response.new(raw_response, opts.merge(settings: settings))
         response.attributes["fingerprint"] = options.idp_cert_fingerprint
-        response.soft = opts[:soft] || false
 
         response.is_valid?
         @name_id = response.name_id
@@ -214,7 +215,6 @@ module OmniAuth
         # the LogoutResponse, verify it, then actually delete our session.
 
         logout_response = OneLogin::RubySaml::Logoutresponse.new(raw_response, settings, :matches_request_id => session["saml_transaction_id"])
-        logout_response.soft = false
         logout_response.validate
 
         session.delete("saml_uid")

@md5
Copy link
Contributor

md5 commented Jun 28, 2016

I'm sorry to go back and forth on this, but the more I think about it, the more I think this shouldn't even be mentioned in the README.md.

We already support passing through a bunch of properties to ruby-saml that are not documented in the README.md, so the only thing that's really needed to support allowing soft to be used is changing the line that unilaterally sets response.soft = false to allow it to be true.

@md5
Copy link
Contributor

md5 commented Jun 28, 2016

@bufferoverflow @supernova32 Do you guys have an opinion on this?

@quamen
Copy link
Author

quamen commented Jun 30, 2016

@md5 I'm happy to change the implementation if that is what you and the other maintainers feel is best. Let me know and I'll re-work this pull request.

@md5
Copy link
Contributor

md5 commented Jun 30, 2016

@quamen I think the implementation is fine.

I'm assuming the way you came to make this PR was like this:

  1. You noticed that ruby-saml supports a soft option
  2. You tried setting soft: true in the omniauth-saml settings
  3. You noticed that it didn't work
  4. You looked at the omniauth-saml source code and noticed that soft is hard-coded to false

Assuming that's the case, I think it's fine for other developers to discover that soft now works in the same way (once this PR merges).

The only thing I think needs to be done with this is removing :soft from OTHER_REQUEST_OPTIONS, unless I'm missing something. I'd also like to get agreement from the other maintainers that leaving this option documented only in ruby-saml is fine.

@quamen
Copy link
Author

quamen commented Jun 30, 2016

@md5 that's exactly how I came to make this PR.

I'll wait to hear from you and the other maintainers, then I'll update the code and/or README to suit.

@bufferoverflow
Copy link
Member

Im ok with this, the statement within README.md is very clear.

@md5
Copy link
Contributor

md5 commented Jul 7, 2016

@bufferoverflow Sounds good

@quamen I think the only unresolved issue in that case is my comment about OTHER_REQUEST_OPTIONS. Can you explain why you think that change is necessary or just remove it by amending your commit?

Copy link
Member

@suprnova32 suprnova32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quamen this looks good. Can you please address the comments we left?

Copy link
Contributor

@md5 md5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once #115 is merged, this PR will need to be updated to take into account the movement of where soft is handled. That PR also adds an additional place where soft is explicitly set to false in the single logout code.

@quamen
Copy link
Author

quamen commented Sep 20, 2016

@quamen this looks good. Can you please address the comments we left?

@supernova32 I've removed the :soft option from the OTHER_REQUEST_OPTIONS array.

@coveralls
Copy link

coveralls commented Sep 20, 2016

Coverage Status

Coverage remained the same at 94.565% when pulling e749aca on CloverAU:feat/add-soft-option-to-saml-options into 76aa16c on omniauth:master.

5 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.565% when pulling e749aca on CloverAU:feat/add-soft-option-to-saml-options into 76aa16c on omniauth:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.565% when pulling e749aca on CloverAU:feat/add-soft-option-to-saml-options into 76aa16c on omniauth:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.565% when pulling e749aca on CloverAU:feat/add-soft-option-to-saml-options into 76aa16c on omniauth:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.565% when pulling e749aca on CloverAU:feat/add-soft-option-to-saml-options into 76aa16c on omniauth:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.565% when pulling e749aca on CloverAU:feat/add-soft-option-to-saml-options into 76aa16c on omniauth:master.

@md5
Copy link
Contributor

md5 commented Dec 16, 2016

@quamen Sorry for the delay on following up on your changes. Do you mind rebasing this PR?

@quamen
Copy link
Author

quamen commented Dec 16, 2016

@quamen Sorry for the delay on following up on your changes. Do you mind rebasing this PR?

@md5 I've rebased against master.

@coveralls
Copy link

coveralls commented Dec 16, 2016

Coverage Status

Coverage decreased (-16.2%) to 78.378% when pulling 6b9e26a on CloverAU:feat/add-soft-option-to-saml-options into 958adef on omniauth:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-16.2%) to 78.378% when pulling 6b9e26a on CloverAU:feat/add-soft-option-to-saml-options into 958adef on omniauth:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-16.2%) to 78.378% when pulling 6b9e26a on CloverAU:feat/add-soft-option-to-saml-options into 958adef on omniauth:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-16.2%) to 78.378% when pulling 6b9e26a on CloverAU:feat/add-soft-option-to-saml-options into 958adef on omniauth:master.

@md5
Copy link
Contributor

md5 commented Dec 16, 2016

@quamen Looks like there are some spec failures now. Mind taking a look at those?

When setting up the providr you can now set the soft option.

  provider :saml,
    issuer: 'Example',
    idp_sso_target_url: 'example.com/sso',
    idp_cert: 'mycert',
    soft: true

The default is still false, but you can now over-ride this to turn
off raising of SAML validation errors.

This is useful when testing or in environment where you don't really
want to set up a real SAML server with signed requests etc.
@quamen
Copy link
Author

quamen commented Dec 16, 2016

@quamen Looks like there are some spec failures now. Mind taking a look at those?

@md5 sorry about that, rebased it all very quickly before getting distracted by other things.

This should go green now.

@coveralls
Copy link

coveralls commented Dec 16, 2016

Coverage Status

Coverage increased (+1.4%) to 95.946% when pulling 1540e5c on CloverAU:feat/add-soft-option-to-saml-options into 958adef on omniauth:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+1.4%) to 95.946% when pulling 1540e5c on CloverAU:feat/add-soft-option-to-saml-options into 958adef on omniauth:master.

@md5
Copy link
Contributor

md5 commented Dec 19, 2016

@quamen Could you describe the scenario where you want to have omniauth-saml in your middleware stack but you don't have an actual SAML server? After looking at this PR again, the big caveat about not using this in production is making me question the need for this change.

In a testing scenario, it seems like it should be possible to generate a usable SAML response with ruby-saml and a key pair generated just for purpose of testing or to mock out the response appropriately. The response generation for test purposes could even be done on a one-time basis if you use something like timecop to time shift and allow any time-dependent validations to pass.

@keysen
Copy link

keysen commented Mar 28, 2018

Hey, I bump this PR as I'm interested by this option too. Why it's not merged yet?

My usecase is:
We have a staging environment exactly like the production, It's a SaaS product, each product have extensions whose Saml and every time we have a non-technical person who wants to setup SAML first on staging, it's hardcore and we add new SAML extensions quite often. It could help them to have a soft option to be sure everything works before fixing all the errors. Could we have this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants