Revision 0308f3a7 snf-pithos-app/pithos/api/delegate.py
b/snf-pithos-app/pithos/api/delegate.py | ||
---|---|---|
37 | 37 |
import urllib |
38 | 38 |
import urllib2 |
39 | 39 |
|
40 |
from django.http import HttpResponseNotFound, HttpResponseRedirect, HttpResponseBadRequest, HttpResponse |
|
40 |
from django.http import ( |
|
41 |
HttpResponseNotFound, HttpResponseRedirect, HttpResponseBadRequest, |
|
42 |
HttpResponse) |
|
41 | 43 |
from django.utils.http import urlencode |
42 | 44 |
from django.views.decorators.csrf import csrf_exempt |
43 | 45 |
|
44 |
from pithos.api.settings import AUTHENTICATION_URL, AUTHENTICATION_USERS, SERVICE_TOKEN |
|
46 |
from pithos.api.settings import ( |
|
47 |
AUTHENTICATION_URL, AUTHENTICATION_USERS, SERVICE_TOKEN, USER_INFO_URL) |
|
45 | 48 |
|
49 |
from synnefo.lib.astakos import get_username |
|
46 | 50 |
|
47 | 51 |
logger = logging.getLogger(__name__) |
48 | 52 |
|
... | ... | |
90 | 94 |
logger.exception(e) |
91 | 95 |
return HttpResponse(status=e.reason) |
92 | 96 |
return HttpResponse() |
97 |
|
|
98 |
def account_username(request): |
|
99 |
uuid = request.META.get('HTTP_X_USER_UUID') |
|
100 |
try: |
|
101 |
username = get_username( |
|
102 |
SERVICE_TOKEN, uuid, USER_INFO_URL, |
|
103 |
AUTHENTICATION_USERS) |
|
104 |
return HttpResponse(content=username) |
|
105 |
except Exception, e: |
|
106 |
try: |
|
107 |
content, status = e.args |
|
108 |
except: |
|
109 |
content, status = e, 500 |
|
110 |
|
|
111 |
return HttpResponse(status=status, content=content) |
Also available in: Unified diff