mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-10 03:54:06 +00:00
Adds option to grant web user read-only DB access
Introduces a command-line flag to grant read-only access to the web user for all tables, improving ease of permissions management during refresh operations.
This commit is contained in:
@@ -119,6 +119,7 @@ class NominatimArgs:
|
|||||||
enable_debug_statements: bool
|
enable_debug_statements: bool
|
||||||
data_object: Sequence[Tuple[str, int]]
|
data_object: Sequence[Tuple[str, int]]
|
||||||
data_area: Sequence[Tuple[str, int]]
|
data_area: Sequence[Tuple[str, int]]
|
||||||
|
ro_access: bool
|
||||||
|
|
||||||
# Arguments to 'replication'
|
# Arguments to 'replication'
|
||||||
init: bool
|
init: bool
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ class UpdateRefresh:
|
|||||||
help='Update secondary importance raster data')
|
help='Update secondary importance raster data')
|
||||||
group.add_argument('--importance', action='store_true',
|
group.add_argument('--importance', action='store_true',
|
||||||
help='Recompute place importances (expensive!)')
|
help='Recompute place importances (expensive!)')
|
||||||
|
group.add_argument('--ro-access', action='store_true',
|
||||||
|
help='Grant read-only access to web user for all tables')
|
||||||
group.add_argument('--website', action='store_true',
|
group.add_argument('--website', action='store_true',
|
||||||
help='DEPRECATED. This function has no function anymore'
|
help='DEPRECATED. This function has no function anymore'
|
||||||
' and will be removed in a future version.')
|
' and will be removed in a future version.')
|
||||||
@@ -159,6 +161,11 @@ class UpdateRefresh:
|
|||||||
LOG.error('WARNING: Website setup is no longer required. '
|
LOG.error('WARNING: Website setup is no longer required. '
|
||||||
'This function will be removed in future version of Nominatim.')
|
'This function will be removed in future version of Nominatim.')
|
||||||
|
|
||||||
|
if args.ro_access:
|
||||||
|
from ..tools import admin
|
||||||
|
LOG.warning('Grant read-only access to web user')
|
||||||
|
admin.grant_ro_access(args.config.get_libpq_dsn(), args.config)
|
||||||
|
|
||||||
if args.data_object or args.data_area:
|
if args.data_object or args.data_area:
|
||||||
with connect(args.config.get_libpq_dsn()) as conn:
|
with connect(args.config.get_libpq_dsn()) as conn:
|
||||||
for obj in args.data_object or []:
|
for obj in args.data_object or []:
|
||||||
|
|||||||
Reference in New Issue
Block a user