I am using the JwtAuthProvider to create tokens when authenticating users.
I then pass that token to backend services to verify and use, but I want the Subject to be a custom generated App ID, not a incremental number.
(I also need to save registered users into a custom database (custom schema)).
It looks like I will need to create my own IAuthRepository to get storing data the data in the form we need in our database.
However, how best to handle the custom UserId?
It is best to generate the custom ID in the CustomAuthUserSession.OnRegister and save it as the AuthUserId in the session? OR is there another way to change the Session.AuthUserId to be what I need it to be, rather than it use the integer of the IAuthUser coming from the IAuthRepository?
What APIs are you using to create the token? It uses IAuthSession.UserAuthId for its sub so you can populate that property with the session you’re creating a JWT of.
OK, I can do that by saving the custom ID in session.Meta and use it in the JWT using CreatePayloadFilter, but what if I want my custom ID to really be the session.UserAuthId for the current service?
Seems that changing it in the CustomAuthUserSession.OnRegistered does work, but does not make it stick! (by the time the user logs in at CustomAuthUserSession.OnAuthenticated the session.UserAuthId is back being an integer again!!
I simply want to define my own Session.UserAuthId and not use the built in integer value that comes from IAuthUser (it seems). Is it possible? If so, where do I need to extend?
Is your CredentialsAuthProvider doing it? So you’re using an Auth Repository? Why would you want to change the sub which is expected to be the UserAuthId? But you can modify the JWT Payload in the CreatePayloadFilter.