nginx 的 basic 认证密码校验怎样做才更安全? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Weixk
V2EX    NGINX

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

  •  
  •   Weixk May 27, 2020 3859 views
    This topic created in 2164 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     2612 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 302ms UTC 02:14 PVG 10:14 LAX 19:14 JFK 22:14
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86