Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
# Python
|
|
2 | 6 |
import logging |
3 |
|
|
4 |
# Django
|
|
5 | 6 |
from django.utils.encoding import smart_text |
6 |
|
|
7 |
# Django REST Framework
|
|
8 | 6 |
from rest_framework import authentication |
9 |
|
|
10 | 6 |
logger = logging.getLogger('cyborgbackup.api.authentication') |
11 |
|
|
12 |
|
|
13 | 6 |
class LoggedBasicAuthentication(authentication.BasicAuthentication): |
14 |
|
|
15 | 6 |
def authenticate(self, request): |
16 | 6 |
ret = super(LoggedBasicAuthentication, self).authenticate(request) |
17 | 6 |
if ret: |
18 |
username = ret[0].username if ret[0] else '<none>' |
|
19 |
logger.debug(smart_text(u"User {} performed a {} to {} through the API".format(username, |
|
20 |
request.method, |
|
21 |
request.path))) |
|
22 | 6 |
return ret |
23 |
|
|
24 | 6 |
def authenticate_header(self, request): |
25 | 6 |
return super(LoggedBasicAuthentication, self).authenticate_header(request) |
26 |
|
|
27 |
|
|
28 | 6 |
class SessionAuthentication(authentication.SessionAuthentication): |
29 |
|
|
30 | 6 |
def authenticate_header(self, request): |
31 | 6 |
return 'Session' |
32 |
|
|
33 | 6 |
def enforce_csrf(self, request): |
34 | 6 |
return None |
Read our documentation on viewing source code .