简体   繁体   English

Symfony 注销。 将目标路径协议从 HTTP 更改为 HTTPS

[英]Symfony logout. Change target path protocol from HTTP to HTTPS

My logout target path sends request by HTTP protocol.我的注销目标路径通过 HTTP 协议发送请求。 All on server works by HTTPS protocol.服务器上的所有内容均通过 HTTPS 协议工作。 How to say that after logout redirect should be by HTTPS protocol?怎么说注销后重定向应该是 HTTPS 协议?

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述 在此处输入图像描述

There are two ways of doing this with Symfony 4. Symfony 4 有两种方法可以做到这一点。

  1. Force HTTPS for an range of urls ( Symfony Docs ) with "requires_channel":使用“requires_channel”强制 HTTPS 获取一系列网址( Symfony 文档):
# config/packages/security.yaml
security:
    # ...

    access_control:
        # ...
        # catch all URLs starting with /api/user
        - { path: '^/api/user', roles: ROLE_USER, requires_channel: https }
  1. Doing this for one Action as Annotation ( Symfony Docs ) with "schemes":使用“方案”对一个操作作为注释( Symfony 文档)执行此操作:
// src/Controller/SecurityController.php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;

class SecurityController extends AbstractController
{
    /**
     * @Route("/api/user/logout-end", name="api-user-logoutEnd", schemes={"https"})
     */
    public function apiUserLogoutEnd()
    {
        // ...
    }
}

It could be that "Logout" is https, but the following site is not. “注销”可能是 https,但以下站点不是。 Then you can apply the methods on that route, too.然后,您也可以在该路线上应用这些方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM