utils: add simple HTTP Bearer authentication class
This commit is contained in:
parent
f424478578
commit
a7e7814002
|
@ -68,3 +68,18 @@ class HawkAuth(AuthBase):
|
|||
def __call__(self, r):
|
||||
r.headers['Authorization'] = self.get_authorization_header(r)
|
||||
return r
|
||||
|
||||
|
||||
class HttpBearerAuth(AuthBase):
|
||||
def __init__(self, token):
|
||||
self.token = token
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.token == getattr(other, 'token', None)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self == other
|
||||
|
||||
def __call__(self, r):
|
||||
r.headers['Authorization'] = 'Bearer ' + self.token
|
||||
return r
|
||||
|
|
Loading…
Reference in New Issue