Revision 83204389 snf-common/synnefo/lib/astakos.py
b/snf-common/synnefo/lib/astakos.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
import logging |
|
35 |
|
|
34 | 36 |
from time import time, mktime |
35 | 37 |
from urlparse import urlparse |
36 | 38 |
from urllib import quote, unquote |
... | ... | |
40 | 42 |
|
41 | 43 |
from synnefo.lib.pool.http import get_http_connection |
42 | 44 |
|
45 |
logger = logging.getLogger(__name__) |
|
43 | 46 |
|
44 | 47 |
def authenticate(token, authentication_url='http://127.0.0.1:8000/im/authenticate'): |
45 | 48 |
p = urlparse(authentication_url) |
... | ... | |
63 | 66 |
|
64 | 67 |
if status < 200 or status >= 300: |
65 | 68 |
raise Exception(data, status) |
66 |
|
|
69 |
|
|
67 | 70 |
return json.loads(data) |
68 | 71 |
|
69 | 72 |
def user_for_token(token, authentication_url, override_users): |
... | ... | |
95 | 98 |
if not user: |
96 | 99 |
user = user_for_token(fallback_token, authentication_url, override_users) |
97 | 100 |
if not user: |
101 |
logger.warning("Cannot retrieve user details from %s", |
|
102 |
authentication_url) |
|
98 | 103 |
return |
99 | 104 |
|
105 |
# use user uuid, instead of email, keep email/username reference to user_id |
|
106 |
request.user_uniq = user['uuid'] |
|
100 | 107 |
request.user = user |
101 |
request.user_uniq = user['uniq'] |
|
108 |
request.user_id = user['username'] |
|
109 |
return user |
|
102 | 110 |
|
103 | 111 |
|
104 | 112 |
def get_token_from_cookie(request, cookiename): |
Also available in: Unified diff