Skip to content

Commit 8c31a20

Browse files
committed
✨ Update authentication check endpoint and improve documentation
1 parent 4aef8a2 commit 8c31a20

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

api/specs/web-server/_auth.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,15 @@ async def logout(_body: LogoutBody):
153153

154154
@router.get(
155155
"/auth:check",
156-
operation_id="check_authentication",
157156
status_code=status.HTTP_204_NO_CONTENT,
158157
responses={
159158
status.HTTP_401_UNAUTHORIZED: {
160159
"model": EnvelopedError,
161-
"description": "unauthorized reset due to invalid token code",
162160
}
163161
},
164162
)
165163
async def check_auth():
166-
"""checks if user is authenticated in the platform"""
164+
"""checks whether user request is authenticated"""
167165

168166

169167
@router.post(

services/web/server/src/simcore_service_webserver/login/_controller/rest/auth.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,18 @@ async def logout(request: web.Request) -> web.Response:
289289
return response
290290

291291

292-
@routes.get(f"/{API_VTAG}/auth:check", name="check_authentication")
292+
@routes.get(f"/{API_VTAG}/auth:check", name="check_auth")
293293
@login_required
294294
async def check_auth(request: web.Request) -> web.Response:
295-
# lightweight endpoint for checking if users are authenticated
296-
# used primarily by Traefik auth middleware to verify session cookies
295+
"""Lightweight endpoint for checking if users are authenticated & authorized to this product
297296
297+
Used primarily by Traefik auth middleware to verify session cookies
298+
SEE https://doc.traefik.io/traefik/middlewares/http/forwardauth
299+
"""
298300
# NOTE: for future development
299301
# if database access is added here, services like jupyter-math
300302
# which load a lot of resources will have a big performance hit
301303
# consider caching some properties required by this endpoint or rely on Redis
302-
303304
assert request # nosec
304305

305306
return web.json_response(status=status.HTTP_204_NO_CONTENT)

services/web/server/tests/unit/with_dbs/03/login/test_login_auth.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
async def test_check_auth(client: TestClient, logged_user: UserInfoDict):
4242
assert client.app
4343

44+
url = client.app.router["check_auth"].url_for()
45+
assert url.path == "/v0/auth:check"
46+
4447
response = await client.get("/v0/auth:check")
4548
await assert_status(response, status.HTTP_204_NO_CONTENT)
4649

0 commit comments

Comments
 (0)