How to set the audience when signing in?
# support-questions-legacy
f
Hi! I'm trying to implement unified user authentication for multiple private services. I was imagining that each service would provide the users credentials alongside with a service identifier, which would then get packed into the JWT as the
aud
claim. The client would then use the JWT for requests with the service thereafter. I took a look at https://app.swaggerhub.com/apis/supertokens/FDI/1.18.0#/EmailPassword%20Recipe/signIn for the prebuilt backend, but I couldn't find a way to pass this id anywhere. What's the easiest way for me to do this?
r
Hey @f1yingbanana could you elaborate on your use case with an example? For example, I don’t understand why each server would need to pass user credentials.
f
Sure! Imagine that each server is a separate app. They would need to authenticate the user first before serving any further requests for them.
We'd like to have a shared authentication backend and database to store all these users so our users could login to each of the services separately, and we'd like to ensure that the JWT used for one service isn't reused for another.
r
Right. I see.
So all these separate apps will share the same user pool?
If so, you need to integrate our backend SDK into this common auth backend, and then when the sign in api is called from our exposed middleware, you can essentially add a custom aud claim into the access token based on the request’s origin (assuming each of these separate apps have a different frontend domain)
f
That's right! I'm actually playing around with the pre-built backend and trying to see if I can get it to work with the least amount of modifications 😛 that's why I was looking at the list of API of this prebuilt backend to see if there's some way for me to pass this custom
aud
claim in. I couldn't find it and here I am. What do you think is the easiest way for me to implement this?
r
f
Looks like I'm trying to modify the right place! But what I'm having trouble is how to read the custom
aud
from the request and pass that into the session creation. I don't see any way to pass any custom parameters in the backend API: https://app.swaggerhub.com/apis/supertokens/FDI/1.18.0#/EmailPassword%20Recipe/signIn.
I’m not sure which recipe you use
The above link is for thirdpartyemailpassword
f
That did the trick, thank you! Btw those two pages have the same content 😛
r
Ah okay. They are in different recipes. So the content is replicated
9 Views