Skip to content

Commit

Permalink
Merge pull request #75 from giosava94/no-strict-auth
Browse files Browse the repository at this point in the history
No strict auth
  • Loading branch information
marcvs authored Dec 5, 2023
2 parents 554df1a + 1c83e3e commit 111acc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 8 additions & 1 deletion flaat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,14 @@ def _run_work_flow(self, *args, **kwargs) -> Tuple[tuple, dict]:
# No error, but also do nothing else
return (args, kwargs)

user_infos = self.authenticate_user(*args, **kwargs)
if self.ignore_no_authn:
try:
user_infos = self.authenticate_user(*args, **kwargs)
except FlaatException:
user_infos = None
else:
user_infos = self.authenticate_user(*args, **kwargs)

if user_infos is None:
if self.ignore_no_authn:
# No error, but also do nothing else
Expand Down
7 changes: 6 additions & 1 deletion flaat/flask/flask_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def case_FakeToken(self, path):
headers = {"Authorization": f"Bearer fake_token"}
return path, headers

@parametrize("path", {"/info_no_strict"})
def case_NoBearer(self, path):
headers = None
return path, headers


class Unauthorized:
"""Request should not pass."""
Expand All @@ -35,7 +40,7 @@ def case_FakeToken(self, path):
headers = {"Authorization": f"Bearer fake_token"}
return path, headers

@parametrize("path", example_paths)
@parametrize("path", example_paths - {"/info_no_strict"})
def case_NoBearer(self, path):
headers = None
return path, headers

0 comments on commit 111acc6

Please sign in to comment.