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

combine strict and non strict behaviour #69

Closed
ghost opened this issue Mar 25, 2014 · 3 comments
Closed

combine strict and non strict behaviour #69

ghost opened this issue Mar 25, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 25, 2014

I would like to force the user to use ssl on the sign_in page, to allow to use ssl and non ssl for /api/* and non ssl only for the rest of the urls.
Currently I have these two lines in my configuation:

config.middleware.use Rack::SslEnforcer, :only => [%r{^/users/sign_in/}], :ignore => %r{/assets}, :strict => true, :except_environments => 'development'

config.middleware.use Rack::SslEnforcer, :only => [%r{^/api/}], :ignore => %r{/assets}, :except_environments => 'development'

However, I cannot connect to non-ssl of the api/* urls anymore.

Do I do something wrong here or is this an internal issue?

Thank you very much for your feedback!

@ghost
Copy link
Author

ghost commented Mar 27, 2014

No ideas?

@tobmatth
Copy link
Owner

Sorry for the delayed response, i was quite busy. With this rulesets, i'd expect the following to happen:

  1. Request to https://example.org/api/ressource.json
  2. Request is forced to http://example.org/api/ressource.json (as you use :strict in the first ruleset)
  3. Then, the second ruleset forces it back to https://example.org/api/ressource.json
  4. See 1.

This should work for your setup

config.middleware.use Rack::SslEnforcer, :only => [%r{^/users/sign_in/}], :ignore => [%r{/assets}, %r{/api}], :strict => true, :except_environments => 'development'

@ghost
Copy link
Author

ghost commented Mar 27, 2014

great, thank you so much!

@ghost ghost closed this as completed Mar 27, 2014
This issue was closed.
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

No branches or pull requests

1 participant