idanto
04/09/2024, 12:08 PMtokenPayload = await new Promise((resolve, reject) =>
jwt.verify(token, this.getKey.bind(this), {}, (err, decoded) => {
if (err) {
this.logger.error({ msg: 'error verifing token', err });
reject(err);
} else {
resolve(decoded);
}
}),
);
we have a distributed system so each sub-graph is doing its own AuthZ using Shield. We define the roles check using graphql-shield functions that check the claims we overload on the GQL request context.
I'm thinking of replacing this local check with:
let session = await Session.getSession(contextValue.req, contextValue.res)
and overload the claims based on this function response.
I just wonder if this will return a new session in case the roles for the user were updated, if yes how should I return it to the client?
also wonder what are the default checks this function does and if it always does it with the Supertokens server or if there is any local cache mechanism?rp_st
04/09/2024, 1:19 PMrp_st
04/09/2024, 1:21 PMidanto
04/09/2024, 2:05 PMUserRoles.UserRoleClaim.validators.includes("admin")
it will update the token in case it needs to be updated, right?
If I still want to use shield so I need to implement the function there using supertokens sdk functions? is there a way to get the most up-to-date claims while validating the session (every 5min is fine)?
when you say "getSession only verifies the JWT + checks any global claim validators you may have added to session.init config" do you mean locally or by calling supertokens server?rp_st
04/09/2024, 2:06 PMrp_st
04/09/2024, 2:07 PMawait session.setAndFetchClaim(UserRoles.UserRoleClaim)
rp_st
04/09/2024, 2:07 PMidanto
04/09/2024, 2:08 PMrp_st
04/09/2024, 2:08 PMawait session.setAndFetchClaim(UserRoles.UserRoleClaim)
- use shieldrp_st
04/09/2024, 2:09 PMrp_st
04/09/2024, 2:09 PMidanto
04/09/2024, 2:27 PMrp_st
04/09/2024, 2:27 PMrp_st
04/09/2024, 2:27 PMrp_st
04/09/2024, 2:27 PMidanto
04/09/2024, 2:28 PMrp_st
04/09/2024, 2:28 PMidanto
04/09/2024, 2:28 PMrp_st
04/09/2024, 2:28 PMidanto
04/09/2024, 2:36 PMidanto
04/09/2024, 2:36 PMrp_st
04/09/2024, 2:36 PMrp_st
04/09/2024, 2:36 PMidanto
04/09/2024, 2:37 PMidanto
04/09/2024, 4:56 PMrp_st
04/09/2024, 5:15 PM