Skip to content

Use webfinger for OIDC parameter discovery - #847

Merged
TheOneRing merged 10 commits into
opencloud-eu:mainfrom
kaivol:use-webfinger-for-oidc-parameter-discovery
Jul 22, 2026
Merged

TheOneRing merged 10 commits into
opencloud-eu:mainfrom
kaivol:use-webfinger-for-oidc-parameter-discovery

Conversation

@kaivol

@kaivol kaivol commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

@kaivol
kaivol force-pushed the use-webfinger-for-oidc-parameter-discovery branch from b345a3c to 063efde Compare April 7, 2026 10:21
@kaivol
kaivol marked this pull request as ready for review April 7, 2026 10:22
@kulmann
kulmann requested a review from dragotin April 28, 2026 07:15
@RichardFevrier

RichardFevrier commented Apr 28, 2026 •

Copy link
Copy Markdown

Did this PR worked for you @kulmann ?

Just tried it without success on my side, when both web + iOS are working perfectly.

I have tested the webfinger with:

curl -L cloud.mydomain.com/.well-known/webfinger?resource=https://cloud.opencloud.test&rel=http://openid.net/specs/connect/1.0/issuer&platform=desktop | jq
  % Total    % Received % Xferd  Average Speed  Time    Time    Time   Current
                                 Dload  Upload  Total   Spent   Left   Speed
  0      0   0      0   0      0      0      0                              0
100    305 100    305   0      0   2324      0                              0
{
  "subject": "https://cloud.opencloud.test",
  "properties": {
    "http://opencloud.eu/ns/oidc/client_id": "OpenCloudDesktop",
    "http://opencloud.eu/ns/oidc/scopes": [
      "openid",
      "profile",
      "email",
      "groups",
      "offline_access"
    ]
  },
  "links": [
    {
      "rel": "http://openid.net/specs/connect/1.0/issuer",
      "href": "https://auth.mydomain.com"
    }
  ]
}

Which returns groups that is mandatory on my setup since Authelia groups binds to OpenCloud roles.

But when the Authelia page appears I can see that groups are not part of the request.

Edit:
debugged it further:

26-04-28 13:38:21:512 [ debug sync.credentials.oauth ]  [ OCC::OAuth::openBrowser ]:    opening browser
26-04-28 13:38:21:512 [ debug sync.credentials.oauth ]  [ isUrlValid ]: Checking URL for validity: QUrl("https://auth.mydomain.com/api/oidc/authorization?response_type=code&client_id=OpenCloudDesktop&redirect_uri=http://127.0.0.1:32979&code_challenge=Kgkj2cHF9MwXPDyTkZETDhc4Pv07hAXBxgSV8DfBhCI&code_challenge_method=S256&scope=openid offline_access email profile&prompt=consent select_account&state=c5bNXSEMgYIazaZ3aMqJjz3mI7SfpbP00YlzmVl-Q2w%3D")
[2] Sandbox: CanCreateUserNamespace() clone() failure: EPERM

You can see that scopes (scope=openid offline_access email profile) doesn't contain groups.

@kaivol
kaivol force-pushed the use-webfinger-for-oidc-parameter-discovery branch from 063efde to 01406ed Compare April 29, 2026 19:03
@kaivol

kaivol commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@RichardFevrier thanks for testing the PR!
I made some changes, so it should work now.

I also bumped the C++ standard version to 23, i hope this is fine.

@RichardFevrier

Copy link
Copy Markdown

Thanks for your work @kaivol I'll test that tomorrow! 🤩

@guruz

guruz commented May 7, 2026

Copy link
Copy Markdown
Contributor

@RichardFevrier Have you tested this PR? :)

@guruz

guruz commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

@kaivol FYI CI ^ says this:

/Users/runner/work/desktop/desktop/src/libsync/creds/oauth.cpp:622:35: error: no member named 'join_with' in namespace 'std::__1::ranges::views'
  622 |                     | std::views::join_with(QStringLiteral(" "))
      |                       ~~~~~~~~~~~~^

Might be related to

I also bumped the C++ standard version to 23, i hope this is fine.

I can't say anything to this topic specifically, if it's easier to keep a lower C++ standard or check if all our platforms would support 23.
CC @TheOneRing

@kaivol
kaivol force-pushed the use-webfinger-for-oidc-parameter-discovery branch from 01406ed to 5e7ecb7 Compare May 7, 2026 19:07
@kaivol

kaivol commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

@guruz Thanks for bringing that up.
I got rid of the join_with call and implemented the logic in a good ol' loop: diff

@guruz

guruz commented May 8, 2026

Copy link
Copy Markdown
Contributor

@kaivol one more failure :) ^

@TheOneRing FYI, i can't seem to be able to ask macos and windows to re-run if linux already failed ^

@kaivol
kaivol force-pushed the use-webfinger-for-oidc-parameter-discovery branch from 5e7ecb7 to e259baa Compare May 8, 2026 17:27
@kaivol

kaivol commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

I'm a little confused, the CI error seems to be in the OpenVFS plugin, not at all related to my changes 😕
A quick look at the CI overview shows that builds are failing for some time already.

@guruz

guruz commented May 9, 2026

Copy link
Copy Markdown
Contributor

@kaivol You're right, sorry!
Could you re-base on current main branch, it should be green now for Linux.
https://github.com/opencloud-eu/desktop/commits/main/

@kaivol
kaivol force-pushed the use-webfinger-for-oidc-parameter-discovery branch from e259baa to dbeb743 Compare May 9, 2026 08:51
@guruz

guruz commented May 9, 2026

Copy link
Copy Markdown
Contributor

^ OAuth test fails

@kaivol
kaivol force-pushed the use-webfinger-for-oidc-parameter-discovery branch from a83044a to b7e4712 Compare May 9, 2026 18:22
@kaivol

kaivol commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

Okay, I adjusted the OAuth test and added a response for the .well-known/webfinger request.

Let me know if you agree with the changes.

KaroUniform pushed a commit to KaroUniform/desktop that referenced this pull request May 26, 2026
Override openIdConnectScopes() in OpenCloudTheme to include the
"groups" scope alongside the default openid/offline_access/email/profile
set.

IDPs that scope-gate their group claim (Authelia, Keycloak and Authentik
in default config) only emit it when the corresponding scope is requested
in the authorization request. Without it, server-side role mapping via
PROXY_ROLE_ASSIGNMENT_OIDC_CLAIM=groups fails with "no roles in user
claims" and login dies on the post-OAuth user-info step with "Failed to
get user info from server".

Stopgap until opencloud-eu#847 (webfinger-based OIDC parameter discovery) lands
upstream. Refs opencloud-eu#217.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@guruz

guruz commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

I can confirm this PR works, I'm logged in a test server with a different client_id and additional scopes.

I'll post my review comments later, it's only small stuff I think.

Thank you for the PR @kaivol

By the way I see this in log:

26-06-06 11:18:37:232 [ warning sync.credentials.manager ]:	set "OpenCloud_credentials:(REMOVED).opencloud.rocks:f6fc19c6-aad5-43ba-a244-191f75967795:http/oauthtoken" has not yet finished. duration(0h, 3min, 45s, 491ms)

@guruz

This comment was marked as off-topic.

@maskimfr

maskimfr commented Jul 1, 2026

Copy link
Copy Markdown

Compiled and tested it with authelia, it's working well. groups are now requested by the client.

Comment thread src/libsync/creds/oauth.cpp Outdated
if (flag & defaultOauthPromtValue())
_supportedPromtValues |= flag;
}
this->_scopes = scopesJoined;

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.

QStringList scopes; scopes.join(QStringLiteral(" "));

Comment thread src/libsync/creds/oauth.cpp Outdated
const QString contentTypeHeader = webfingerReply->header(QNetworkRequest::ContentTypeHeader).toString();
if (!contentTypeHeader.contains(QStringLiteral("application/json"), Qt::CaseInsensitive)) {
qCWarning(lcOauth) << u"server sent invalid content type:" << contentTypeHeader;
handleError(QNetworkReply::NoError, QStringLiteral("WebFinger response had unexpected content type: %1").arg(contentTypeHeader) );

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.

While apparently the errors string is currently unused, those errors should probably be translatable.
so pleas euse the 'tr' macro tr("WebFinger response had unexpected content type: %1").arg(contentTypeHeader) for the error messages

@ember-ana

Copy link
Copy Markdown

tested this on 7.3.0 with authentik as IdP and it worked great :)
is there any help needed on this? would love to not have to teach friends how to use KDE Craft :D

@kaivol

kaivol commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@ember-ana thanks for the feedback!
I made the changes requested by @TheOneRing, however I still need to fix failing tests.

@kaivol
kaivol force-pushed the use-webfinger-for-oidc-parameter-discovery branch from b625d9f to ff446eb Compare July 21, 2026 17:11
kaivol pushed a commit to kaivol/opencloud-desktop that referenced this pull request Jul 21, 2026
@kaivol
kaivol force-pushed the use-webfinger-for-oidc-parameter-discovery branch from ff446eb to 43ebe68 Compare July 21, 2026 20:17
@TheOneRing

Copy link
Copy Markdown
Contributor

Thank you for your contribution, and many thanks for your patience. Any changes to the authentication flows give me a headache.

@TheOneRing
TheOneRing merged commit 396b62b into opencloud-eu:main Jul 22, 2026
3 of 12 checks passed
TheOneRing pushed a commit that referenced this pull request Jul 22, 2026
@openclouders openclouders mentioned this pull request Jul 22, 2026
1 task
@guruz

guruz commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Hi all, Testing of pre-release with webfinger client_id/scope support would be appreciated.
It's installable seperately from the main version, so there should be no collision.
https://github.com/opencloud-eu/desktop/releases/tag/v4.0.0-rc.1

@saw-jan saw-jan mentioned this pull request Sep 2, 2026
9 tasks done
@elafarge

elafarge commented Sep 2, 2026

Copy link
Copy Markdown

Hi all, Testing of pre-release with webfinger client_id/scope support would be appreciated. It's installable seperately from the main version, so there should be no collision. https://github.com/opencloud-eu/desktop/releases/tag/v4.0.0-rc.1

Hey @guruz . I stumbled upon the problem today (OpenCloud 7.4.0 on the server side & Authelia as an OIDC provider). By "the problem" I mean the fact that OpenCloud desktop could not authenticate because it seems the groups claim wasn't requested accordingly from authelia by opencloud-desktop.

I switched to 4.0.0-rc.1 and I can confirm that it does indeed fix the issue, I'm now able to login with opencloud-desktop 🙌 Thank you so much for the "fix" @kaivol 🙌 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use webfinger for OIDC parameter discovery

7 participants