Skip to content

Deal with relative url root installations - #837

Closed
oliverguenther wants to merge 2 commits into
omniauth:masterfrom
oliverguenther:master
Closed

oliverguenther wants to merge 2 commits into
omniauth:masterfrom
oliverguenther:master

Conversation

@oliverguenther

Copy link
Copy Markdown
Contributor

This PR allows OmniAuth to transparently handle relative url root installations
by correctly prefixing the default Strategy#request_path and
Strategy#callback_path with SCRIPT_NAME as provided by Rack.

Also, in order to detect the full current path, uses
Rack::Request#path instead of #path_info, as the latter does not
include SCRIPT_NAME.

A deeper question remains: What should happen with custom callback and
request paths? I can't think of a case where a user with a relative url
root installation would not want to prefix its paths, regardless of
setting a custom path or not.
However, since some people may have configured custom paths in order to
deal with relative root, including this change may be breaking.

I have thus included a specific spec that asserts that custom request paths are not prefixed.

This deals with:

#767
#753

We've stumbled over these bugs while fixing our own OmniAuth relative url root path helpers over at opf/openproject#4169

This commit allows OmniAuth to handle relative url root installations
by correctly prefixing the default `Strategy#request_path` and
`Strategy#callback_path` with `SCRIPT_NAME` as provided by Rack.

Also, in order to detect the full current path, uses
`Rack::Request#path` instead of `#path_info`, as the latter does not
include SCRIPT_NAME.

A deeper question remains: What should happen with custom callback and
request paths? I can't think of a case where a user with a relative url
root installation would *not* want to prefix its paths, regardless of
setting a custom path or not.
However, since some people may have configured custom paths in order to
deal with relative root, including this change may be breaking.
oliverguenther added a commit to oliverguenther/openproject that referenced this pull request Feb 19, 2016
Using my own fork that contributes to the PR at
omniauth/omniauth#837
@sferik
sferik force-pushed the master branch 2 times, most recently from a5c7282 to 76feeea Compare August 8, 2016 18:30
@oddevan

oddevan commented Dec 20, 2016

Copy link
Copy Markdown

Just ran into this issue in my own project; would love to see a fix like this.

@kant01ne

Copy link
Copy Markdown

+1 this would be super useful!

oliverguenther added a commit to opf/openproject that referenced this pull request Jun 13, 2017
Fixes hashie warnings of the kind

```
You are setting a key that conflicts with a built-in method Foo#bar.
```

Warnings have been silenced in:
omniauth/omniauth#874

Since our PR (omniauth/omniauth#837) has not
been answered, we maintain our own fork.
@oliverguenther

Copy link
Copy Markdown
Contributor Author

I've re-opened this on the current dev in #903

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.

3 participants