Inject API Keys in Spring Boot

When using Spring Boot Oauth2, I can use JWT tokens to authenticate to microservices for client password and credential 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 real accounts.

I need to generate these API keys when creating a user, and the user has to send them either as an HTTP Basic header, ie: curl -u test_dk_ChDGGFHFJ9dsd9dbH and via bearer authentication, ie: curl -H "Authorization: Bearer test_dk_ChDGGFHFHJ9dsd9db

  • How to implement this generation and authentication in spring?
  • How can I make sure the API keys are prefixed for test and live accounts?
+3


source to share





All Articles