Generate JWT with custom claims from within Rule?

I am using a custom Rule to modify a SAML attributes mapping for SSO.

I am running Hasura with JWT authentication that depends on custom claims to determine data access privileges.

It is my understanding that I can add custom claims to the JWT in the Rule’s context, but this JWT is unfinished and invalid at the time the Rule is executing and so will be useless to me in the context of using it to authenticate with Hasura in that moment.

I believe I can make an external request to /oauth/token using axios in the Rule, but I’m not sure if there is any way to get custom claims for my Rule with that route.

Ultimately I cannot determine if there is any way to generate a signed JWT from within a rule that has custom claims attached to it. Is anyone aware of any way to accomplish this?

To head off the suggestion: I am aware that I could pass an admin token to Hasura and that doing so would “solve” my problem, but I am hoping to avoid doing that.

Let me know if anything needs clarification and thanks!

Looks like I forgot to specify my why.

I would like to reach out to Hasura during the Rule’s execution in order to enrich the SAML attributes mapping. This work needs to be executed within the rule for security reasons.

Hey there!

As Rules & Hooks are being fully deprecated soon, maybe you’re interested in finding out more how to achieve that with Actions?

As this topic is related to Rules - Hooks - Actions, I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!