[英]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?如何将触发 omniauth 的路由从使用 /auth/:provider 更改为 /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.我也不想重定向,因为我的服务器会将不在 /myapp/ 中的任何内容发送到错误的位置。
Here is how I did this in the config.ru file.以下是我在config.ru文件中的做法。 I my case, my provider is CAS .我的情况是,我的提供者是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
.请注意, CAS::OPTIONS
是一个数组,其中包含omniauth::cas
的 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
.我认为您也必须更改 omniauth 回调: /auth/:provider/callback
应该作为前缀/my-app-path/auth/:provider/callback
。
You can change it via :setup
option您可以通过:setup
选项更改它
Source: https://github.com/omniauth/omniauth/blob/e9978e377f1ac2b7271e5a8486dfe103a1c1d48d/lib/omniauth/strategy.rb#L304-L307资料来源: https://github.com/omniauth/omniauth/blob/e9978e377f1ac2b7271e5a8486dfe103a1c1d48d/lib/omniauth/strategy.rb#L304-L307
Add the following option in your initializer:在初始化程序中添加以下选项:
option :request_path, 'https://yourdomain.com/auth/yourprovider/callback'
Restart you app server and try!重新启动您的应用服务器并尝试!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.