Skip to content

Fixes for OIDC#2411

Open
N00byKing wants to merge 1 commit into
famedly:mainfrom
N00byKing:oidc-fix
Open

Fixes for OIDC#2411
N00byKing wants to merge 1 commit into
famedly:mainfrom
N00byKing:oidc-fix

Conversation

@N00byKing

@N00byKing N00byKing commented Jul 14, 2026

Copy link
Copy Markdown

These changes allow connection to the newly added OIDC support in Continuwuity.
I tested the change by building FluffyChat, which worked (After setting the oidc flag).

Currently, login fails because:

  • OIDC-only logins make the sdk throw an exception
    • First patch modifies the logic so that the exception only occurs if both legacy and oidc login are unavailable
  • Continuwuity returns code 200 on successful registration, but 201 is expected by the sdk
    • Continuwuity is not standard-conformant here and 201 is correct. I've submitted a patch there to fix the return code.
    • Since this is not really an error, for stability I modified the logic to allow 200 as well
  • Continuwuity will reject oidc registration for loopback addresses if a port is specified. (See code snippet from continuwuity)
    • I'm not sure which is standard conformant here. The standard only says that "The authorization server MUST allow any port to be specified at the time of the request", i.e. at authorization, but not registration.

The third patch may or may not be correct here, I'm really not sure. Let me know what you think.

NOTE: I've never written dart code, extra scrutiny is appreciated

EDIT: Patch 1 and 2 superseded by #2412

@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches OIDC client registration and alters registered redirect URIs relative to what the app may use at authorization time, which could break redirect matching if the server enforces exact URI equality.

Overview
registerOidcClient now sends port-stripped redirect URIs for native apps using http on loopback hosts (localhost, 127.0.0.1, [::1]), while validation still uses the caller’s original URIs.

Loopback host names are hoisted to a shared loopbackHosts constant (replacing the inline allowedHosts in the native branch). The registration JSON uses a derived registrationRedirectUris list instead of redirectUris directly, documented as a workaround for homeservers that reject loopback registrations when a port is present.

Reviewed by Cursor Bugbot for commit f34f894. Bugbot is set up for automated code reviews on this repo. Configure here.

@CLAassistant

CLAassistant commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 12f89ab. Configure here.

);
}
return uri;
}).toList();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Registration auth redirect mismatch

Medium Severity

registerOidcClient posts loopback native redirect_uris with ports removed, while the documented OIDC flow still uses the original redirectUri (including port) in authorization and token requests. Servers that validate redirect_uri by exact match to registered values may reject login after successful registration.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 12f89ab. Configure here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is intended. At registration, no port is specified, and at authorization all ports MUST be accepted

Port is only specified at authorization

Signed-off-by: Yussur Mustafa Oraji <N00byKing@hotmail.de>
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 59.64%. Comparing base (53a6a79) to head (f34f894).

Files with missing lines Patch % Lines
...ion/msc_2966_oidc_dynamic_client_registration.dart 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2411      +/-   ##
==========================================
+ Coverage   59.62%   59.64%   +0.02%     
==========================================
  Files         161      161              
  Lines       20329    20342      +13     
==========================================
+ Hits        12121    12134      +13     
  Misses       8208     8208              
Files with missing lines Coverage Δ
...ion/msc_2966_oidc_dynamic_client_registration.dart 75.00% <93.75%> (+4.33%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53a6a79...f34f894. Read the comment docs.

host: uri.host,
path: uri.path,
query: uri.hasQuery ? uri.query : null,
fragment: uri.hasFragment ? uri.fragment : null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So this is just removing the port from the redirectUrl, but is this then still working on for example Linux Desktop? There the port is used to find the application iirc

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I was testing on desktop, so yes :P
The port is still forwarded, but not at registration.
Its still present in the authorization

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.

3 participants