Skip to content

Commit

Permalink
[IMP] Moved is_user_authenticated into namespace blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
c8y3 committed Oct 8, 2024
1 parent a9ea4cb commit 10ce2df
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
18 changes: 17 additions & 1 deletion source/app/blueprints/access_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import uuid
from functools import wraps

from flask import Request
from flask import request
from flask import session
from flask import render_template
Expand All @@ -29,17 +30,21 @@
from werkzeug.utils import redirect

from app import TEMPLATE_PATH
from app import app
from app.datamgmt.case.case_db import get_case
from app.datamgmt.manage.manage_access_control_db import user_has_client_access
from app.iris_engine.access_control.utils import ac_fast_check_user_has_case_access
from app.iris_engine.access_control.utils import ac_get_effective_permissions_of_user
from app.models.authorization import Permissions
from app.models.authorization import CaseAccessLevel
from app.util import _local_authentication_process
from app.util import _local_authentication_process
from app.util import _local_authentication_process
from app.util import _oidc_proxy_authentication_process

from app.util import update_current_case
from app.util import log_exception_and_error
from app.util import response_error
from app.util import is_user_authenticated
from app.util import not_authenticated_redirection_url


Expand Down Expand Up @@ -355,3 +360,14 @@ def wrap(*args, **kwargs):
return f(*args, **kwargs)
return wrap
return inner_wrap


def is_user_authenticated(incoming_request: Request):
authentication_mapper = {
"oidc_proxy": _oidc_proxy_authentication_process,
"local": _local_authentication_process,
"ldap": _local_authentication_process,
"oidc": _local_authentication_process,
}

return authentication_mapper.get(app.config.get("AUTHENTICATION_TYPE"))(incoming_request)
2 changes: 1 addition & 1 deletion source/app/blueprints/graphql/graphql_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from graphene_sqlalchemy import SQLAlchemyConnectionField

from app.datamgmt.manage.manage_cases_db import build_filter_case_query
from app.util import is_user_authenticated
from app.blueprints.access_controls import is_user_authenticated
from app.util import response_error

from app.models.authorization import CaseAccessLevel
Expand Down
11 changes: 0 additions & 11 deletions source/app/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,6 @@ def not_authenticated_redirection_url(request_url: str):
return redirection_mapper.get(app.config.get("AUTHENTICATION_TYPE"))()


def is_user_authenticated(incoming_request: Request):
authentication_mapper = {
"oidc_proxy": _oidc_proxy_authentication_process,
"local": _local_authentication_process,
"ldap": _local_authentication_process,
"oidc": _local_authentication_process,
}

return authentication_mapper.get(app.config.get("AUTHENTICATION_TYPE"))(incoming_request)


def is_authentication_local():
return app.config.get("AUTHENTICATION_TYPE") == "local"

Expand Down

0 comments on commit 10ce2df

Please sign in to comment.