nginx 的 basic 认证密码校验怎样做才更安全?

2020-05-27 21:53:20 +08:00
 Weixk

nginx 的 ngx_http_auth_basic_module 模块,校验密码一般是通过 apr1 算法( MD5 迭代 1000 )实现的吧,不安全。 我们自己 web 服务校验是使用 pbkdf2 算法,但是使用的某些开源组件需要走 nginx 进行 basic 认证。 想问下有没有现成的插件实现了更安全的算法,还是有其他更好的方案做密码校验?

2932 次点击
所在节点    NGINX
8 条回复
johnniang
2020-05-27 22:05:33 +08:00
htpasswd
Weixk
2020-05-27 23:45:26 +08:00
@johnniang htpasswd 有 bcryte 算法,但是 ngx_http_auth_basic_module 不支持
gstqc
2020-05-27 23:53:31 +08:00
直接调用 libc.so
libc.so 支持就行
Xusually
2020-05-27 23:53:49 +08:00
怎么可能不支持?

http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html

The following password types are supported:

encrypted with the crypt() function; can be generated using the “htpasswd” utility from the Apache HTTP Server distribution or the “openssl passwd” command;
hashed with the Apache variant of the MD5-based password algorithm (apr1); can be generated with the same tools;
specified by the “{scheme}data” syntax (1.0.3+) as described in RFC 2307; currently implemented schemes include PLAIN (an example one, should not be used), SHA (1.3.13) (plain SHA-1 hashing, should not be used) and SSHA (salted SHA-1 hashing, used by some software packages, notably OpenLDAP and Dovecot).
nuk
2020-05-28 00:48:08 +08:00
不是有 PAM 模块
Weixk
2020-05-28 09:41:36 +08:00
pmispig
2020-05-28 09:57:34 +08:00
用 openresty,你想用什么加密方式都可以。。
Xusually
2020-05-28 11:01:03 +08:00
@Weixk
你看下代码,最后的 fallback:

/* fallback to libc crypt() */

return ngx_libc_crypt(pool, key, salt, encrypted);

libc crypt()支持的都可以,至于你提到的 pbkdf2 我不清楚。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/676124

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX