holydancer
V2EX  ›  问与答

求教, DRF 中如何既验 Token,也验参数签名

  •  
  •   holydancer · Mar 17, 2022 · 1282 views
    This topic created in 1697 days ago, the information mentioned may be changed or developed.

    第一次接触 Django 和 DRF ,想问下认证模块,如何既验证 Token ,也验证签名

    authentication_classes = [TokenAuthentication,RSAAuthentication]

    现在是这俩认证,好像任何一个通过了,都算通过,直接返回内容数据了。

    我想的是 Token 用来区分用户,签名校验每次请求是否合法,在 DRF 中的正确姿势是什么呢

    3 replies  •  2022-03-17 14:38:42 +08:00
    Hstar
    Hstar
    Mar 17, 2022❤️1
    1
    自己写一个 TokenAndRSAAuthentication 吧
    SjwNo1
    SjwNo1
    Mar 17, 2022
    2
    直接 patch APIView 的 perform_authentication
    holydancer
    holydancer
    OP
    Mar 17, 2022
    3
    @Hstar 就这样解决了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3297 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 03:59 · PVG 11:59 · LAX 19:59 · JFK 22:59
    ♥ Do have faith in what you're doing.