[PR #6522] [MERGED] [PM-29885] Implement SSO cookie vending authentication flow #26021

Closed
opened 2026-04-17 01:34:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/6522
Author: @SaintPatrck
Created: 2/11/2026
Status: Merged
Merged: 2/17/2026
Merged by: @SaintPatrck

Base: mainHead: cookie-vending/p9-t9_cookie-interceptor


📝 Commits (5)

  • 9a31c9e [PM-29885] Implement SSO cookie vending authentication flow
  • d71ead8 Updated RetrofitsTest to verify cookie interceptor usage
  • 9e7350e Make bootstrapType the subject of when
  • c421c14 Refactored CookieRedirectException and CookieInterceptor
  • 6235626 Use network interceptor for cookies

📊 Changes

18 files changed (+840 additions, -0 deletions)

View changed files

📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/datasource/network/di/PlatformNetworkModule.kt (+3 -0)
📝 app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/di/PlatformManagerModule.kt (+14 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManager.kt (+8 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManagerImpl.kt (+56 -0)
app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/util/CookieConfigurationDataExtensions.kt (+20 -0)
app/src/test/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManagerTest.kt (+214 -0)
app/src/test/kotlin/com/x8bit/bitwarden/data/platform/manager/util/CookieConfigurationDataExtensionsTest.kt (+71 -0)
📝 authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/network/di/PlatformNetworkModule.kt (+9 -0)
📝 network/src/main/kotlin/com/bitwarden/network/BitwardenServiceClient.kt (+6 -0)
📝 network/src/main/kotlin/com/bitwarden/network/BitwardenServiceClientImpl.kt (+7 -0)
network/src/main/kotlin/com/bitwarden/network/exception/CookieRedirectException.kt (+16 -0)
network/src/main/kotlin/com/bitwarden/network/interceptor/CookieInterceptor.kt (+93 -0)
📝 network/src/main/kotlin/com/bitwarden/network/model/BitwardenServiceClientConfig.kt (+2 -0)
network/src/main/kotlin/com/bitwarden/network/model/NetworkCookie.kt (+12 -0)
network/src/main/kotlin/com/bitwarden/network/provider/CookieProvider.kt (+42 -0)
📝 network/src/main/kotlin/com/bitwarden/network/retrofit/RetrofitsImpl.kt (+3 -0)
network/src/test/kotlin/com/bitwarden/network/interceptor/CookieInterceptorTest.kt (+251 -0)
📝 network/src/test/kotlin/com/bitwarden/network/retrofit/RetrofitsTest.kt (+13 -0)

📄 Description

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-29885

📔 Objective

Add cookie interceptor support for enterprise SSO configurations that require ELB session cookies. The interceptor manages the full cookie lifecycle for API requests behind a load balancer:

  • Preemptive bootstrap: Detects when cookies are needed but not yet available and triggers acquisition before making a doomed request
  • Cookie attachment: Attaches stored cookies to outgoing API requests via the Cookie header
  • Redirect detection: Catches HTTP 302 responses indicating expired/missing cookies and triggers re-acquisition via the identity provider
  • Connection safety: Properly closes OkHttp responses before throwing to prevent connection pool exhaustion

Key components:

  • CookieInterceptor — OkHttp interceptor for request/response cookie handling
  • NetworkCookieManager / NetworkCookieManagerImpl — Bootstrap detection and cookie storage bridge
  • CookieRedirectException — Signal exception to trigger cookie acquisition flow
  • CookieProvider — Interface bridging the network and app layers

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/6522 **Author:** [@SaintPatrck](https://github.com/SaintPatrck) **Created:** 2/11/2026 **Status:** ✅ Merged **Merged:** 2/17/2026 **Merged by:** [@SaintPatrck](https://github.com/SaintPatrck) **Base:** `main` ← **Head:** `cookie-vending/p9-t9_cookie-interceptor` --- ### 📝 Commits (5) - [`9a31c9e`](https://github.com/bitwarden/android/commit/9a31c9eafb5fa095e759985afa26b9168c5d708d) [PM-29885] Implement SSO cookie vending authentication flow - [`d71ead8`](https://github.com/bitwarden/android/commit/d71ead8c2dc41a917661aa0e9aa76ba67c367453) Updated RetrofitsTest to verify cookie interceptor usage - [`9e7350e`](https://github.com/bitwarden/android/commit/9e7350e221cc0d9044ef9463553c8b483b53ba04) Make bootstrapType the subject of when - [`c421c14`](https://github.com/bitwarden/android/commit/c421c14a74c1fecff283173ecce1a3d9cbeab631) Refactored CookieRedirectException and CookieInterceptor - [`6235626`](https://github.com/bitwarden/android/commit/6235626a7c0baeddc8d490247629d0bb2158ac83) Use network interceptor for cookies ### 📊 Changes **18 files changed** (+840 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/datasource/network/di/PlatformNetworkModule.kt` (+3 -0) 📝 `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/di/PlatformManagerModule.kt` (+14 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManager.kt` (+8 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManagerImpl.kt` (+56 -0) ➕ `app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/util/CookieConfigurationDataExtensions.kt` (+20 -0) ➕ `app/src/test/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManagerTest.kt` (+214 -0) ➕ `app/src/test/kotlin/com/x8bit/bitwarden/data/platform/manager/util/CookieConfigurationDataExtensionsTest.kt` (+71 -0) 📝 `authenticator/src/main/kotlin/com/bitwarden/authenticator/data/platform/datasource/network/di/PlatformNetworkModule.kt` (+9 -0) 📝 `network/src/main/kotlin/com/bitwarden/network/BitwardenServiceClient.kt` (+6 -0) 📝 `network/src/main/kotlin/com/bitwarden/network/BitwardenServiceClientImpl.kt` (+7 -0) ➕ `network/src/main/kotlin/com/bitwarden/network/exception/CookieRedirectException.kt` (+16 -0) ➕ `network/src/main/kotlin/com/bitwarden/network/interceptor/CookieInterceptor.kt` (+93 -0) 📝 `network/src/main/kotlin/com/bitwarden/network/model/BitwardenServiceClientConfig.kt` (+2 -0) ➕ `network/src/main/kotlin/com/bitwarden/network/model/NetworkCookie.kt` (+12 -0) ➕ `network/src/main/kotlin/com/bitwarden/network/provider/CookieProvider.kt` (+42 -0) 📝 `network/src/main/kotlin/com/bitwarden/network/retrofit/RetrofitsImpl.kt` (+3 -0) ➕ `network/src/test/kotlin/com/bitwarden/network/interceptor/CookieInterceptorTest.kt` (+251 -0) 📝 `network/src/test/kotlin/com/bitwarden/network/retrofit/RetrofitsTest.kt` (+13 -0) </details> ### 📄 Description ## 🎟️ Tracking https://bitwarden.atlassian.net/browse/PM-29885 ## 📔 Objective Add cookie interceptor support for enterprise SSO configurations that require ELB session cookies. The interceptor manages the full cookie lifecycle for API requests behind a load balancer: - **Preemptive bootstrap**: Detects when cookies are needed but not yet available and triggers acquisition before making a doomed request - **Cookie attachment**: Attaches stored cookies to outgoing API requests via the `Cookie` header - **Redirect detection**: Catches HTTP 302 responses indicating expired/missing cookies and triggers re-acquisition via the identity provider - **Connection safety**: Properly closes OkHttp responses before throwing to prevent connection pool exhaustion Key components: - `CookieInterceptor` — OkHttp interceptor for request/response cookie handling - `NetworkCookieManager` / `NetworkCookieManagerImpl` — Bootstrap detection and cookie storage bridge - `CookieRedirectException` — Signal exception to trigger cookie acquisition flow - `CookieProvider` — Interface bridging the network and app layers --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 01:34:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#26021