Skip to content

Conversation

@d-led
Copy link

@d-led d-led commented Dec 15, 2023

Problem

as an admin of an Etherpad deployment I might not be able to map custom claims as these are controlled by the larger organization

Solution

If I manage to map a custom role into the roles claim (e.g. in MS/Azure/Entra ID), these will appear in the roles claim of the token:

"roles": [
  "etherpad_is_admin"
]

this change adds the possibility to set the user property, e.g. is_admin to true based on the presence of the configured string in the roles claim:

"is_admin": {"role": "etherpad_is_admin"},

Test

sorry, there's no automatic test as of now, however if you can configure the authority to either provide the role or not, visiting the admin page as a test should suffice.

Expected Behavior

if configured as above, and no other users configuration is present, then access to Admin panel should be forbidden for users that don't have that role in the roles claim

Dependencies

also upgraded dependencies:

before:

ep_openid_connect % npm outdated 
Package        Current  Wanted  Latest  Location                    Depended by
oidc-provider    8.4.5  7.14.3   8.4.5  node_modules/oidc-provider  ep_openid_connect
typescript       4.9.5   4.9.5   5.3.3  node_modules/typescript     ep_openid_connect

after:

ep_openid_connect % npm outdated
Package     Current  Wanted  Latest  Location                 Depended by
typescript    4.9.5   4.9.5   5.3.3  node_modules/typescript  ep_openid_connect

@d-led d-led changed the title Feature: set user property via roles claim Add setting user property via the roles claim Dec 15, 2023
@d-led d-led changed the title Add setting user property via the roles claim Add setting user property via the roles claim Dec 15, 2023
@d-led d-led marked this pull request as draft January 25, 2024 16:54
@d-led d-led marked this pull request as ready for review January 25, 2024 18:10
@d-led d-led marked this pull request as draft February 29, 2024 11:26
@d-led
Copy link
Author

d-led commented Feb 29, 2024

additional problems: upgrading the dependencies changes Ajs validation logic which then fails.

@morgenroth
Copy link

This is a neat solution! I tested it against keycloak with success. Thanks!

The alternative using Script Mapper mentioned in #44 did not worked for me. Script Mapper are no longer available in the UI of keycloak.

Please merge this PR, it is definitely needed.

@d-led d-led marked this pull request as ready for review May 7, 2025 14:14
@makefu
Copy link

makefu commented Dec 31, 2025

hi, i'd also love to see this merged

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants