I have to implement multiple type of authentication in my backend application.
- JWT authentication
- API key authentication
In case of JWT authentication:- After successfull authentication of user, claims like UserId, UserName... added to JWT token. Some protected API's get data from this token and added to the database.
Now the problem is that In case of API Key authentication:- I have no claims because API key auth is not like JWT authentication (JWT token).
I tried to generate an API key using some root user always but its not a standard practice or design principle.
I want to know how these types of authentication are managed? Is it possible to use JWT as well as API key authentication? If using API key and storing data related to API key in database and getting it from db or any in memory cache (makes it session based authentcation, and I think then no use of JWT here if I need to manage it).
Please suggest how to managed this.