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.