[PM-29885] Implement SSO cookie vending authentication flow#6522
[PM-29885] Implement SSO cookie vending authentication flow#6522SaintPatrck wants to merge 3 commits intomainfrom
Conversation
|
New Issues (4)Checkmarx found the following issues in this Pull Request
|
...tlin/com/x8bit/bitwarden/data/platform/manager/util/CookieConfigurationDataExtensionsTest.kt
Dismissed
Show dismissed
Hide dismissed
...tlin/com/x8bit/bitwarden/data/platform/manager/util/CookieConfigurationDataExtensionsTest.kt
Dismissed
Show dismissed
Hide dismissed
...tlin/com/x8bit/bitwarden/data/platform/manager/util/CookieConfigurationDataExtensionsTest.kt
Dismissed
Show dismissed
Hide dismissed
...tlin/com/x8bit/bitwarden/data/platform/manager/util/CookieConfigurationDataExtensionsTest.kt
Dismissed
Show dismissed
Hide dismissed
|
Claude finished @SaintPatrck's task in 5m 56s —— View job Code Review: PM-29885 SSO Cookie Vending Authentication Flow
Review complete. Inline comments have been posted on the PR for specific findings. Overall the implementation follows Bitwarden's architectural patterns well — proper interface/impl separation, clean UDF integration via |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6522 +/- ##
==========================================
- Coverage 86.38% 86.31% -0.07%
==========================================
Files 777 797 +20
Lines 56175 56629 +454
Branches 8170 8192 +22
==========================================
+ Hits 48527 48882 +355
- Misses 4804 4895 +91
- Partials 2844 2852 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add cookie interceptor that manages ELB session cookies for enterprise SSO configurations. The interceptor attaches stored cookies to API requests, preempts requests when cookie bootstrap is needed, and detects HTTP 302 redirects to trigger cookie re-acquisition via an identity provider. Key components: - CookieInterceptor for OkHttp request/response cookie handling - NetworkCookieManager for bootstrap detection and cookie storage - CookieRedirectException to signal cookie acquisition flow - CookieProvider interface bridging network and app layers Co-Authored-By: Claude <noreply@anthropic.com>
5087f55 to
0dc2bc5
Compare
This commit updates the `RetrofitsTest` to ensure that the `CookieInterceptor` is consistently called across all Retrofit client configurations. Previously, the tests for `api`, `identity`, `events`, and `notifications` clients did not verify the presence of the cookie interceptor. This change adds an assertion (`assertTrue(isCookieInterceptorCalled)`) to each relevant test case to confirm that the interceptor is included in the chain.
...rc/main/kotlin/com/x8bit/bitwarden/data/platform/manager/network/NetworkCookieManagerImpl.kt
Outdated
Show resolved
Hide resolved
| // Return the response if it is not a redirect or does not contain | ||
| // a Location header. | ||
| val location = response.header(HEADER_LOCATION) | ||
| if (response.code != HTTP_REDIRECT || location == null) { |
There was a problem hiding this comment.
Should this be an &&?
There was a problem hiding this comment.
Hm. Now that I think about it, we shouldn't need this location check. We should technically already have the IdP login URL saved. Could have swore I saw that in the spec somewhere. 🤔
Let me double check with the other teams and make sure we actually need to check and capture this.
Thanks for calling attention to this.
| baseUrlsProvider = bitwardenServiceClientConfig.baseUrlsProvider, | ||
| ), | ||
| cookieInterceptor = CookieInterceptor( | ||
| cookieProvider = bitwardenServiceClientConfig.cookieProvider, |
There was a problem hiding this comment.
Minor but can you just reference the cookieProvider property from above


🎟️ 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:
CookieheaderKey components:
CookieInterceptor— OkHttp interceptor for request/response cookie handlingNetworkCookieManager/NetworkCookieManagerImpl— Bootstrap detection and cookie storage bridgeCookieRedirectException— Signal exception to trigger cookie acquisition flowCookieProvider— Interface bridging the network and app layers