External role resolver (Okta / Auth0 / custom IDP)
Roles live in your IDP, not your DB.
Your roles already live in Okta groups (or Auth0, or your own internal IDP). Don't duplicate them in the nest_auth_roles table — resolve them on every login from the IDP.
When this runs
resolveRoles runs on every login and every refresh. Cache aggressively:
A 5-minute TTL means a role change in Okta propagates within five minutes — usually acceptable; tune to your policy.
Hard fail vs soft fail
If Okta is down and resolveRoles throws, login fails. Sometimes that's right; sometimes you want to fall back to last-known-good:
Pairing with loginHooks.onLogin
If you want to write roles to the local DB too (so the admin console shows them), do that in the login hook — but treat the IDP as source of truth: