Skip to content

Deny login early when offline and force_provider_authentication set#1356

Merged
adombeck merged 4 commits intomainfrom
UDENG-9481-fail-early
Apr 8, 2026
Merged

Deny login early when offline and force_provider_authentication set#1356
adombeck merged 4 commits intomainfrom
UDENG-9481-fail-early

Conversation

@adombeck
Copy link
Copy Markdown
Contributor

When the session is offline and force_provider_authentication is set, we still used to ask the user for the local password, and only when the correct local password was entered we returned an error.

Let's improve UX by failing early in that case, before asking for a password. Also improves the error message a bit.

UDENG-9481

adombeck added 4 commits April 8, 2026 10:35
The error message from `err` can be quite long, making it hard to
distinguish where it ends:

    Could not connect to the provider: Get "https://login.microsoftonline.com/03c73201-ef9e-4182-ae04-0adb51f4a0b6/v2.0/.well-known/openid-configuration": dial tcp: lookup login.microsoftonline.com on 127.0.0.53:53: server misbehaving. Starting session in offline mode.

Let's move the "starting session in offline mode" part before the error
message to make it more visible and to make clear that it does not
belong the message of the connection error.
When the session is offline and force_provider_authentication is set, we
still used to ask the user for the local password, and only when the
correct local password was entered we returned an error.

Let's improve UX by failing early in that case, before asking for a
password. Also improves the error message a bit.

Note that, if sshd is configured to allow login with authd, this leaks
the information if the host can reach the provider or not to anyone try
to connect via SSH. However, that is already the case, since users can
"go back" and check if device authentication is offered or not.

This breaks
TestIsAuthenticated/Error_when_provider_authentication_is_forced_and_session_is_offline,
so we remove it, but we add a new test case to TestNewSession in the
next commit.
Avoid prepending unhelpful information to the error message displayed to
the user.

The old message was:

    could not create new session for user "test@ubudev1.onmicrosoft.com": Error connecting to provider. Check your network connection.

The new message is:

    Error connecting to provider. Check your network connection.

In the one other case where this function returns an error, we now
prepend the error with a description.
@adombeck adombeck force-pushed the UDENG-9481-fail-early branch from aba524e to f3cac77 Compare April 8, 2026 08:48
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.00%. Comparing base (1590501) to head (f3cac77).
⚠️ Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
authd-oidc-brokers/internal/broker/broker.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1356      +/-   ##
==========================================
- Coverage   86.44%   80.00%   -6.45%     
==========================================
  Files          99       20      -79     
  Lines        6690      990    -5700     
  Branches      111        0     -111     
==========================================
- Hits         5783      792    -4991     
+ Misses        851      198     -653     
+ 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.

@adombeck adombeck marked this pull request as ready for review April 8, 2026 14:33
@adombeck adombeck merged commit 70591f9 into main Apr 8, 2026
21 of 28 checks passed
@adombeck adombeck deleted the UDENG-9481-fail-early branch April 8, 2026 15:57
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.

2 participants