🚀 Feature: Ability to have custom claims be non-string objects #359

Closed
opened 2025-10-08 00:05:04 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @gray-morley on GitHub.

Feature description

I would like the ability to define a custom claim as either String, List, or JSON.

Pitch

I have an application that expects either a list or a json object from the custom claims. Currently pocket id is causing a failure because it converts what we type in the UI to a string. Thus when the application tries to read the claim, it throws a parsing error.

Specifically, my application in use is Audiobookshelf with custom login claims.

Thanks

Originally created by @gray-morley on GitHub. ### Feature description I would like the ability to define a custom claim as either String, List, or JSON. ### Pitch I have an application that expects either a list or a json object from the custom claims. Currently pocket id is causing a failure because it converts what we type in the UI to a string. Thus when the application tries to read the claim, it throws a parsing error. Specifically, my application in use is Audiobookshelf with custom login claims. Thanks
OVERLORD added the feature label 2025-10-08 00:05:04 +03:00
Author
Owner

@stonith404 commented on GitHub:

Alright, thanks. I'll look into it.

@stonith404 commented on GitHub: Alright, thanks. I'll look into it.
Author
Owner

@stonith404 commented on GitHub:

Can you share for which feature Audiobookshelf needs an object of a custom claim?

@stonith404 commented on GitHub: Can you share for which feature Audiobookshelf needs an object of a custom claim?
Author
Owner

@gray-morley commented on GitHub:

Sure,

Here’s a screenshot of the claim that expects a json object:

Image

This results in the following error:
2025-02-05 03:14:19.019
ERROR
[Auth] openid callback error: Unexpected permission property: 0 Error: Unexpected permission property: 0 at /server/models/User.js:845:15 at Array.forEach () at User.updatePermissionsFromExternalJSON (/server/models/User.js:842:33) at Auth.updateUserPermissions (/server/Auth.js:333:20) at OpenIDConnectStrategy._verify (/server/Auth.js:157:24) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Claim response looks like the following (set up in pocket id):
Using a group claim:
Claim name: abspermissions
Claim value: { "canDownload": true, "canUpload": false, "canDelete": false, "canUpdate": false, "canAccessExplicitContent": true, "canAccessAllLibraries": true, "canAccessAllTags": false, "canCreateEReader": false, "tagsAreDenylist": true, "allowedTags": [ "Test" ] }

In Audiobookshelf logs, it receives:
[Auth] openid callback userinfo= { "abspermissions": "{ "canDownload": true, "canUpload": false, "canDelete": false, "canUpdate": false, "canAccessExplicitContent": true, "canAccessAllLibraries": true, "canAccessAllTags": false, "canCreateEReader": false, "tagsAreDenylist": true, "allowedTags": [ "Test" ] }", "email": "XXXXXX", "email_verified": true, "family_name": "XXXXXX", "given_name": "XXXXX", "name": "XXXXXXXX", "preferred_username": "XXXXXXX", "sub": "XXXXXXXX" }

As you can see, the abspermissions value is wrapped in quotes

@gray-morley commented on GitHub: Sure, Here’s a screenshot of the claim that expects a json object: ![Image](https://github.com/user-attachments/assets/f8864448-3e3a-408b-892c-537594f34a03) This results in the following error: 2025-02-05 03:14:19.019 ERROR [Auth] openid callback error: Unexpected permission property: 0 Error: Unexpected permission property: 0 at /server/models/User.js:845:15 at Array.forEach (<anonymous>) at User.updatePermissionsFromExternalJSON (/server/models/User.js:842:33) at Auth.updateUserPermissions (/server/Auth.js:333:20) at OpenIDConnectStrategy._verify (/server/Auth.js:157:24) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Claim response looks like the following (set up in pocket id): Using a group claim: Claim name: abspermissions Claim value: { "canDownload": true, "canUpload": false, "canDelete": false, "canUpdate": false, "canAccessExplicitContent": true, "canAccessAllLibraries": true, "canAccessAllTags": false, "canCreateEReader": false, "tagsAreDenylist": true, "allowedTags": [ "Test" ] } In Audiobookshelf logs, it receives: [Auth] openid callback userinfo= { "abspermissions": "{ \"canDownload\": true, \"canUpload\": false, \"canDelete\": false, \"canUpdate\": false, \"canAccessExplicitContent\": true, \"canAccessAllLibraries\": true, \"canAccessAllTags\": false, \"canCreateEReader\": false, \"tagsAreDenylist\": true, \"allowedTags\": [ \"Test\" ] }", "email": "XXXXXX", "email_verified": true, "family_name": "XXXXXX", "given_name": "XXXXX", "name": "XXXXXXXX", "preferred_username": "XXXXXXX", "sub": "XXXXXXXX" } As you can see, the abspermissions value is wrapped in quotes
Author
Owner

@stonith404 commented on GitHub:

Added in v0.29.0.

@stonith404 commented on GitHub: Added in `v0.29.0`.
Author
Owner

@gray-morley commented on GitHub:

Thanks

@gray-morley commented on GitHub: Thanks
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-1#359