Auth: Add userinfo API endpoint to get information about the logged in user #2134

Open
opened 2026-02-20 01:06:51 -05:00 by deekerman · 2 comments
Owner

Originally created by @lastzero on GitHub (Jul 3, 2024).

Performing an authenticated request to GET /api/v1/oauth/userinfo should return information about the logged in user:

(1) Since we are using the (OpenID Foundation certified) github.com/zitadel/oidc library for the recently released OIDC client implementation, the authorize and userinfo API endpoints should also be based on it (as much as possible):

(2) Based on this (a) allowing authentication and authorization with our own auth/session tokens (so existing clients can use the endpoint) and (b) setting the Userinfo values from the User entity seems to be pretty much all that is needed.

(3) In addition, all pull requests should include unit tests - at least for the core functionality - to ensure that the changes work as expected: https://docs.photoprism.app/developer-guide/pull-requests/#acceptance-criteria


Documentation:

Protocol References:

Related Issues:

Originally created by @lastzero on GitHub (Jul 3, 2024). Performing an authenticated request to `GET /api/v1/oauth/userinfo` should return information about the logged in user: - https://github.com/photoprism/photoprism/blob/develop/internal/api/oauth_userinfo.go **(1)** Since we are using the (OpenID Foundation certified) [`github.com/zitadel/oidc`](https://github.com/zitadel/oidc) library for the [recently released OIDC client](https://docs.photoprism.app/developer-guide/api/oidc/) implementation, the [`authorize`](https://github.com/photoprism/photoprism/issues/4368) and `userinfo` API endpoints should also be based on it (as much as possible): - https://github.com/photoprism/photoprism/tree/develop/internal/auth/oidc - https://github.com/zitadel/oidc/blob/7b8be4387a20a2ceeb5dfd7a229f308e1a6e01ba/pkg/op/userinfo.go#L26-L48 **(2)** Based on this (a) allowing authentication and authorization with our [own auth/session tokens](https://github.com/photoprism/photoprism/blob/develop/internal/api/api_auth.go) (so existing clients can use the endpoint) and (b) setting the [Userinfo](https://github.com/zitadel/oidc/blob/main/pkg/oidc/userinfo.go) values from the [User](https://github.com/photoprism/photoprism/blob/develop/internal/entity/auth_user.go) entity seems to be pretty much all that is needed. **(3)** In addition, all pull requests should [include unit tests](https://docs.photoprism.app/developer-guide/code-quality/#test-automation-guidelines) - at least for the core functionality - to ensure that the changes work as expected: https://docs.photoprism.app/developer-guide/pull-requests/#acceptance-criteria --- Documentation: - https://docs.photoprism.app/developer-guide/api/#openid-configuration - https://docs.photoprism.app/developer-guide/api/oidc/#service-discovery - https://docs.photoprism.app/developer-guide/api/oauth2/ Protocol References: - https://openid.net/specs/openid-connect-core-1_0.html#UserInfo - https://www.oauth.com/oauth2-servers/openid-connect/id-tokens/ Related Issues: - https://github.com/photoprism/photoprism/issues/4368 - https://github.com/photoprism/photoprism/issues/782 - https://github.com/photoprism/photoprism/issues/3943
Author
Owner

@andiz2 commented on GitHub (Jul 13, 2024):

Hi friends! I can take care of this endpoint too :).
Would be so much fun.

@andiz2 commented on GitHub (Jul 13, 2024): Hi friends! I can take care of this endpoint too :). Would be so much fun.
Author
Owner

@lastzero commented on GitHub (Jul 13, 2024):

@andiz2 Awesome, thank you very much! I've updated the issue description and added the most important acceptance criteria as well as links to the code and library we're using. I'll be happy to help if you have any questions or would like to join our contributors chat.

@lastzero commented on GitHub (Jul 13, 2024): @andiz2 Awesome, thank you very much! I've updated the issue description and added the most important acceptance criteria as well as links to the code and library we're using. I'll be [happy to help](https://www.photoprism.app/contact) if you have any questions or would like to join our contributors chat.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/photoprism#2134
No description provided.