Following MongoDB Custom Authentication, it is given that any JWT Token
with the minimal below fields works with the MongoDB Stitch Authentication. Also, token needs to be issued by External Authentication System
{
"aud": "<stitch app id>"
"sub": "<unique user id>",
"exp": <NumericDate>,
}
I've tested this and it works as well
- Created Stitch App and enabled Users with
Custom Authentication Provider
- Generated Sample Token through Jwt.io with the below inputs. (Use same algorithm and key as configured when enabling Custom Authentication Provider, Here it is, HS256 and the )
It works in the way,
- It is validating the users in MongoDB Stich Users Collection with the unique
value
provided insub
:"sub": "<unique user id>"
and if the user is present then it returning the Object Id for that User. - If the user is not present then it is creating one against the input and returning the Object Id.
Queries are,
- Why it is creating a new user instead of returning login failure, which in turn works like any user can log in with any credentials on demand?
- If
MongoDB Stitch Custom Authentication
involvesExternal Authentication System
to issueJWT
, where the user data will be actually stored when user registration? -MongoDB Stitch App Collection
orExternal Authentication API System
?