Projet

Général

Profil

0001-utils-add-simple-HTTP-Bearer-authentication-class.patch

Serghei Mihai, 21 mai 2019 10:33

Télécharger (1,06 ko)

Voir les différences:

Subject: [PATCH 1/2] utils: add simple HTTP Bearer authentication class

 passerelle/utils/http_authenticators.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
passerelle/utils/http_authenticators.py
68 68
    def __call__(self, r):
69 69
        r.headers['Authorization'] = self.get_authorization_header(r)
70 70
        return r
71

  
72

  
73
class HttpBearerAuth(AuthBase):
74
    def __init__(self, token):
75
        self.token = token
76

  
77
    def __eq__(self, other):
78
        return self.token == getattr(other, 'token', None)
79

  
80
    def __ne__(self, other):
81
        return not self == other
82

  
83
    def __call__(self, r):
84
        r.headers['Authorization'] = 'Bearer ' + self.token
85
        return r
71
-