mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 11:22:10 +08:00
feat : admin aspect
This commit is contained in:
61
app/Constants/Common/ClientIpRequestConstant.php
Normal file
61
app/Constants/Common/ClientIpRequestConstant.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Constants\Common;
|
||||
|
||||
|
||||
final class ClientIpRequestConstant
|
||||
{
|
||||
/**
|
||||
* RFC 7239 标准的 Forwarded 头
|
||||
*/
|
||||
public const int HEADER_FORWARDED = 0b000001;
|
||||
|
||||
/**
|
||||
* 客户端原始 IP
|
||||
*/
|
||||
public const int HEADER_X_FORWARDED_FOR = 0b000010;
|
||||
|
||||
/**
|
||||
* 原始主机名
|
||||
*/
|
||||
public const int HEADER_X_FORWARDED_HOST = 0b000100;
|
||||
|
||||
/**
|
||||
* 原始协议 (http/https)
|
||||
*/
|
||||
public const int HEADER_X_FORWARDED_PROTO = 0b001000;
|
||||
|
||||
/**
|
||||
* 原始端口
|
||||
*/
|
||||
public const int HEADER_X_FORWARDED_PORT = 0b010000;
|
||||
|
||||
/**
|
||||
* 原始路径前缀
|
||||
*/
|
||||
public const int HEADER_X_FORWARDED_PREFIX = 0b100000;
|
||||
|
||||
/**
|
||||
* 将部分标志映射到 RFC 7239 Forwarded 头中的参数名
|
||||
*/
|
||||
public const array FORWARDED_PARAMS = [
|
||||
self::HEADER_X_FORWARDED_FOR => 'for',
|
||||
self::HEADER_X_FORWARDED_HOST => 'host',
|
||||
self::HEADER_X_FORWARDED_PROTO => 'proto',
|
||||
self::HEADER_X_FORWARDED_PORT => 'host',
|
||||
];
|
||||
|
||||
/**
|
||||
* 将标志映射到实际的 HTTP 头名称
|
||||
*/
|
||||
public const array TRUSTED_HEADERS = [
|
||||
self::HEADER_FORWARDED => 'forwarded',
|
||||
self::HEADER_X_FORWARDED_FOR => 'x-forwarded-for',
|
||||
self::HEADER_X_FORWARDED_HOST => 'x-forwarded-host',
|
||||
self::HEADER_X_FORWARDED_PROTO => 'x-forwarded-proto',
|
||||
self::HEADER_X_FORWARDED_PORT => 'x-forwarded-port',
|
||||
self::HEADER_X_FORWARDED_PREFIX => 'x-forwarded-prefix',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user