python - Python中nginx和uWSGI获取认证数据

标签 python authentication uwsgi

我需要在我的小型 Python 应用程序(只有一个脚本)中从 nginx + uWSGI 获取身份验证数据。身份验证必须在 Web 服务器端(例如 nginx,nginx.conf 中的基本身份验证)实现,而不是在 Python 应用程序中实现,这一点很重要!所以,没有中间件或类似的东西会有所帮助......

我想 uWSGI 必须通过其 API 或 smth 将此数据发送到我的 Python 应用程序..

如何在 Python 脚本中获取这些数据? 我需要类似的东西

$_SERVER['PHP_AUTH_USER']

在 PHP 中。

uWSGI session :

[uwsgi]

socket = /tmp/uwsgi.sock
processes = 4
master = true
module = myapp
harakiri = 30
cache = false
daemonize = /var/log/uwsgi.log

nginx 配置:

server {
listen       8080;
server_name  _;


location / {
    include        uwsgi_params;
    uwsgi_pass     unix:///tmp/uwsgi.sock;
uwsgi_cache off;    
}

}

谢谢!

最佳答案

尝试添加

uwsgi_param REMOTE_USER $remote_user;

在 nginx 配置中

您将在environ['REMOTE_USER']中找到用户名

关于python - Python中nginx和uWSGI获取认证数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11180795/

相关文章:

python - 使用 numba 处理容器中多个常量的最佳方法?

python - 从 crontab 运行 python 时的意外行为

python - 打印出文本的行号?

java - JDBC 无法登录 LocalDB 实例,但在 SSMS 中我可以登录

node.js - 使用 Node.js 连接到 PHP 网站并保持 session

django - Nginx+uWsgi+Django 'Permission denied while connecting to upstream'(套接字)

ubuntu - 带有 uWSGI : Can't set as system service on Ubuntu 的 flask

python - 迭代生成器时调用 iter 和 next

java - RxJava retry当重试整个方法时返回一个Completable

python - uWSGI中的timer和rbtimer有什么区别?