Skip to content

Commit

Permalink
[Minor fixes] settings typos and fixoauth mgt commands
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed May 10, 2019
1 parent 1974350 commit 9c53111
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
15 changes: 14 additions & 1 deletion geonode/base/management/commands/fixoauthuri.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,26 @@ class Command(BaseCommand):
"""
can_import_settings = True

def add_arguments(self, parser):
parser.add_argument(
'--target-address',
dest='target_address',
help='Target Address (the one to be changed e.g. http://my-public.geonode.org)')

def handle(self, *args, **options):

target_address = options.get('target_address')

from django.conf import settings
client_id = None
client_secret = None

if check_ogc_backend(geoserver.BACKEND_PACKAGE):
from geonode.geoserver.helpers import ogc_server_settings
redirect_uris = '%s\n%s' % (ogc_server_settings.LOCATION, ogc_server_settings.public_url)
redirect_uris = '%s\n%s\n%s' % (
ogc_server_settings.LOCATION,
ogc_server_settings.public_url,
"http://{}/geoserver/".format(target_address))
if Application.objects.filter(name='GeoServer').exists():
Application.objects.filter(name='GeoServer').update(redirect_uris=redirect_uris)
app = Application.objects.filter(name='GeoServer')[0]
Expand Down
2 changes: 1 addition & 1 deletion geonode/local_settings.py.geoserver.sample
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ if MONITORING_ENABLED:
('geonode.contrib.monitoring.middleware.MonitoringMiddleware',)
MONITORING_CONFIG = None
MONITORING_HOST_NAME = os.getenv("MONITORING_HOST_NAME", HOSTNAME)
MONITORING_SERVICE_NAME = 'geonode'
MONITORING_SERVICE_NAME = os.getenv("MONITORING_SERVICE_NAME", 'local-geonode')


# Documents Thumbnails
Expand Down
2 changes: 1 addition & 1 deletion geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@
# add following lines to your local settings to enable monitoring
MONITORING_ENABLED = ast.literal_eval(os.environ.get('MONITORING_ENABLED', 'False'))
MONITORING_HOST_NAME = os.getenv("MONITORING_HOST_NAME", HOSTNAME)
MONITORING_SERVICE_NAME = os.getenv("MONITORING_SERVICE_NAME", 'local-geoserver')
MONITORING_SERVICE_NAME = os.getenv("MONITORING_SERVICE_NAME", 'local-geonode')

# how long monitoring data should be stored
MONITORING_DATA_TTL = timedelta(days=7)
Expand Down
6 changes: 3 additions & 3 deletions package/support/geonode.updateip
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ client_secret=`echo $oauth_keys | cut -d \, -f 2`
oauth_config="$GEOSERVER_DATA_DIR/security/filter/geonode-oauth2/config.xml"
sed -i "s|<cliendId>.*</cliendId>|<cliendId>$client_id</cliendId>|g" $oauth_config
sed -i "s|<clientSecret>.*</clientSecret>|<clientSecret>$client_secret</clientSecret>|g" $oauth_config
sed -i "s|<accessTokenUri>.*</accessTokenUri>|<accessTokenUri>$NEW_INT_IP/o/token/</accessTokenUri>|g" $oauth_config
sed -i "s|<accessTokenUri>.*</accessTokenUri>|<accessTokenUri>$NEW_EXT_IP/o/token/</accessTokenUri>|g" $oauth_config
sed -i "s|<userAuthorizationUri>.*</userAuthorizationUri>|<userAuthorizationUri>$NEW_EXT_IP/o/authorize/</userAuthorizationUri>|g" $oauth_config
sed -i "s|<redirectUri>.*</redirectUri>|<redirectUri>$NEW_EXT_IP/geoserver/</redirectUri>|g" $oauth_config
sed -i "s|<checkTokenEndpointUrl>.*</checkTokenEndpointUrl>|<checkTokenEndpointUrl>$NEW_INT_IP/api/o/v4/tokeninfo/</checkTokenEndpointUrl>|g" $oauth_config
sed -i "s|<checkTokenEndpointUrl>.*</checkTokenEndpointUrl>|<checkTokenEndpointUrl>$NEW_EXT_IP/api/o/v4/tokeninfo/</checkTokenEndpointUrl>|g" $oauth_config
sed -i "s|<logoutUri>.*</logoutUri>|<logoutUri>$NEW_EXT_IP/account/logout/</logoutUri>|g" $oauth_config

# Updating REST Role Service Config
sed -i "s|<baseUrl>.*</baseUrl>|<baseUrl>$NEW_INT_IP</baseUrl>|g" "$GEOSERVER_DATA_DIR/security/role/geonode REST role service/config.xml"
sed -i "s|<baseUrl>.*</baseUrl>|<baseUrl>$NEW_EXT_IP</baseUrl>|g" "$GEOSERVER_DATA_DIR/security/role/geonode REST role service/config.xml"

# Updating GeoServer Global Config
global_config="$GEOSERVER_DATA_DIR/global.xml"
Expand Down

0 comments on commit 9c53111

Please sign in to comment.