Skip to content

Commit

Permalink
[Fixes GeoNode#4322]
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed May 30, 2019
1 parent e953e72 commit 8d487b7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ install:
sudo apt-get install -y python-virtualenv python-imaging python-lxml python-pyproj python-shapely python-httplib2 python-httplib2 gettext;
sudo apt-get install -y python-dev libxml2 libxml2-dev libxslt1-dev zlib1g-dev libjpeg-dev libpq-dev libgdal-dev git default-jdk;
sudo apt-add-repository -y ppa:jonathonf/backports;
sudo apt-get -y update && sudo apt-get install -y sqlite3;
sudo apt-get -y update && sudo apt-get install -y sqlite3 spatialite-bin libsqlite3-mod-spatialite;
sudo apt install -y openjdk-8-jre openjdk-8-jdk ant maven;
sudo update-java-alternatives --set java-1.8.0-openjdk-amd64;
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::");
Expand Down
18 changes: 0 additions & 18 deletions geonode/geoserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,24 +1492,6 @@ def ensure_valid_configuration(self, alias):
except KeyError:
raise ServerDoesNotExist("The server %s doesn't exist" % alias)

datastore = server.get('DATASTORE')
uploader_backend = getattr(
settings,
'UPLOADER',
dict()).get(
'BACKEND',
'geonode.rest')

if uploader_backend == 'geonode.importer' and datastore and not settings.DATABASES.get(
datastore):
raise ImproperlyConfigured(
'The OGC_SERVER setting specifies a datastore '
'but no connection parameters are present.')

if uploader_backend == 'geonode.importer' and not datastore:
raise ImproperlyConfigured(
'The UPLOADER BACKEND is set to geonode.importer but no DATASTORE is specified.')

if 'PRINTNG_ENABLED' in server:
raise ImproperlyConfigured("The PRINTNG_ENABLED setting has been removed, use 'PRINT_NG_ENABLED' instead.")

Expand Down
14 changes: 7 additions & 7 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
# see https://docs.djangoproject.com/en/1.8/ref/contrib/gis/db-api/#module-django.contrib.gis.db.backends for
# detailed list of supported backends and notes.
_db_conf = dj_database_url.parse(DATABASE_URL, conn_max_age=600)
_db_conf.update({'TIMEOUT': 60})
if 'spatialite' in DATABASE_URL:
SPATIALITE_LIBRARY_PATH = 'mod_spatialite.so'
DATABASES = {
'default': _db_conf
}
Expand Down Expand Up @@ -549,7 +550,7 @@
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'

# Security stuff
SESSION_EXPIRED_CONTROL_ENABLED = ast.literal_eval(os.environ.get('SESSION_EXPIRED_CONTROL_ENABLED', 'False'))
SESSION_EXPIRED_CONTROL_ENABLED = ast.literal_eval(os.environ.get('SESSION_EXPIRED_CONTROL_ENABLED', 'True'))

if SESSION_EXPIRED_CONTROL_ENABLED:
# This middleware checks for ACCESS_TOKEN validity and if expired forces
Expand Down Expand Up @@ -740,13 +741,13 @@
)

GEOSERVER_PUBLIC_PORT = os.getenv(
'GEOSERVER_PUBLIC_PORT', 8000
'GEOSERVER_PUBLIC_PORT', 8080
)

_default_public_location = '{}://{}:{}/gs/'.format(
_default_public_location = '{}://{}:{}/geoserver/'.format(
GEOSERVER_PUBLIC_SCHEMA,
GEOSERVER_PUBLIC_HOST,
GEOSERVER_PUBLIC_PORT) if GEOSERVER_PUBLIC_PORT else '{}://{}/gs/'.format(GEOSERVER_PUBLIC_SCHEMA, GEOSERVER_PUBLIC_HOST)
GEOSERVER_PUBLIC_PORT) if GEOSERVER_PUBLIC_PORT else '{}://{}/geoserver/'.format(GEOSERVER_PUBLIC_SCHEMA, GEOSERVER_PUBLIC_HOST)

GEOSERVER_PUBLIC_LOCATION = os.getenv(
'GEOSERVER_PUBLIC_LOCATION', _default_public_location
Expand Down Expand Up @@ -807,8 +808,7 @@
# Uploader Settings
DATA_UPLOAD_MAX_NUMBER_FIELDS = 100000
UPLOADER = {
'BACKEND': os.getenv('DEFAULT_BACKEND_UPLOADER', 'geonode.rest'),
# 'BACKEND': 'geonode.importer',
'BACKEND': os.getenv('DEFAULT_BACKEND_UPLOADER', 'geonode.importer'),
'OPTIONS': {
'TIME_ENABLED': ast.literal_eval(os.getenv('TIME_ENABLED', 'False')),
'MOSAIC_ENABLED': ast.literal_eval(os.getenv('MOSAIC_ENABLED', 'False')),
Expand Down
19 changes: 10 additions & 9 deletions geonode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,15 +1279,16 @@ def request(self, url, method='GET', data=None, headers={}, stream=False, timeou
valid_uname_pw = base64.b64encode(
b"%s:%s" % (self.username, self.password)).decode("ascii")
headers['Authorization'] = 'Basic {}'.format(valid_uname_pw)
try:
_u = user or get_user_model().objects.get(username=self.username)
access_token = get_or_create_token(_u)
if access_token and not access_token.is_expired():
headers['Authorization'] = 'Bearer %s' % access_token.token
except BaseException:
tb = traceback.format_exc()
logger.debug(tb)
pass
if not connection.cursor().db.vendor in ('sqlite', 'sqlite3', 'spatialite',):
try:
_u = user or get_user_model().objects.get(username=self.username)
access_token = get_or_create_token(_u)
if access_token and not access_token.is_expired():
headers['Authorization'] = 'Bearer %s' % access_token.token
except BaseException:
tb = traceback.format_exc()
logger.debug(tb)
pass

response = None
content = None
Expand Down

0 comments on commit 8d487b7

Please sign in to comment.