Skip to content

Commit

Permalink
safeguard auth paths
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Feb 3, 2025
1 parent 20b04d8 commit 80a9c30
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion wis2box-management/wis2box/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@

LOGGER = logging.getLogger(__name__)

VALID_PATHS = [
'collections/stations',
'processes/wis2box',
'wis2downloader'
]


def create_token(path: str, token: str) -> bool:
"""
Expand Down Expand Up @@ -160,7 +166,11 @@ def add_token(ctx, metadata_id, path, yes, token):
raise click.ClickException(f'Metadata identifier {metadata_id} not found in data mappings') # noqa
path = metadata_id
elif path is not None:
path = path
if path not in VALID_PATHS:
msg = f'Not a valid path, valid paths are {VALID_PATHS}'
raise click.ClickException(msg)
else:
path = path
else:
raise click.ClickException('Missing path or metadata_id')

Expand Down

0 comments on commit 80a9c30

Please sign in to comment.