feat: add unified authorization middleware
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
```http
|
||||
POST /rpc/passport/Login/Pwd
|
||||
Authorization: Bearer <token>
|
||||
Authorization: <JWT>
|
||||
Content-Type: application/json
|
||||
|
||||
{"account":"demo","password":"secret"}
|
||||
@@ -37,8 +37,8 @@ Content-Type: application/json
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 7,
|
||||
"message": "dynamic RPC method is not allowed",
|
||||
"code": 3,
|
||||
"message": "invalid protobuf JSON: ...",
|
||||
"details": []
|
||||
}
|
||||
```
|
||||
@@ -67,23 +67,10 @@ Content-Type: application/json
|
||||
需要身份的接口统一发送:
|
||||
|
||||
```http
|
||||
Authorization: Bearer <token>
|
||||
Authorization: <JWT>
|
||||
```
|
||||
|
||||
具体方法是否允许匿名由服务实现和 gRPC interceptor 决定。客户端不应仅根据请求字段推断匿名权限。
|
||||
|
||||
## 动态 RPC 白名单
|
||||
|
||||
`all/etc/<workspace>_<runtime>.yaml` 的 `DynamicRPC.Allow` 控制可调用范围:
|
||||
|
||||
```yaml
|
||||
DynamicRPC:
|
||||
Allow:
|
||||
- passport.Login.Pwd
|
||||
- passport.Register
|
||||
```
|
||||
|
||||
支持完整方法名、完整服务名或 `*`。生产环境不建议使用 `*`。
|
||||
请求头直接传递 JWT,不添加 `Bearer` 前缀。`all` 使用 `Authorization.Key` 验证 HS256 签名,并根据 token 的 `exp` 与 `Authorization.Expire` 校验有效期;是否匿名由 `Authorization.Anonymous` 配置决定。
|
||||
|
||||
## 当前限制与风险
|
||||
|
||||
|
||||
Reference in New Issue
Block a user