Add missing login.logout endpoint

This commit is contained in:
allegroai 2021-05-11 16:12:27 +03:00
parent 8ebc334889
commit 9beefa7473
3 changed files with 23 additions and 6 deletions

View File

@ -93,3 +93,19 @@ supported_modes {
}
}
}
logout {
authorize: false
allow_roles = [ "*" ]
"2.13" {
description: """ Logout (including SSO, if used)) """
request {
type: object
additionalProperties: false
}
response {
type: object
additionalProperties: false
}
}
}

View File

@ -41,14 +41,12 @@ def login(call: APICall, *_, **__):
)
# Add authorization cookie
call.result.cookies[
config.get("apiserver.auth.session_auth_cookie_name")
] = call.result.data_model.token
call.result.set_auth_cookie(call.result.data_model.token)
@endpoint("auth.logout", min_version="2.2")
def logout(call: APICall, *_, **__):
call.result.cookies[config.get("apiserver.auth.session_auth_cookie_name")] = None
call.result.set_auth_cookie(None)
@endpoint(

View File

@ -1,5 +1,3 @@
from jsonmodels.fields import BoolField
from apiserver.apimodels.login import (
GetSupportedModesRequest,
GetSupportedModesResponse,
@ -35,3 +33,8 @@ def supported_modes(call: APICall, _, __: GetSupportedModesRequest):
),
authenticated=call.auth is not None,
)
@endpoint("login.logout", min_version="2.13")
def logout(call: APICall, _, __):
call.result.set_auth_cookie(None)