Skip to content

fix: allow logins for token refresh failures due to unstable connections#1383

Open
nooreldeenmansour wants to merge 1 commit intomainfrom
allow-logins-unstable-connections
Open

fix: allow logins for token refresh failures due to unstable connections#1383
nooreldeenmansour wants to merge 1 commit intomainfrom
allow-logins-unstable-connections

Conversation

@nooreldeenmansour
Copy link
Copy Markdown
Member

@nooreldeenmansour nooreldeenmansour commented Apr 2, 2026

Closes #998

UDENG-9464

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses intermittent unlock/login failures when an OIDC token refresh times out on unstable connections by allowing password-based authentication to fall back to cached/offline authentication (unless provider authentication is explicitly forced), matching the behavior users see when fully offline.

Changes:

  • Add fallback-to-cached authentication when password auth token refresh fails with a non-protocol (intended: network) error and provider auth isn’t forced.
  • Add/adjust TestIsAuthenticated cases to cover the fallback path and the forced-provider-auth timeout path.
  • Add golden outputs and generic cached token/password fixtures for the new test scenarios.

Reviewed changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
authd-oidc-brokers/internal/broker/broker.go Implements fallback to cached authentication on token refresh failures intended to represent unstable network conditions.
authd-oidc-brokers/internal/broker/broker_test.go Updates TestIsAuthenticated table to add fallback scenario and keep a forced-provider-auth timeout denial scenario.
authd-oidc-brokers/internal/broker/testdata/golden/TestIsAuthenticated/Authenticating_with_password_falls_back_to_cached_on_token_refresh_network_error/first_call Golden output for the new “fallback to cached” scenario.
authd-oidc-brokers/internal/broker/testdata/golden/TestIsAuthenticated/Authenticating_with_password_falls_back_to_cached_on_token_refresh_network_error/data/provider_url/test-user@email.com/token.json Generic token fixture for the new test scenario.
authd-oidc-brokers/internal/broker/testdata/golden/TestIsAuthenticated/Authenticating_with_password_falls_back_to_cached_on_token_refresh_network_error/data/provider_url/test-user@email.com/password Generic password fixture for the new test scenario.
authd-oidc-brokers/internal/broker/testdata/golden/TestIsAuthenticated/Error_when_mode_is_password_and_token_refresh_times_out_with_forced_provider_auth/first_call Golden output for forced-provider-auth refresh timeout denial.
authd-oidc-brokers/internal/broker/testdata/golden/TestIsAuthenticated/Error_when_mode_is_password_and_token_refresh_times_out_with_forced_provider_auth/data/provider_url/test-user@email.com/token.json Generic token fixture for forced-provider-auth timeout scenario.
authd-oidc-brokers/internal/broker/testdata/golden/TestIsAuthenticated/Error_when_mode_is_password_and_token_refresh_times_out_with_forced_provider_auth/data/provider_url/test-user@email.com/password Generic password fixture for forced-provider-auth timeout scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.18%. Comparing base (7624c01) to head (bc99294).

Files with missing lines Patch % Lines
authd-oidc-brokers/internal/broker/broker.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1383      +/-   ##
==========================================
- Coverage   86.32%   80.18%   -6.15%     
==========================================
  Files          99       20      -79     
  Lines        6690      989    -5701     
  Branches      111        0     -111     
==========================================
- Hits         5775      793    -4982     
+ Misses        859      196     -663     
+ Partials       56        0      -56     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nooreldeenmansour nooreldeenmansour force-pushed the allow-logins-unstable-connections branch from 754b580 to fd7fc34 Compare April 2, 2026 17:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 8 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nooreldeenmansour nooreldeenmansour force-pushed the allow-logins-unstable-connections branch 3 times, most recently from bc864f8 to 36dff11 Compare April 2, 2026 18:59
@nooreldeenmansour nooreldeenmansour force-pushed the allow-logins-unstable-connections branch from 36dff11 to bc99294 Compare April 2, 2026 19:00
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.

Unlocking screen sometimes fails with "authentication failure: could not refresh token" when internet connection is unstable

2 participants