Skip to content

Commit

Permalink
BUG: api session: better error message with disabled session storage
Browse files Browse the repository at this point in the history
the error message when the session storage was disabled was misleading
as it suggested wrong credentials, but actually no login is required and
possible.

the intelmq-manager shows a fixed error message and needs a fix as well
  • Loading branch information
Sebastian Wagner committed Aug 25, 2021
1 parent ff1c479 commit ff934b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CHANGELOG

3.0.1 (unreleased)
------------------

- Return a matching error message if the session storage is disabled and therefore a login is not possible (PR#36 by Sebastian Wagner, fixes #35).

3.0.0 (2021-07-07)
------------------
Expand Down
7 changes: 5 additions & 2 deletions intelmq_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,17 @@ def config(response, file: str, fetch: bool=False):

@hug.post("/api/login", versions=1)
def login(username: str, password: str):
if session_store is not None:
if session_store is None:
return {"error": "Session store is disabled by configuration! No login possible and required."}
else:
known = session_store.verify_user(username, password)
if known is not None:
token = session_store.new_session({"username": username})
return {"login_token": token,
"username": username,
}
return "Invalid username and/or password"
else:
return {"error": "Invalid username and/or password."}


@hug.get("/api/harmonization", requires=token_authentication, versions=1)
Expand Down

0 comments on commit ff934b7

Please sign in to comment.