Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions source/app/blueprints/pages/login/login_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,33 @@ def oidc_authorise():
if usergroup_field is not None and not user_group:
return response_error("Required user group information missing in OIDC response", 403)
if user_group:
groups_list = get_groups_list()
group_name_to_id = {
group.group_name: group.group_id for group in groups_list
}

group_id_set = {g.group_id for g in groups_list}

if not userroles_mapping_field:
groups_list = get_groups_list()
group_name_to_id = {
group.group_name: group.group_id for group in groups_list
}
new_user_group = [
group_name_to_id[group_name]
for group_name in user_group
if group_name in group_name_to_id
]
else:
group_name_to_id = json.loads(userroles_mapping_field)
new_user_group = [group_name_to_id[group_name] for group_name in user_group if group_name in group_name_to_id]
roles_to_group = json.loads(userroles_mapping_field)
new_user_group = []
for role_name in user_group:
if role_name not in roles_to_group:
continue
mapped_group = roles_to_group[role_name]
try:
group_id = int(mapped_group)
if group_id in group_id_set:
new_user_group.append(group_id)
except (ValueError, TypeError):
if mapped_group in group_name_to_id:
new_user_group.append(group_name_to_id[mapped_group])
if not new_user_group:
return response_error("User role not in IRIS", 403)
update_user_groups(user.id, new_user_group)
Expand Down
2 changes: 1 addition & 1 deletion source/app/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def _parse_float(value):

class Config:
# Handled by bumpversion
IRIS_VERSION = "v2.5.0-beta.1-dev-pr8" # DO NOT EDIT THIS LINE MANUALLY
IRIS_VERSION = "v2.5.0-beta.1-dev-pr9" # DO NOT EDIT THIS LINE MANUALLY

if os.environ.get('IRIS_DEMO_VERSION') is not None and os.environ.get('IRIS_DEMO_VERSION') != 'None':
IRIS_VERSION = os.environ.get('IRIS_DEMO_VERSION')
Expand Down
2 changes: 1 addition & 1 deletion source/app/iris_engine/utils/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def track_activity(message, caseid=None, ctx_less=False, user_input=False, displ
ua.activity_date = datetime.utcnow()
ua.activity_desc = message.capitalize()

if iris_current_user.is_authenticated:
if iris_current_user and iris_current_user.is_authenticated:
logger.info(f"{iris_current_user.user} [#{iris_current_user.id}] :: Case {caseid} :: {ua.activity_desc}")
else:
logger.info(f"Anonymous :: Case {caseid} :: {ua.activity_desc}")
Expand Down
3 changes: 3 additions & 0 deletions source/app/post_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,9 @@ def run(self):

self._logger.info('Running DB migration')

db.session.close()
db.engine.dispose()

alembic_cfg = Config(file_='app/alembic.ini')
alembic_cfg.set_main_option('sqlalchemy.url', self._configuration['SQLALCHEMY_DATABASE_URI'])
command.upgrade(alembic_cfg, 'head')
Expand Down
Loading