holydancer
V2EX  ›  问与答

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

  •  
  •   holydancer · Mar 17, 2022 · 1029 views
    This topic created in 1556 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
        1
    Hstar  
       Mar 17, 2022   ❤️ 1
    自己写一个 TokenAndRSAAuthentication 吧
    SjwNo1
        2
    SjwNo1  
       Mar 17, 2022
    直接 patch APIView 的 perform_authentication
    holydancer
        3
    holydancer  
    OP
       Mar 17, 2022
    @Hstar 就这样解决了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1070 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 17:56 · PVG 01:56 · LAX 10:56 · JFK 13:56
    ♥ Do have faith in what you're doing.