如何使用密码保护gunicorn上托管的网站

发布于 2024-12-19 09:05:19 字数 96 浏览 4 评论 0原文

有没有办法对gunicorn中托管的应用程序进行密码保护,

我在apache中使用.htaccess做到了这一点,但是我们可以在gurnicorn中做到这一点吗?

Is there a way to password protect an application which is hosted in gunicorn,

I did this with .htaccess in apache, but can we do this in gurnicorn?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埖埖迣鎅 2024-12-26 09:05:19

您还可以使用中间件,例如终止每个会话,如果不符合要求则不显示任何内容。例如,您可以定义中间件来检查请求是否来自您使用的 IP,如果是 - 不执行任何操作,如果否 - 停止。也许不是最好的,但解决方案:)

You can also use middleware and for example kill every session and show nothing if it not passes the requirements. For example, you can define middleware which checks if the request comes from the IP you use, if yes - do nothing, if no - stop. Maybe not the best, but solution :)

生活了然无味 2024-12-26 09:05:19

您标记了 并且它有一些正确构建的有用的东西进入它......

你应该能够做一个 @login_required 就在您的特定视图功能之前。

如果当前的“匿名”用户未登录,这将强制他们进入登录屏幕。

You tagged and it has some useful things built right into it...

You should be able to do a @login_required right before your specific view funciton.

This will force the current 'anonymous' user to a login screen if they aren't logged in.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文