Revision 0308f3a7
b/snf-common/synnefo/lib/astakos.py | ||
---|---|---|
110 | 110 |
override_users={}): |
111 | 111 |
if override_users: |
112 | 112 |
return uuid |
113 |
|
|
114 |
headers = {} |
|
115 |
if uuid: |
|
116 |
headers['X-User-Uuid'] = uuid |
|
117 |
|
|
113 | 118 |
try: |
114 |
data = call(token, url, {'X-User-Uuid': uuid})
|
|
119 |
data = call(token, url, headers)
|
|
115 | 120 |
except Exception, e: |
116 | 121 |
raise e |
117 | 122 |
else: |
... | ... | |
126 | 131 |
override_users={}): |
127 | 132 |
if override_users: |
128 | 133 |
return username |
134 |
|
|
135 |
headers = {} |
|
136 |
if username: |
|
137 |
headers['X-User-Username'] = username |
|
129 | 138 |
try: |
130 |
data = call(token, url, {'X-User-Username': username})
|
|
139 |
data = call(token, url, headers)
|
|
131 | 140 |
except Exception, e: |
132 | 141 |
raise e |
133 | 142 |
else: |
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) |
b/snf-pithos-app/pithos/api/urls.py | ||
---|---|---|
34 | 34 |
from django.conf.urls.defaults import include, patterns |
35 | 35 |
|
36 | 36 |
# TODO: This only works when in this order. |
37 |
api_urlpatterns = patterns('pithos.api.functions', |
|
38 |
(r'^$', 'top_demux'), |
|
39 |
( |
|
40 |
r'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$', |
|
41 |
'object_demux'), |
|
42 |
(r'^(?P<v_account>.+?)/(?P<v_container>.+?)/?$', |
|
43 |
'container_demux'), |
|
44 |
(r'^(?P<v_account>.+?)/?$', 'account_demux') |
|
45 |
) |
|
37 |
api_urlpatterns = patterns( |
|
38 |
'pithos.api.functions', |
|
39 |
(r'^$', 'top_demux'), |
|
40 |
(r'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$', |
|
41 |
'object_demux'), |
|
42 |
(r'^(?P<v_account>.+?)/(?P<v_container>.+?)/?$', |
|
43 |
'container_demux'), |
|
44 |
(r'^(?P<v_account>.+?)/?$', 'account_demux')) |
|
46 | 45 |
|
47 |
urlpatterns = patterns('', |
|
48 |
(r'^v1(?:$|/)', include(api_urlpatterns)), |
|
49 |
(r'^v1\.0(?:$|/)', include(api_urlpatterns)), |
|
50 |
(r'^public/(?P<v_public>.+?)/?$', |
|
51 |
'pithos.api.public.public_demux'), |
|
52 |
(r'^login/?$', |
|
53 |
'pithos.api.delegate.delegate_to_login_service'), |
|
54 |
(r'^feedback/?$', |
|
55 |
'pithos.api.delegate.delegate_to_feedback_service'), |
|
56 |
) |
|
46 |
urlpatterns = patterns( |
|
47 |
'', |
|
48 |
(r'^v1(?:$|/)', include(api_urlpatterns)), |
|
49 |
(r'^v1\.0(?:$|/)', include(api_urlpatterns)), |
|
50 |
(r'^public/(?P<v_public>.+?)/?$', 'pithos.api.public.public_demux'), |
|
51 |
(r'^login/?$', 'pithos.api.delegate.delegate_to_login_service'), |
|
52 |
(r'^feedback/?$', 'pithos.api.delegate.delegate_to_feedback_service'), |
|
53 |
(r'^account/?$', 'pithos.api.delegate.account_username')) |
Also available in: Unified diff