Skip to content

[#5] add auth status view of current user#28

Merged
sergei-maertens merged 1 commit intomainfrom
feature/5-authentication-endpoint
Feb 20, 2026
Merged

[#5] add auth status view of current user#28
sergei-maertens merged 1 commit intomainfrom
feature/5-authentication-endpoint

Conversation

@SonnyBA
Copy link
Copy Markdown
Contributor

@SonnyBA SonnyBA commented Feb 12, 2026

Partly closes open-formulieren/admin-ui#2

Adds a simple view which front-end clients can interact with to retrieve the current user's authentication status.

Required for #5 (which is needed for this admin-ui issue). This new view will be used in OF to provide the front-end with the necessary data.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7e468e1) to head (4ea96d4).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #28   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        15    +2     
  Lines          237       248   +11     
  Branches        19        20    +1     
=========================================
+ Hits           237       248   +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread maykin_2fa/api/views.py Outdated
return JsonResponse(
{
"auth_status": {
"authenticated": request.user.is_authenticated,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we wanted to allow anonymous users to access this endpoint but if we don't we can remove this field and return an 401 response instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure either, why shouldn't we allow them?Can you think of a specific situation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is mentioned anywhere in the tickets but I recall during discussing this endpoint that it might be expanded on later, with extra information related to authenticated users. You could argue that that information won't be relevant for unauthenticated users and just return the 401 response.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, not sure about it..maybe we should ask for an extra opinion from Robin or Anna who have a better overview?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robinmolen as you're going to be working with this endpoint, do you have any thoughts/preferences about this?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhh yeah we discussed possible expansions for this endpoint last thursday, but not sure if and when this would happen. I think I'm in favor of returning 401 when the user isn't logged in. Then, when the user is logged in, we return 200 with the MFA verified flag.

401 will make the OF admin-ui a bit simpler, and might be a more generic (Maykin-wide) expected behaviour.

@SonnyBA
Copy link
Copy Markdown
Contributor Author

SonnyBA commented Feb 13, 2026

I was look into the X-SESSION-EXPIRES-IN header but it turns out this is something OF specific. We could incorporate it into this library if other projects will also use it.

@SonnyBA SonnyBA marked this pull request as ready for review February 13, 2026 10:08
@SonnyBA SonnyBA requested a review from vaszig February 13, 2026 10:09
@SonnyBA SonnyBA self-assigned this Feb 13, 2026
Comment thread maykin_2fa/api/views.py Outdated
return JsonResponse(
{
"auth_status": {
"authenticated": request.user.is_authenticated,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure either, why shouldn't we allow them?Can you think of a specific situation?

Comment thread maykin_2fa/api/views.py Outdated
@SonnyBA SonnyBA force-pushed the feature/5-authentication-endpoint branch from 5f185d3 to 3a2cb6e Compare February 16, 2026 11:30
@SonnyBA SonnyBA requested a review from vaszig February 16, 2026 11:44
@SonnyBA SonnyBA force-pushed the feature/5-authentication-endpoint branch from 3a2cb6e to c51570f Compare February 16, 2026 15:05
Copy link
Copy Markdown
Member

@sergei-maertens sergei-maertens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also include a default maykin_2fa.api.urls so that all individual projects don't need to invent the endpoint? We can then also hardcode the (relative) URL in the frontend code.

Comment thread maykin_2fa/api/views.py Outdated
Comment thread maykin_2fa/api/views.py Outdated
Comment thread maykin_2fa/api/views.py
Comment thread tests/test_endpoints.py Outdated
Comment thread tests/test_user_info_endpoint.py
@SonnyBA SonnyBA force-pushed the feature/5-authentication-endpoint branch 2 times, most recently from db24ef8 to 59a9ec3 Compare February 19, 2026 11:14
Comment thread maykin_2fa/api/urls.py Outdated
Comment thread docs/reference.rst Outdated
Comment thread docs/reference.rst
Comment thread maykin_2fa/urls.py Outdated
@SonnyBA SonnyBA force-pushed the feature/5-authentication-endpoint branch from 59a9ec3 to cd61fa1 Compare February 20, 2026 10:24
@SonnyBA SonnyBA force-pushed the feature/5-authentication-endpoint branch from cd61fa1 to 4ea96d4 Compare February 20, 2026 10:49
@sergei-maertens sergei-maertens merged commit 73ec91c into main Feb 20, 2026
13 checks passed
@sergei-maertens sergei-maertens deleted the feature/5-authentication-endpoint branch February 20, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check authentication status & redirect user to login page if necessary

4 participants