Get all roles from every project into one access token

Hello everyone I have a question. Currently when I get a token from the oidc client everything works fine. With the ClientId i get the roles from the project. Now my question is if its possible to get all roles of the user from every project that is currently available in the project. I have about 7 projects and I need all users roles for every project. If I want to do that I need 7 different access tokens but I only want to have 1. Is something like that possible?
75 Replies
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
hey @FFO thanks for your message. I have to admit I don't even know where to begin making this action and what exactly I have to doπŸ˜… . As much as I understand it I have to call an action in my backend and tweak the token content (I don't know what tweak means). Is that right?
boblack_zocker
boblack_zockerOPβ€’3y ago
is this the action you've meant?
No description
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
Can you tell me how I tweak the token content with all roles? What should my script have to do?
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
thats the ListMyUserGrants right?
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
the thing is when i do that i get the result i want: every role the user has on every project. but i think the performance would really struggle if i do it like this in the backend cause i would have to call it every time my API gets called.
No description
boblack_zocker
boblack_zockerOPβ€’3y ago
i actually only want all roles from a single user but on different projects. I think you misunderstood me at the beginning could that be? the only thing is that i want this information in the users claim in the access token so i dont have to call it every time with ListMyUserGrants. because currently i only get the roles of one project.
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
that makes sense to me. The only thing is i don't know where to start with the action πŸ˜‚
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
is it something like that? thats from the docs
No description
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
uf i would have to test it can't tell you rigth away
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
well in my example i have to setClaim() in the access token is that right?
boblack_zocker
boblack_zockerOPβ€’3y ago
well this is how you set the grants in the access token but how do i get them in the first place πŸ˜…
No description
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
this one right?
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
the userid is in ctx.v1.user ?
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
aha okey
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
its starts to make sense even more now i think i know where i can begin now to do the action πŸ˜‚
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
yes that makes sense well i'm gonna try it and tell u the result later on πŸ‘ . Really appreciate your help thanks!
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
one more questionπŸ˜… . Is that the only way to make an action? can i make the action in a standalone javascript file so i have a debugger and interpreter.
No description
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
i was just trying something out there πŸ˜… πŸ˜‚ its a bit hard to think without a interpreter hahaha
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
already did hehe
No description
boblack_zocker
boblack_zockerOPβ€’3y ago
url right as i did or does it need the full path?
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
how can i see if it worked or not?
boblack_zocker
boblack_zockerOPβ€’3y ago
I made this script and zitadel gives me no feedback if it works or not. the action is stated as active but nothing happens
No description
boblack_zocker
boblack_zockerOPβ€’3y ago
its says its active but it doesn't look like its working
No description
boblack_zocker
boblack_zockerOPβ€’3y ago
it looks like my function never gets called but i'm not sure
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
no problem I was out too. I'm currently self-hosted how does that work?
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
i tried to do api.v1.userinfo.setClaim('year', 2023) as a test but it didnt get added
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
oh i see
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
so this should work?
No description
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
jep that true
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
is it even right if i set the parameters like in my code? it seems to take a string and any
No description
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
is that enough to get my function executed?
No description
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
i looked at my logs i dont get a hello world or anything else
No description
boblack_zocker
boblack_zockerOPβ€’3y ago
name of the function is also the same
boblack_zocker
boblack_zockerOPβ€’3y ago
No description
boblack_zocker
boblack_zockerOPβ€’3y ago
I searched my logs in the docker container. But there is nothing. is there a own log file in the system that outputs the logs?
boblack_zocker
boblack_zockerOPβ€’3y ago
ZITADEL Docs
Quotas is an enterprise feature that is relevant if you want to host ZITADEL as a service.
boblack_zocker
boblack_zockerOPβ€’3y ago
GitHub
zitadel/defaults.yaml at main Β· zitadel/zitadel
ZITADEL - The best of Auth0 and Keycloak combined. Built for the serverless era. - zitadel/defaults.yaml at main Β· zitadel/zitadel
No description
boblack_zocker
boblack_zockerOPβ€’3y ago
do i need that stuff? and if yes where do i have to add it
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
The actions i did should be hit as much as i can tell because everything was done right on the console site. It could really be that nothing gets logged. It was really frustrating yesterday searching for this logsπŸ˜‚ . Is it right that those logs must show up in "docker compose logs"? I also tried to test actions made from your sample (https://github.com/zitadel/actions/blob/main/examples/post_auth_log.js). Here even the syntax and everything should be okay but still no logs there. Also none that the process failed or something.
No description
No description
No description
No description
boblack_zocker
boblack_zockerOPβ€’3y ago
just for my understanding. When does the action gets executed exactly? When the user calls "/oauth/v2/token"?
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
Yes sure. Pls let me know if there is a updateπŸ‘
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
Is that the latest version?
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
i get now console logs πŸ‘ . but kinda not helpful logs but still better then nothing 😁 . it looks like i get the whole http request logged. i dont know why beacause i dont log that anywhere. starts with: time="2023-02-17T13:25:06Z" level=info msg="log record emitted" caller="/home/runner/work/zitadel/zitadel/internal/logstore/emitters/stdout/stdout.go:19" record="{"logDate":"2023-02-17T13:25:06.892322614Z","protocol":1,"requestUrl":"/oauth/v2/token\ ........ and goes on
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
boblack_zocker
boblack_zockerOPβ€’3y ago
yes but can i send it private to you?
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?