Skip to content

Support different OIDC issuer for desktop #246

Closed

Description

@xgroleau

Problem

Both web and desktop clients share one issuer (OC_OIDC_ISSUER) but have different client id and redirect URI.
So the desktop app (which has its own client ID and redirect URI) fails authentication as it uses

Steps to Reproduce

  1. In Authentik, create two apps:
    • web (ID: web, issuer https://auth.domain.com/application/o/opencloud/, redirect regex: ^https:\/\/opencloud\.domain\.com\/.*$)
    • desktop (ID: OpenCloudDesktop, issuer https://auth.domain.com/application/o/opencloud-desktop/, redirect regex: ^http:\/\/(127\.0\.0\.1|localhost).*$)
  2. Set OC_OIDC_ISSUER to the web URL and OC_OIDC_CLIENT_ID=web.
  3. Set OC_OIDC_ISSUER=https://auth.domain.com/application/o/opencloud/.
  4. Launch the desktop app → it still uses the web issuer and client ID, and auth fails.
    • uses https://auth.domain.com/application/o/opencloud/ instead of https://auth.domain.com/application/o/opencloud-desktop/ (expected since there is no way to configure that)

Expected

Add support for per-client overrides (e.g. DESKTOP_OIDC_ISSUER and DESKTOP_OIDC_CLIENT_ID) on the serveer so each app can point to its own OIDC endpoint if possible.

Or allow to specify the issuer directly in the desktop app instead of using the default web one.

Environment

Authentik for OIDC, Caddy reverse proxy, OpenCloud (2.0.2), OpenCloud desktop 1.0.0

Workaroud

As for now, we can simply use WEB_OIDC_CLIENT_ID=OpenCloudDesktop and use only one issuer and support both web and desktop redirect URI. This allows both the web client and desktop client uses the same issuer.

This might be more relevant to the opencloud repo instead of desktop depending on the path to solve the issue

Activity

  1. micbar commented on May 3, 2025

    @micbar
    Member

    Maybe I am getting it wrong, but for me the issuer is auth.domain.com

    From my understanding, the issuer is the server who holds the identity of a user.

    In OIDC, a user should always be identifiable with subject@issuer .

    Why should the issuer change from one application / client to another?

    @butonic @rhafer

  2. rhafer commented on May 5, 2025

    @rhafer
    Member

    Why should the issuer change from one application / client to another?

    That seems to be some specialty of Authentik: goauthentik/authentik#7251
    I don't think there is any good solution to this yes.

  3. mrblumi commented on May 5, 2025

    @mrblumi

    It‘s not only Authentik specific- same goes for Kanidm.

  4. K900 commented on May 7, 2025

    @K900
    Contributor

    In addition to this, the desktop app should really pull the client ID to use from the server as well, as according to the RFC, the client ID is issued by the authorization server and doesn't have a specified format: https://www.rfc-editor.org/rfc/rfc6749#section-2.2

    Meaning a compliant server may not allow setting the client ID to a known string at all, or not allow OpenCloudDesktop as a valid ID.

  5. micbar commented on May 7, 2025

    @micbar
    Member

    In addition to this, the desktop app should really pull the client ID to use from the server as well, as according to the RFC, the client ID is issued by the authorization server and doesn't have a specified format: https://www.rfc-editor.org/rfc/rfc6749#section-2.2

    Meaning a compliant server may not allow setting the client ID to a known string at all, or not allow OpenCloudDesktop as a valid ID.

    Yes. This is called „dynamic client registration“ and works fine with our clients and providers which allow client registration. (Keycloak for example)

    But most of the admins do not want client registration at all. They create specific clients with id and secret to only allow managed devices.

  6. maxkratz commented on May 11, 2025

    @maxkratz

    Workaroud

    As for now, we can simply use WEB_OIDC_CLIENT_ID=OpenCloudDesktop and use only one issuer and support both web and desktop redirect URI. This allows both the web client and desktop client uses the same issuer.

    This might be more relevant to the opencloud repo instead of desktop depending on the path to solve the issue

    Thank you for providing this workaround, @xgroleau.

    Interestingly, the iOS app works correctly with the default setup described in https://docs.opencloud.eu/docs/admin/configuration/authentication-and-user-management/external-idp/.

  7. PinkidG commented on May 12, 2025

    @PinkidG

    Workaroud

    As for now, we can simply use WEB_OIDC_CLIENT_ID=OpenCloudDesktop and use only one issuer and support both web and desktop redirect URI. This allows both the web client and desktop client uses the same issuer.
    This might be more relevant to the opencloud repo instead of desktop depending on the path to solve the issue

    Thank you for providing this workaround, @xgroleau.

    Interestingly, the iOS app works correctly with the default setup described in https://docs.opencloud.eu/docs/admin/configuration/authentication-and-user-management/external-idp/.

    Interesting, for me it didn't because of a client id missmatch.

    See opencloud-eu/ios#4

  8. kaivol commented on May 21, 2025

    @kaivol
    Contributor

    Workaroud

    As for now, we can simply use WEB_OIDC_CLIENT_ID=OpenCloudDesktop and use only one issuer and support both web and desktop redirect URI. This allows both the web client and desktop client uses the same issuer.

    This might be more relevant to the opencloud repo instead of desktop depending on the path to solve the issue

    This workaround sadly does not work with kanidm, as client IDs are always lowercased in kanidm.


    Also, I was wondering why different OIDC clients are used for the web app and the native applications at all.
    If I didn't miss anything, they only differ in the redirect URIs, and it is no problem to specify multiple redirect URIs for an OIDC client.

    Using only a single OIDC client would help to reduce the complexity of setting up OIDC in the identity provider.

  9. C8opmBM commented on Jun 5, 2025

    @C8opmBM

    Yes, that would be amazing to combine them as one.
    I'm using Pocket ID oidc and unfortunately the clientID is automatically generated so cannot be changed.
    So at the moment, I can only use one version (either web or desktop or android).

    If there are any other solutions, do share.
    Thanks.

    LE: it seems there is a workaround to edit the client id and secret in pocketID, but somehow the other clients (desktop/android) still don't work.

  10. mosslocker commented on Jun 14, 2025

    @mosslocker

    I am using Zitadel as my OIDC provider, and unfortunately they don't allow you to change your client ID, so I'm stuck using only the web UI. It would be great if we could allow an optional feature, where somehow the desktop & mobile apps retrieve unique per-app client ID's from your Opencloud server configuration.

  11. C8opmBM commented on Jun 14, 2025

    @C8opmBM

    Update, for anyone using pocketID, desktop client also works. See here

  12. micbar commented on Jun 14, 2025

    @micbar
    Member
  13. gcebollero commented on Jul 7, 2025

    @gcebollero

    I'm unable to make it work even with the workaround. My OIDC is Authentik, the same configuration that xgroleau, but OpenCloud Desktop shows "Invalid credentials" and this error appears on OpenCloud Server logs:

    ERR failed to authenticate the request error="failed to verify access token: token has invalid claims: token has invalid issuer" authenticator=oidc client.address=192.168.1.1 line=github.com/opencloud-eu/opencloud/services/proxy/pkg/middleware/oidc_auth.go:198 network.peer.address= network.peer.port= path=/ocs/v2.php/cloud/user service=proxy user_agent="Mozilla/5.0 (Linux) mirall/2.0.0 (OpenCloud, arch-6.15.2-arch1-1 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
    
  14. micbar commented on Jul 8, 2025

    @micbar
    Member

    Invalid issuer means your token does not match the issuer configured in the env variables for opencloud.

  15. gcebollero commented on Jul 9, 2025

    @gcebollero

    Finally, I have been able to make the workaround work, configure both Web & Desktop client to use only the "OpenCloudDesktop" ClientID.

    Would be great to implement xgroleau proposal to been able to have more than one issuer using env vars.

  16. 39 remaining items

  17. kevinreniers commented on Jul 19, 2026

    @kevinreniers

    Even when/if the desktop client gets updated to support extracting the appropriate client_id from webfinger, as long as client-specific URLs aren't supported it still won't really work well with something like kanidm. Is this going to be supported?

  18. guruz commented on Jul 22, 2026

    @guruz
    Contributor

    FYI #847 was just merged (thanks @kaivol / @TheOneRing )

  19. TheOneRing commented on Jul 22, 2026

    @TheOneRing
    Contributor
  20. pat-s commented on Jul 22, 2026

    @pat-s

    Ah, I think I misunderstood the previous state. Cool to see something moving (finally)! Will try it out but apparently it already works according to the posts from others.

  21. alvaroemtnez commented on Jul 23, 2026

    @alvaroemtnez

    For Zitadel users: until this is released (i tried to use the appimage generated by github actions and it doesnt work, it asks for the openvfs binary which is not yet supported AFAIK), here's a simple proxy that you add to zitadel, that highjacks /oauth/v2/authorize, /oauth/v2/token and /oauth/v2/keys, so that when it detects that the client ID is OpenCloudDesktop, rewrites it to the Zitadel client ID and proxies it to the API. And also, it changes the response back to the original ID (OpenCloudDesktop) so that the desktop client doesnt complain.

    Anything with a client ID different than OpenCloudDesktop is proxied normally to the zitadel API so that other apps don't break.

    https://github.com/alvaroemtnez/opencloud-zitadel-api-proxy

    It's completely vibe-coded but it works great for me. Don't blame me if things horribly break though :)

    Edit: I must say I only tested it with the Linux appimage at the moment

    Edit 2: Many thanks to the devs for solving this! :)

  22. stratself commented on Aug 25, 2026

    @stratself

    Hi, does #847 actually solves the problem of having multiple issuer URLs for different platforms? I don't think it does so, and therefore still wouldn't work with Kanidm and Authentik properly.

    I have also found opencloud-eu/opencloud#2072 to be relevant. Thanks for any updates.

  23. guruz commented on Aug 26, 2026

    @guruz
    Contributor

    Hi, does #847 actually solves the problem of having multiple issuer URLs for different platforms? I don't think it does so, and therefore still wouldn't work with Kanidm and Authentik properly.

    I recommend looking for an issue for this in opencloud repo, not desktop repo. The right people will hopefully see it there.
    https://github.com/opencloud-eu/opencloud/

    FYI, someone on the Matrix chat mentioned this one, maybe it helps: https://github.com/2bros-group/opencloud-oidc-webfinger-proxy

  24. kaivol commented on Aug 27, 2026

    @kaivol
    Contributor

    Hi, does #847 actually solves the problem of having multiple issuer URLs for different platforms? I don't think it does so, and therefore still wouldn't work with Kanidm and Authentik properly.

    First, you really don't need different issuers for different platforms.

    What exactly does not work for you?
    I use OpenCloud without any problems with Kanidm and various platforms (web, desktop, Android). Note that the current version of the desktop client does not yet include #847, you would need to build it yourself.

  25. MannixTT commented on Aug 28, 2026

    @MannixTT

    Hi, does #847 actually solves the problem of having multiple issuer URLs for different platforms? I don't think it does so, and therefore still wouldn't work with Kanidm and Authentik properly.

    I have also found opencloud-eu/opencloud#2072 to be relevant. Thanks for any updates.

    Since the variables already exist at the OpenCloud level, but the desktop client can't process them, I'd say it will work after that.
    The web and mobile versions (Android app) already work for me, since the WebFinger parameters can already be used there.

  26. stratself commented on Aug 29, 2026

    @stratself

    First, you really don't need different issuers for different platforms.

    What exactly does not work for you?

    I would like to use different client IDs against Kanidm, rather than having them sharing a single client ID as it introduces this weakening aspect. However, Kanidm specifies each client ID to use its own separate issuer URL, and I've since learned that this problem is shared with some other IDPs including Authentik. So you can't use different IDs and have a single OC_ISSUER_URL in this particular integration. How did you configure your Kanidm-Opencloud integration, and did you successfully use multiple client IDs?

    I've tried the opencloud-oidc-webfinger-proxy thing, but it doesn't seem to work against my Kanidm instance. Therefore, I've attempted this approach to hardcode some webfinger responses via my Caddy reverse proxy:

    Details
    # environment variables
    OC_ISSUER_URL=https://idp.example.com/oauth2/openid/opencloud-web
    WEBFINGER_WEB_OIDC_CLIENT_ID=opencloud-web
    WEBFINGER_ANDROID_OIDC_CLIENT_ID=opencloud-android
    WEBFINGER_IOS_OIDC_CLIENT_ID=opencloud-ios
    WEBFINGER_DESKTOP_OIDC_CLIENT_ID=opencloud-desktop

    Caddyfile:

    https://cloud.example.com {
        
        reverse_proxy {
            to http://opencloud:9200
        }
    
    
        # Rewrite webfingers
        @webfinger {
            path /.well-known/webfinger
            query resource=*
        }
    
        handle @webfinger {
    
            # set proper cache-control headers
            header Cache-Control `no-cache, no-store, max-age=0, must-revalidate, value`
            
            # match webfinger requests where ?platform=android
            @opencloud-android {   
                query platform=android
            }
            # respond with custom JSON
            handle @opencloud-android {
                respond <<JSON
                    {
                        "subject": "https://cloud.example.com",
                        "properties": {
                            "http://opencloud.eu/ns/oidc/client_id": "opencloud-android",
                            "http://opencloud.eu/ns/oidc/scopes": [ "openid profile email offline_access" ]
                        },
                        "links": [
                            {
                            "rel": "http://openid.net/specs/connect/1.0/issuer",
                            "href": "https://idp.example.com/oauth2/openid/opencloud-android"
                            }
                        ]
                    }
                JSON
            }
            # continue for other platforms (desktop and ios)
            # if handle conditions aren't matched, the request is reverse proxied to opencloud
            # therefore, the web platform isn't needed as it uses the default OC_ISSUER_URL
        }
    }

    While this breaks the webfinger spec, I hope it can be helpful to someone.

    I recommend looking for an issue for this in opencloud repo, not desktop repo. The right people will hopefully see it there.
    https://github.com/opencloud-eu/opencloud/

    Thanks, I'll poke around a bit more and consider opening an issue there.

  27. kaivol commented on Aug 30, 2026

    @kaivol
    Contributor

    I would like to use different client IDs against Kanidm, rather than having them sharing a single client ID as it introduces this weakening aspect.

    I believe you misunderstand what the Kanidm docs is saying there: With application they mean the whole service, not individual (web/desktop/mobile) clients for a single service. In OAuth terms, a client is An application making protected resource requests on behalf of the resource owner and with its authorization (RFC 6749).

    In the documentation it says

    By sharing a client ID between multiple applications this implies that all of these applications are a singular client in Kanidm’s view. This means tokens issued to one application can be reused on any other application.

    This limits your ability to enforce scopes, presents a large compromise blast radius if a token is stolen, and also increases the damage radius if the client credentials are stolen.

    Say, for example you share a client ID between OpenCloud and another Service X. If the latter is compromised, an attacker can use the OAuth tokens provided to Service X to access a user's OpenCloud data.
    Note that this does not apply do different OpenCloud clients: If an attacker steals a token for the mobile client they can already access all files of a user. It doesn't matter if they can also do it using the desktop client (if they want to, the attacker can also simply change the Client ID of their desktop client to make it appear like a mobile client to the server).

    Friendly ping to @Firstyear, maye they could clarify on this?

  28. guruz commented on Aug 31, 2026

    @guruz
    Contributor

    FYI #847 was just merged (thanks @kaivol / @TheOneRing )

    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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions