我一直在尝试将Symphony 4实例配置为使用https而不是http,但是一直停留在如何修复转到uri /login/
的重定向循环上。使用基本的http可以正常工作,但是当我尝试通过此article添加https支持时,会出现重定向循环。所以相关的配置文件是:
hwi_oauth.yaml
hwi_oauth:
firewall_names: [secured_area]
connect: ~
resource_owners:
auth0:
type: oauth2
class: 'App\Model\Auth0ResourceOwner'
base_url: https://mytenant.auth0.com
client_id: myid
client_secret: mysecret
redirect_uri: /oauth/callback
scope: "openid profile email"
security.yaml
security:
providers:
hwi:
id: hwi_oauth.user.provider
firewalls:
secured_area:
anonymous: ~
oauth:
resource_owners:
auth0: "/oauth/callback"
login_path: /login
use_forward: false
failure_path: /login
default_target_path: /secured
oauth_user_provider:
service: hwi_oauth.user.provider
logout:
path: /logout
target: /
access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/secured, roles: ROLE_OAUTH_USER }
hwi_oauth_routing.yaml
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /connect
schemes: [https]
hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /connect
schemes: [https]
hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /login
schemes: [https]
auth0_login:
path: /oauth/callback
schemes: [https]
auth0_logout:
path: /logout
schemes: [https]
答案 0 :(得分:0)
尽力而为-enter link description here
答案 1 :(得分:0)
我没有意识到我需要配置symfony如何配置代理。因此,article解决了我的问题。
我使用了代码的变体
// public/index.php
// ...
$request = Request::createFromGlobals();
// tell Symfony about your reverse proxy
Request::setTrustedProxies(
// the IP address (or range) of your proxy
['192.0.0.1', '10.0.0.0/8'],
// trust *all* "X-Forwarded-*" headers
Request::HEADER_X_FORWARDED_ALL
// or, if your proxy instead uses the "Forwarded" header
// Request::HEADER_FORWARDED
// or, if you're using AWS ELB
// Request::HEADER_X_FORWARDED_AWS_ELB
);