Part II: Secure Spring Boot Service with Azure AD

Updated: Dec 26, 2020


Securing App with Azure Active Directory
Spring Boot With Azure Active Directory(AAD)

In this blog, we will learn about securing spring-boot service using Azure Active Directory. Please check my GitHub for complete code.


This is 2nd part of 5 part blog series.


Introduction



To start with Azure AD integration, below are the few steps that we need to follow:


For detailed steps, checkout this blog. Application Id, client secret, and tenant id that we copied for this blog, wil be used here.
  • Create Azure AD App from Azure Portal using App Registration Section in Azure Active Directory.

  • Save the Application Id (Client Id), we need to use it later. And also copy directory Id, we also need this.

  • Create Client Secret, and copy it.


Learn more about Azure AD


Implementation


There are two different implementation.

  • Using a multi-module project skeleton. ( For this implementation, I have created a custom parent and starter, that can be used instead of spring boot parent. Anyone can clone my repo, and get started with it.)

  • Doing everything by yourself. ( For this implementation, I will provide the steps, that can be used to implement security by yourself.)

Both implementations will perform the same job, but 1st implementation is an easy and efficient way. It has many different functionality, that can utilized in service, which will be discussed in other parts of this series.


Implementation 1: Using a multi-module project skeleton


To get started with it, check out my first blog in this series, and look for How to Use Section.


You can also checkout my GitHub Documentation, it also has steps, to create new service, and once service is created, then you can follow below steps.

Check out my Sample Service implementation on GitHub.


This implementation has only two steps:


Step 1: Use below pom.xml


Step2: Add Below content in the application.yml


How to use @PreAuthorize annotation?



Implementation 2: Developing everything by your self.

Check out this implementation on GitHub.


Step1: Add below dependencies in pom.xml


Step 2: Add below content in application.yml



Step 3: Create WebSecuirtyConfig Class by extending WebSecurityConfigurerAdapter and its helper class implementation



How to use @PreAuthorize annotation?


Thanks for reading. I hope these implementations will help you in integrating Azure AD in your Spring Boot Service.


Comments and feedback are most welcomed.

Please follow me on Linkedin, Github, and join our newsletter to keep yourself updated.

Thanks for reading. Happy Learning 😊

428 views

Recent Posts

See All