Skip to content
Advertisement

Azure AD with spring boot with user in local Database

Helo Here, I Hope you are doing well. I’s been few days I’m having this problem.

I have a spring boot API using Azure AD authentication thanks to AADResourceServerWebSecurityConfigurerAdapter.

Here is the flow I want to have:

  1. User gets token from Azure in the react native frontend (done)
  2. User logs into the api thanks to the given token. (to-do)
  3. If user doesn’t exists in local db, then it’s created thanks to info from the token.

Here is my question: How can I do to be able to have a callback / function executed when the user first connect to the api with a new token ? With this answer, I will be able to check if an user exist with the provided email in the token, and create it if it’s not existing.

Here is my websecurity config:

JavaScript

I know this is messy because it is stil a part in development, but I would like to complete it thank to your information.

Thanks, Alex

Advertisement

Answer

As you said that you’ve done the step of getting access token. So I think you can add a filter to judge if the user contained in the token exists in your database. Here’s a sample filter.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement