Skip to content

Feat/mobile auth - #779

Merged
jbpenrath merged 2 commits into
developmentfrom
feat/mobile-auth
Aug 12, 2026
Merged

Feat/mobile auth#779
jbpenrath merged 2 commits into
developmentfrom
feat/mobile-auth

Conversation

@jbpenrath

@jbpenrath jbpenrath commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Purpose

Adapt auth workflow for mobile flow

Summary by CodeRabbit

  • New Features

    • Improved mobile sign-in with a handoff page that automatically opens the app and provides a manual fallback link.
    • Added configurable mobile authentication callback schemes.
    • Added complete mobile logout through the identity provider, including return-to-app handling.
  • Bug Fixes

    • Prevented authentication redirects from being blocked by identity-provider security policies.
    • Ensured logout ends both server and identity-provider sessions, requiring authentication on the next sign-in.
  • Documentation

    • Updated mobile authentication and release checklist guidance for the revised logout behavior.

@jbpenrath jbpenrath self-assigned this Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8332787f-d8a1-4727-99ac-d4f425ae8207

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Mobile login now uses a non-cacheable HTML handoff before opening the app. Native logout now performs IdP logout, clears the server session, and uses configurable callback schemes. Backend tests cover callback state, scheme validation, and stale handoff data.

Changes

Mobile authentication flows

Layer / File(s) Summary
Mobile login handoff
src/backend/core/authentication/views.py, src/backend/core/templates/core/mobile_handoff.html, src/backend/core/tests/authentication/test_mobile_auth.py, docs/mobile.md
Mobile login callbacks render a non-cacheable handoff page with automatic and manual deep-link navigation. Tests validate the HTML link and cache policy.
RP-initiated mobile logout
src/backend/core/authentication/views.py, src/backend/core/authentication/urls.py, src/backend/core/api/viewsets/mobile_auth.py, src/backend/core/tests/authentication/test_logout.py, src/backend/core/tests/authentication/test_mobile_auth.py, docs/mobile.md
Mobile logout validates callback schemes, stores logout state, handles valid OIDC callbacks, rejects invalid state, and falls back to local session cleanup. Documentation and release checks describe the new logout behavior.
Native logout and callback scheme configuration
src/frontend/src/features/native/auth.ts, src/frontend/src/features/native/sso-invariants.test.ts
Native logout opens browser-based IdP logout before server cleanup. The callback scheme uses MOBILE_AUTH_SCHEME, with matching iOS and Android fallback validation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: sylvinus

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change as mobile authentication updates.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jbpenrath

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/mobile.md`:
- Around line 112-124: Update the later “Logout keeps the IdP session alive”
section to describe RP-initiated browser logout through OIDCLogoutView as the
nominal mobile flow, and identify /mobile/auth/logout/ with MobileLogoutView as
the local-session fallback. Remove the outdated claim that nativeLogout() skips
/logout/ and that IdP logout is only a follow-up.

In `@Makefile`:
- Around line 787-792: Replace the git commit-count default in Makefile’s
MOBILE_VERSION_CODE definition with a required CI-managed persistent
per-application release sequence, failing release builds when it is unset while
preserving explicit overrides. Update docs/env.md at the documented
environment-variable entry to remove the commit-count monotonicity claim and
describe the required persistent source.

In `@src/backend/core/templates/core/mobile_handoff.html`:
- Line 10: Update the root <html> element in the mobile handoff template to
include lang="fr", preserving the existing document structure.

In `@src/frontend/android/app/build.gradle`:
- Around line 15-20: Update the signing configuration setup around signingValue
and hasSigningConfig to resolve and require all four signing values—keystore
path, store password, key alias, and key password—before treating signing as
configured. Keep release signing unattached for partial credentials, and update
the release guard to report the specific missing signing keys rather than only
detecting a missing keystore path.

In `@src/frontend/src/features/native/auth.ts`:
- Around line 103-107: Update the logout request flow in the try block to store
the fetch response, validate response.ok, and throw when the server returns a
non-2xx status before clearing local cookies or reloading. Preserve the existing
warning/error path so failed logout responses do not report successful
completion.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 349cb1a6-8f44-455e-8d7a-5c12833f5042

📥 Commits

Reviewing files that changed from the base of the PR and between a489100 and 4dcb866.

📒 Files selected for processing (23)
  • Makefile
  • deploy/env/frontend.defaults
  • docs/env.md
  • docs/mobile.md
  • src/backend/core/api/viewsets/mobile_auth.py
  • src/backend/core/authentication/urls.py
  • src/backend/core/authentication/views.py
  • src/backend/core/templates/core/mobile_handoff.html
  • src/backend/core/tests/authentication/test_logout.py
  • src/backend/core/tests/authentication/test_mobile_auth.py
  • src/frontend/android/.gitignore
  • src/frontend/android/app/build.gradle
  • src/frontend/android/app/src/main/AndroidManifest.xml
  • src/frontend/android/app/src/main/res/values/strings.xml
  • src/frontend/capacitor.config.ts
  • src/frontend/ios/.gitignore
  • src/frontend/ios/App/App.xcodeproj/project.pbxproj
  • src/frontend/ios/App/App/Info.plist
  • src/frontend/scripts/generate-ios-xcconfig.mjs
  • src/frontend/src/features/native/auth.ts
  • src/frontend/src/features/native/sso-invariants.test.ts
  • src/frontend/src/vite-env.d.ts
  • src/frontend/vite.config.ts

Comment thread docs/mobile.md
Comment thread Makefile Outdated
Comment thread src/backend/core/templates/core/mobile_handoff.html
Comment thread src/frontend/android/app/build.gradle Outdated
Comment thread src/frontend/src/features/native/auth.ts
@jbpenrath

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/backend/core/authentication/views.py`:
- Around line 203-207: Bind the mobile logout marker to the generated OIDC
logout state in the flow that stores MOBILE_LOGOUT_SESSION_KEY, preserving the
scheme and timestamp. In the callback logic consuming MOBILE_LOGOUT_SESSION_KEY,
pop and use it only when the callback state matches the stored state, rather
than for any valid oidc_states entry. Add a regression test covering an earlier
valid web state followed by a later mobile logout state, ensuring the mobile
callback redirects to its scheme logout URL.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1999d85a-828e-41b4-8c50-2ea9eb73750d

📥 Commits

Reviewing files that changed from the base of the PR and between 4dcb866 and 9adf176.

📒 Files selected for processing (3)
  • docs/mobile.md
  • src/backend/core/authentication/views.py
  • src/backend/core/tests/authentication/test_logout.py

Comment thread src/backend/core/authentication/views.py
A staging and a production build must be installable side by side on one
device, and two apps claiming the same OIDC deep-link scheme would make
Android ask the user which one receives the login callback, mid-flow. The
app id, the displayed name and the callback scheme therefore become
per-environment (MOBILE_APP_ID / MOBILE_APP_NAME / MOBILE_AUTH_SCHEME).
ProConnect ignores prompt=login, so preserving the IdP session locked
mobile users into the same identity forever. The logout endpoint now
accepts a mobile_scheme and ends the RP-initiated round-trip on a new
logout-callback view that deep-links back to the app, so the system
browser — which holds both the Django session handed over at login and
the IdP SSO cookie — terminates both sessions.
Then, Proconnect login page's Content Security Policy blocks
the direct redirect: Chrome enforces its form-action on the whole
redirect chain of the credential form submission, and "*" only matches
network schemes — so our network mobile scheme violates it and the user
stays stuck on the identity provider during logout workflow.
The callback now serves a page that ends the form chain on a
network mobile scheme, then hands off to the app from our own page,
outside the IdP policy: automatically via script (iOS
interception, unchanged) with a button as the always-working fallback.
@jbpenrath
jbpenrath merged commit 3b888a3 into development Aug 12, 2026
12 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 13, 2026
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.

1 participant