Skip to content

Commit

Permalink
- [Minor fix] Proxy will attach access_token only if remote netloc m…
Browse files Browse the repository at this point in the history
…atches the local one
  • Loading branch information
afabiani committed May 8, 2019
1 parent 2c9915a commit 99c548e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
32 changes: 17 additions & 15 deletions geonode/proxy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,27 @@ def get_headers(request, url, raw_url):
headers["Content-Type"] = request.META["CONTENT_TYPE"]

access_token = None
# we give precedence to obtained from Aithorization headers
if 'HTTP_AUTHORIZATION' in request.META:
auth_header = request.META.get(
'HTTP_AUTHORIZATION',
request.META.get('HTTP_AUTHORIZATION2'))
if auth_header:
access_token = get_token_from_auth_header(auth_header)
# otherwise we check if a session is active
elif request and request.user.is_authenticated:
access_token = get_token_object_from_session(request.session)

# we extend the token in case the session is active but the token expired
if access_token and access_token.is_expired():
extend_token(access_token)

site_url = urlsplit(settings.SITEURL)
if site_url.netloc == url.netloc:
# we give precedence to obtained from Aithorization headers
if 'HTTP_AUTHORIZATION' in request.META:
auth_header = request.META.get(
'HTTP_AUTHORIZATION',
request.META.get('HTTP_AUTHORIZATION2'))
if auth_header:
access_token = get_token_from_auth_header(auth_header)
# otherwise we check if a session is active
elif request and request.user.is_authenticated:
access_token = get_token_object_from_session(request.session)

# we extend the token in case the session is active but the token expired
if access_token and access_token.is_expired():
extend_token(access_token)

if access_token:
headers['Authorization'] = 'Bearer %s' % access_token

site_url = urlsplit(settings.SITEURL)
pragma = "no-cache"
referer = request.META[
"HTTP_REFERER"] if "HTTP_REFERER" in request.META else \
Expand Down
2 changes: 1 addition & 1 deletion geonode/static/geonode/js/upload/LayerInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ define(function (require, exports) {
type: this.type.name,
format: this.type.format,
time: time_enabled,
mosaic: mosaic_enabled
mosaic: mosaic_enabled
});
file_queue.append(li);
this.errors = this.collectErrors();
Expand Down

0 comments on commit 99c548e

Please sign in to comment.