NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
Weixk
V2EX  ›  NGINX

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

  •  
  •   Weixk · May 27, 2020 · 3939 views
    This topic created in 2201 days ago, the information mentioned may be changed or developed.

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

    8 replies    2020-05-28 11:01:03 +08:00
    johnniang
        1
    johnniang  
       May 27, 2020 via Android
    htpasswd
    Weixk
        2
    Weixk  
    OP
       May 27, 2020
    @johnniang htpasswd 有 bcryte 算法,但是 ngx_http_auth_basic_module 不支持
    0ZXYDDu796nVCFxq
        3
    0ZXYDDu796nVCFxq  
       May 27, 2020 via Android
    直接调用 libc.so
    libc.so 支持就行
    Xusually
        4
    Xusually  
       May 27, 2020
    怎么可能不支持?

    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
        5
    nuk  
       May 28, 2020
    不是有 PAM 模块
    Weixk
        6
    Weixk  
    OP
       May 28, 2020
    pmispig
        7
    pmispig  
       May 28, 2020
    用 openresty,你想用什么加密方式都可以。。
    Xusually
        8
    Xusually  
       May 28, 2020
    @Weixk
    你看下代码,最后的 fallback:

    /* fallback to libc crypt() */

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

    libc crypt()支持的都可以,至于你提到的 pbkdf2 我不清楚。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2846 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 04:24 · PVG 12:24 · LAX 21:24 · JFK 00:24
    ♥ Do have faith in what you're doing.