nginx - 在访问处理程序中创建的 nginx 变量在后续指令中使用时不包含值
问题描述
我为 nginx 编写了一个模块,它在 ACCESS 阶段注册。该模块解码并验证它接收到的令牌,并存储正在验证的用户的值(在令牌中编码),该值由我为变量定义的变量 get 函数提供。然而,在 location 块中变量的后续使用不会返回该值。在对该位置的下一个 HTTP 请求中,将返回上一个请求的值。它总是不同步 - 当前请求返回上一个 HTTP 请求的名称。
这是我的 nginx.conf 的相关部分:
location /introspect {
set_form_input $token token; # parse the request body
# decode the token, and if valid save user name
jwt_decode aud=$aud token=$token;
# $jwt_user is defined by the module and returns the saved user name
set $whoami $jwt_user;
try_files $uri @success;
}
location @success {
return 200 '{"active" : true, "user" : "$whoami"}';
}
关于可能出现什么问题的任何想法?
解决方案
推荐阅读
- react-native - 有什么办法可以将 TabBar 放在我的标题上
- mongodb - 如何避免集合中的重复条目?
- bash - 用 MAKEFLAGS 覆盖包含空格的 make 变量
- sql - 需要帮助从 sql 内部联接获取 SUM 数据
- python - 比较熊猫组中的不同行
- gradle - 在 gradle 中解压 rpm
- apache-spark - 从数据块中的 mlflow-registry 加载模型时出现 InvalidMountException
- python - 如何使用 Kivy/Buildozer 在 Android 上请求 ACCESS_SURFACE_FLINGER 权限?
- c# - c# 中 CefSharp DevTool 类中的事件处理程序
- powershell - 通过 PowerShell 创建新用户