authentik icon indicating copy to clipboard operation
authentik copied to clipboard

Front-channel OIDC logout triggers duplicate SessionEndStage POSTs and NoneType exception

Open seh-len opened this issue 4 months ago • 2 comments

Describe the bug

With an OIDC provider configured for front-channel logout, logging out from Grafana succeeds on the Grafana side, but authentik's provider invalidation flow ends with:

'NoneType' object has no attribute 'status_code'

File "/authentik/flows/views/executor.py", line 349, in post
File "/authentik/flows/views/executor.py", line 554, in to_stage_response

SessionEndStage.challenge_valid() returns:

return self.executor.cancel()

However, FlowExecutor.cancel() has no return value. It therefore returns None, which is passed to to_stage_response(). That function then accesses source.status_code.

The reason for the additional POST requests still needs investigation, but the server-side exception is caused by SessionEndStage.challenge_valid() not returning an HttpResponse.

Configuration

  • Invalidation flow: default-provider-invalidation-flow
  • Logout method: Front-channel
  • Logout URI: https://grafana.example.com/logout
  • Grafana sign-out redirect: https://authentik.example.com/application/o/grafana/end-session/

How to reproduce

  1. Log in to Grafana through authentik.
  2. Click Logout in Grafana.
  3. Grafana successfully terminates the user session.
  4. authentik invokes Grafana's /logout through the front-channel iframe.
  5. The iframe logout stage advances, but additional POST requests subsequently reach the flow executor and trigger the exception.

Expected behavior

The provider logout flow should finish without an exception. A late or duplicate POST should not cause a server-side error.

Screenshots

No response

Additional context

No response

Deployment Method

Docker

Version

2026.5.5

Relevant log output

server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"/application/o/grafana/end-session/","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.asgi","method":"GET","pid":"[PID_1]","remote":"[CLIENT_IP]","request_id":"[REQUEST_ID_1]","runtime":105,"schema_name":"public","scheme":"https","status":302,"timestamp":"2026-07-17T13:42:29.727462","user":"[USER]","user_agent":"[BROWSER_USER_AGENT]"}
server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"/if/flow/default-provider-invalidation-flow/?inspector=available","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.asgi","method":"GET","pid":"[PID_1]","remote":"[CLIENT_IP]","request_id":"[REQUEST_ID_2]","runtime":44,"schema_name":"public","scheme":"https","status":200,"timestamp":"2026-07-17T13:42:29.971702","user":"[USER]","user_agent":"[BROWSER_USER_AGENT]"}
server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"/api/v3/flows/executor/default-provider-invalidation-flow/?query=inspector%3Davailable","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.asgi","method":"GET","pid":"[PID_1]","remote":"[CLIENT_IP]","request_id":"[REQUEST_ID_3]","runtime":41,"schema_name":"public","scheme":"https","status":200,"timestamp":"2026-07-17T13:42:33.182164","user":"[USER]","user_agent":"[BROWSER_USER_AGENT]"}
server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"/api/v3/flows/executor/default-provider-invalidation-flow/?query=inspector%3Davailable","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.asgi","method":"GET","pid":"[PID_1]","remote":"[CLIENT_IP]","request_id":"[REQUEST_ID_4]","runtime":41,"schema_name":"public","scheme":"https","status":200,"timestamp":"2026-07-17T13:42:34.140688","user":"[USER]","user_agent":"[BROWSER_USER_AGENT]"}
server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"/api/v3/flows/executor/default-provider-invalidation-flow/?query=inspector%3Davailable","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.asgi","method":"POST","pid":"[PID_1]","remote":"[CLIENT_IP]","request_id":"[REQUEST_ID_5]","runtime":29,"schema_name":"public","scheme":"https","status":302,"timestamp":"2026-07-17T13:42:34.436353","user":"[USER]","user_agent":"[BROWSER_USER_AGENT]"}
server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"/api/v3/flows/executor/default-provider-invalidation-flow/?query=inspector%3Davailable","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.asgi","method":"GET","pid":"[PID_1]","remote":"[CLIENT_IP]","request_id":"[REQUEST_ID_6]","runtime":105,"schema_name":"public","scheme":"https","status":200,"timestamp":"2026-07-17T13:42:34.634428","user":"[USER]","user_agent":"[BROWSER_USER_AGENT]"}
server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"AttributeError(\"'NoneType' object has no attribute 'status_code'\")","flow_slug":"default-provider-invalidation-flow","host":"[AUTHENTIK_HOST]","level":"warning","logger":"authentik.flows.views.executor","pid":"[PID_2]","request_id":"[REQUEST_ID_7]","schema_name":"public","timestamp":"2026-07-17T13:42:34.697668"}
server-1 | {"action":"system_exception","auth_via":"session","client_ip":"[CLIENT_IP]","context":{"exception":[{"exc_notes":[],"exc_type":"AttributeError","exc_value":"'NoneType' object has no attribute 'status_code'","exceptions":[],"frames":[{"filename":"/authentik/flows/views/executor.py","lineno":349,"name":"post"},{"filename":"/authentik/flows/views/executor.py","lineno":554,"name":"to_stage_response"}],"is_cause":false,"is_group":false,"syntax_error":null}],"http_request":{"args":{"inspector":"available"},"method":"POST","path":"/api/v3/flows/executor/default-provider-invalidation-flow/","request_id":"[REQUEST_ID_7]","user_agent":"[BROWSER_USER_AGENT]"},"message":"System exception during flow execution."},"domain_url":"[AUTHENTIK_HOST]","event":"Created Event","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.events.models","pid":"[PID_2]","request_id":"[REQUEST_ID_7]","schema_name":"public","timestamp":"2026-07-17T13:42:34.703024","user":{"email":"[USER_EMAIL]","pk":"[USER_PK]","username":"[USER]"}}
server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"AttributeError(\"'NoneType' object has no attribute 'status_code'\")","flow_slug":"default-provider-invalidation-flow","host":"[AUTHENTIK_HOST]","level":"warning","logger":"authentik.flows.views.executor","pid":"[PID_1]","request_id":"[REQUEST_ID_8]","schema_name":"public","timestamp":"2026-07-17T13:42:34.705599"}
server-1 | {"action":"system_exception","auth_via":"session","client_ip":"[CLIENT_IP]","context":{"exception":[{"exc_notes":[],"exc_type":"AttributeError","exc_value":"'NoneType' object has no attribute 'status_code'","exceptions":[],"frames":[{"filename":"/authentik/flows/views/executor.py","lineno":349,"name":"post"},{"filename":"/authentik/flows/views/executor.py","lineno":554,"name":"to_stage_response"}],"is_cause":false,"is_group":false,"syntax_error":null}],"http_request":{"args":{"inspector":"available"},"method":"POST","path":"/api/v3/flows/executor/default-provider-invalidation-flow/","request_id":"[REQUEST_ID_8]","user_agent":"[BROWSER_USER_AGENT]"},"message":"System exception during flow execution."},"domain_url":"[AUTHENTIK_HOST]","event":"Created Event","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.events.models","pid":"[PID_1]","request_id":"[REQUEST_ID_8]","schema_name":"public","timestamp":"2026-07-17T13:42:34.714888","user":{"email":"[USER_EMAIL]","pk":"[USER_PK]","username":"[USER]"}}
server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"/api/v3/flows/executor/default-provider-invalidation-flow/?query=inspector%3Davailable","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.asgi","method":"POST","pid":"[PID_2]","remote":"[CLIENT_IP]","request_id":"[REQUEST_ID_7]","runtime":69,"schema_name":"public","scheme":"https","status":200,"timestamp":"2026-07-17T13:42:34.738266","user":"[USER]","user_agent":"[BROWSER_USER_AGENT]"}
server-1 | {"auth_via":"session","domain_url":"[AUTHENTIK_HOST]","event":"/api/v3/flows/executor/default-provider-invalidation-flow/?query=inspector%3Davailable","host":"[AUTHENTIK_HOST]","level":"info","logger":"authentik.asgi","method":"POST","pid":"[PID_1]","remote":"[CLIENT_IP]","request_id":"[REQUEST_ID_8]","runtime":84,"schema_name":"public","scheme":"https","status":200,"timestamp":"2026-07-17T13:42:34.753629","user":"[USER]","user_agent":"[BROWSER_USER_AGENT]"}

seh-len avatar Jul 17 '26 14:07 seh-len

Can you please re-test on 2026.5.6 and report back?

dewi-tik avatar Jul 23 '26 16:07 dewi-tik

Can you please re-test on 2026.5.6 and report back?

In 2026.5.6, it works as expected, thanks!

seh-len avatar Jul 23 '26 17:07 seh-len