-
Notifications
You must be signed in to change notification settings - Fork 158
feat: support desktop and mobile specific OIDC issuer and client_id
#2072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,9 @@ import ( | |
| ) | ||
|
|
||
| const ( | ||
| OpenIDConnectRel = "http://openid.net/specs/connect/1.0/issuer" | ||
| OpenIDConnectRel = "http://openid.net/specs/connect/1.0/issuer" | ||
| OpenIDConnectDesktopRel = "http://openid.net/specs/connect/1.0/issuer/desktop" | ||
| OpenIDConnectMobileRel = "http://openid.net/specs/connect/1.0/issuer/mobile" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should invent new relations here. (As also mentioned by @butonic in the PR discussion) Apart from the fact that OpenCloud itself does currently only support talking a single IDP and configuring multiple different issuer URL would effectively mean we'd need to add multi-IDP support, I really think we don't need that. As outlined here support for multiple issuers is not even needed. In the case of Authentik where one application (OpenCloud) can just have a single clientid we should just use the same client id for all clients. If the clients fetch their client id via webfinger that is easy to be achived without adding the complexity of multiple issuer urls. |
||
| ) | ||
|
|
||
| type openIDDiscovery struct { | ||
|
|
@@ -31,3 +33,72 @@ func (l *openIDDiscovery) Add(_ context.Context, jrd *webfinger.JSONResourceDesc | |
| Href: l.Href, | ||
| }) | ||
| } | ||
|
|
||
| // ClientIDProperty is the property URI for the OIDC client ID | ||
| const ClientIDProperty = "http://openid.net/specs/connect/1.0/client_id" | ||
|
|
||
| type openIDDiscoveryDesktop struct { | ||
| Href string | ||
| ClientID string | ||
| } | ||
|
|
||
| // OpenIDDiscoveryDesktop adds the OpenID Connect issuer relation for desktop clients. | ||
| // This allows identity providers that require separate OIDC clients per application type | ||
| // (like Authentik, Kanidm, Zitadel) to provide a distinct issuer URL for desktop clients. | ||
| // If clientID is provided, it will be included as a property in the link. | ||
| // See: https://github.com/opencloud-eu/desktop/issues/246 | ||
| func OpenIDDiscoveryDesktop(href string, clientID string) service.RelationProvider { | ||
| return &openIDDiscoveryDesktop{ | ||
| Href: href, | ||
| ClientID: clientID, | ||
| } | ||
| } | ||
|
|
||
| func (l *openIDDiscoveryDesktop) Add(_ context.Context, jrd *webfinger.JSONResourceDescriptor) { | ||
| if jrd == nil { | ||
| jrd = &webfinger.JSONResourceDescriptor{} | ||
| } | ||
| link := webfinger.Link{ | ||
| Rel: OpenIDConnectDesktopRel, | ||
| Href: l.Href, | ||
| } | ||
| if l.ClientID != "" { | ||
| link.Properties = map[string]string{ | ||
| ClientIDProperty: l.ClientID, | ||
| } | ||
| } | ||
| jrd.Links = append(jrd.Links, link) | ||
| } | ||
|
|
||
| type openIDDiscoveryMobile struct { | ||
| Href string | ||
| ClientID string | ||
| } | ||
|
|
||
| // OpenIDDiscoveryMobile adds the OpenID Connect issuer relation for mobile clients. | ||
| // This allows identity providers that require separate OIDC clients per application type | ||
| // (like Authentik, Kanidm, Zitadel) to provide a distinct issuer URL for mobile clients. | ||
| // If clientID is provided, it will be included as a property in the link. | ||
| // See: https://github.com/opencloud-eu/desktop/issues/246 | ||
| func OpenIDDiscoveryMobile(href string, clientID string) service.RelationProvider { | ||
| return &openIDDiscoveryMobile{ | ||
| Href: href, | ||
| ClientID: clientID, | ||
| } | ||
| } | ||
|
|
||
| func (l *openIDDiscoveryMobile) Add(_ context.Context, jrd *webfinger.JSONResourceDescriptor) { | ||
| if jrd == nil { | ||
| jrd = &webfinger.JSONResourceDescriptor{} | ||
| } | ||
| link := webfinger.Link{ | ||
| Rel: OpenIDConnectMobileRel, | ||
| Href: l.Href, | ||
| } | ||
| if l.ClientID != "" { | ||
| link.Properties = map[string]string{ | ||
| ClientIDProperty: l.ClientID, | ||
| } | ||
| } | ||
| jrd.Links = append(jrd.Links, link) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally to the
clientidI think we also need to be able to set a list ofscopesper client. So that every client is able to figure out with exact scopes it needs to request for the access_-/id_token.This is needed for stuff like automatic role assignment and group provisioning to work in a more generic way and not just for keycloak. (See e.g. opencloud-eu/desktop#217 (comment))