Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return 401 if the circulation token is not present in the header. #47

Merged
merged 1 commit into from
Apr 18, 2024
Merged
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
9 changes: 4 additions & 5 deletions api/ekirjasto_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_tokens(self, authorization, validate_expire=False):
or authorization.token is None
or len(authorization.token) == 0
):
return EKIRJASTO_REMOTE_AUTHENTICATION_FAILED, None, None, None
return INVALID_EKIRJASTO_DELEGATE_TOKEN, None, None, None

token = authorization.token

Expand Down Expand Up @@ -100,6 +100,9 @@ def get_tokens(self, authorization, validate_expire=False):
# for it as it is valdiated with successful authentication.
ekirjasto_token = token

if delegate_token == None:
return INVALID_EKIRJASTO_DELEGATE_TOKEN, None, None, None

return delegate_token, ekirjasto_token, delegate_sub, delegate_expired

@property
Expand Down Expand Up @@ -213,8 +216,6 @@ def get_decrypted_ekirjasto_token(self, request):
) = self.get_tokens(request.authorization, validate_expire=True)
if isinstance(delegate_token, ProblemDetail):
return delegate_token
elif delegate_token == None:
return INVALID_EKIRJASTO_DELEGATE_TOKEN

return Response(
json.dumps({"token": ekirjasto_token}), 200, mimetype="application/json"
Expand All @@ -233,8 +234,6 @@ def call_remote_endpoint(self, remote_path, request):
) = self.get_tokens(request.authorization)
if isinstance(delegate_token, ProblemDetail):
return delegate_token
elif delegate_token == None:
return INVALID_EKIRJASTO_DELEGATE_TOKEN

(
response_json,
Expand Down