Revision a49baffa snf-pithos-app/pithos/api/login.py
b/snf-pithos-app/pithos/api/login.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
import logging |
35 | 35 |
|
36 |
from urlparse import urlparse |
|
37 |
|
|
36 | 38 |
from django.http import HttpResponseNotFound, HttpResponseRedirect |
37 | 39 |
from django.utils.http import urlencode |
38 |
from django.conf import settings |
|
40 |
|
|
41 |
from pithos.api.settings import AUTHENTICATION_URL, AUTHENTICATION_USERS |
|
39 | 42 |
|
40 | 43 |
|
41 | 44 |
logger = logging.getLogger(__name__) |
42 | 45 |
|
43 | 46 |
|
44 | 47 |
def redirect_to_login_service(request): |
45 |
users = settings.AUTHENTICATION_USERS
|
|
46 |
host = settings.AUTHENTICATION_HOST
|
|
47 |
if users is not None or host is None:
|
|
48 |
url = AUTHENTICATION_URL
|
|
49 |
users = AUTHENTICATION_USERS
|
|
50 |
if users or not url:
|
|
48 | 51 |
return HttpResponseNotFound() |
49 | 52 |
|
53 |
p = urlparse(url) |
|
50 | 54 |
if request.is_secure(): |
51 | 55 |
proto = 'https://' |
52 | 56 |
else: |
... | ... | |
56 | 60 |
renew = 'renew' in request.GET |
57 | 61 |
if renew: |
58 | 62 |
params['renew'] = True |
59 |
uri = proto + host + '/login?' + urlencode(params)
|
|
63 |
uri = proto + p.netloc + '/login?' + urlencode(params)
|
|
60 | 64 |
return HttpResponseRedirect(uri) |
Also available in: Unified diff