授权标头未到达laravel项目中的服务器 [英] Authorization header not reaching the server in laravel project

查看:119
本文介绍了授权标头未到达laravel项目中的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JWT令牌对android用户进行授权,但是当我将其发送为null时,服务器会删除Authorization标头吗?我需要更改配置以允许标头传递到后端吗?

I'm using JWT token to authorize android users but when i send it it reaches as null, does the server remove the Authorization header? is there a config i need to change to allow my header to pass to the backend?

推荐答案

我在cPanel托管中遇到了此问题,一些安全模块或插件从标头中剥离了Authorization数据,我正在使用Authorization Bearer.我通过重命名Authorization-> ApiToken并更新Laravel核心中的几行代码来绕过它.

I faced this issue in cPanel hosting, some security mod or plugins strips the Authorization data from the header, I was using Authorization Bearer. I bypassed it by renaming Authorization -> ApiToken and updating few lines of code in Laravel core.

文件vendor\laravel\framework\src\Illuminate\Http\Concerns\InteractsWithInput.php方法bearerToken.

public function bearerToken()
{
    $header = $this->header('Authorization', $this->header('ApiToken', ''));

    if (Str::startsWith($header, 'Bearer ')) {
        return Str::substr($header, 7);
    }
}

顺便说一句,编辑核心代码并不理想.

Btw, editing core code is not ideal.

这篇关于授权标头未到达laravel项目中的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆