Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change route of omniauth from /auth/:provider to /myapp/auth/:provider

How can I change the route that triggers omniauth from using /auth/:provider to /myapp/auth/:provider ?

I don't want to redirect either, because my server will send anything that's not in /myapp/ to the wrong place.

like image 663
99miles Avatar asked Apr 05 '12 17:04

99miles


2 Answers

Here is how I did this in the config.ru file. I my case, my provider is CAS.

use OmniAuth::Builder do
  configure do |config|
      config.path_prefix = '/my-app-path/auth'
  end
  provider :cas,  CAS::OPTIONS 
end

Note that CAS::OPTIONS is an array with CAS configuration for omniauth::cas. This seems to work fine. I think you will have to change the omniauth callback too : /auth/:provider/callback should be prefixed to /my-app-path/auth/:provider/callback.

like image 190
Pierre-Gilles Levallois Avatar answered Nov 01 '22 09:11

Pierre-Gilles Levallois


You can change it via :setup option

Source: https://github.com/omniauth/omniauth/blob/e9978e377f1ac2b7271e5a8486dfe103a1c1d48d/lib/omniauth/strategy.rb#L304-L307

like image 6
Sairam Avatar answered Nov 01 '22 08:11

Sairam