Implement API Keys in spring boot

Viewed 2482

While using Spring Boot Oauth2 I am able to use JWT tokens for authentication in micro services for password and client credentials types.

However, I have a scenario where I need to use API keys like: test_dk_ChDGGFHFJ9dsd9dbH for test accounts and live_dk_Jhdhjkk78GThJk9N9 for live accounts.

I need to generate this API keys on user creation and the user should send them either as a HTTP Basic header ie: curl -u test_dk_ChDGGFHFJ9dsd9dbH and through Bearer authentication ie: curl -H "Authorization: Bearer test_dk_ChDGGFHFJ9dsd9dbH"

  1. How do I implement this generation and authentication in spring?
  2. How do I ensure that the API keys have prefix for test and live accounts?
0 Answers
Related