Posted in Spring Boot Spring JPA Spring Security

PreAuthorize HasPermission Security Using Spring Boot Data JPA

Introduction The ability of hasPermission() method in Spring Boot Security applications is to determine the accessibility of a particular user for the application. The permission of an access can be read, write, etc. So, a particular user has defined set of access permission by which a user can perform certain activities in the application. The most useful annotation @PreAuthorize, which…

Continue Reading... PreAuthorize HasPermission Security Using Spring Boot Data JPA
Posted in Spring Boot Spring Security

Error bean securityConfig: unresolvable circular reference

Problem Recently while I was working with Spring Security in recent versions of Spring Boot framework (2.6.6/2.6.7), I was getting the following error (Requested bean is currently in creation: Is there an unresolvable circular reference?):

Continue Reading... Error bean securityConfig: unresolvable circular reference
Posted in Spring Boot Spring JPA Spring Security

PreAuthorize HasRole Security Using Spring Boot Data JPA

Table of Contents Introduction Where is @PreAuthorize applicable? Prerequisites Project Setup MySQL Table Data Application Config Entity Classes Repository Interfaces Service Class REST Controller Class Security Config Spring Boot Main Class Testing Spring Security – PreAuthorize hasRole Source Code Introduction PreAuthorize hasRole Spring security will determine whether a user can invoke a method or not based on his/her role. hasRole()…

Continue Reading... PreAuthorize HasRole Security Using Spring Boot Data JPA
Posted in Spring Boot Spring REST Spring Security

Spring Security Pre-Authentication with Spring Data JPA

Introduction In this example I am going to show you Spring Security Pre-authentication hasrole with Spring Data JPA. In my another example I had shown the similar example on Spring Security Pre-Authentication with Spring JDBC Template. There are situations where you want to use Spring Security for authorization, but the user has already been reliably authenticated by some external system…

Continue Reading... Spring Security Pre-Authentication with Spring Data JPA
Posted in Spring Boot Spring Cloud Spring REST Spring Security Spring WebFlux

Spring Cloud Gateway Security with JWT (JSON Web Token)

Spring Cloud Gateway Security In this tutorial I am going to show you an example on Spring Cloud Gateway Security with JWT. JSON Web Tokens (JWT) are an open, industry standard RFC 7519 method for representing claims securely between two parties. JWT.IO allows you to decode, verify and generate JWT. The Spring Cloud Gateway sits in front of your microservices…

Continue Reading... Spring Cloud Gateway Security with JWT (JSON Web Token)
Posted in AWS Spring Boot Spring REST Spring Security

Spring Boot OAuth2 SSO Example with AWS Cognito

Here in this example I am going to show you how to allow users for OAuth2 SSO (Single Sign On) using AWS (Amazon Web Services) Cognito. I had explained how to do OAuth2 Single Sign On using Spring Boot and GitHub account. Here I am going to use AWS Cognito. You can use any other providers, such as, Google, Facebook,…

Continue Reading... Spring Boot OAuth2 SSO Example with AWS Cognito
Posted in Angular Spring Boot Spring REST Spring Security

Spring Boot Security Angular 8 Login Logout Example

Introduction Here we will create Spring Boot Security Angular Login Logout Example which will show you how to integrate Spring Security with Angular 8 to login to the application. We will redirect user to the login page if user is not already logged in. Similarly we will redirect user to the home page if user is already logged in. Because…

Continue Reading... Spring Boot Security Angular 8 Login Logout Example
Posted in Spring Boot Spring JDBC Spring Security

Spring Security – Authentication and Role Based Authorization using JWT

Introduction In this post we will see an example on Spring Security authentication and role based authorization using JWT (JSON Web Token) on REST or RESTful services. I won’t explain here about JWT as there is already very good article on JWT. We will implement Spring Security’s UserDetailsService to load user from database. We will use Spring JDBC API to…

Continue Reading... Spring Security – Authentication and Role Based Authorization using JWT
Posted in Spring Boot Spring Security

Spring Boot Security – Form Based Authentication – Persistence Token – Remember Me

Introduction The example Spring Boot Security form based authentication persistence token remember me will show you how to use custom login form with Spring’s j_spring_security_check to authenticate a user. You may also look into form based authentication remember me – persistent token – on Spring MVC framework. The similar example we will implement here but using Spring Boot framework. We will add additional field…

Continue Reading... Spring Boot Security – Form Based Authentication – Persistence Token – Remember Me
Posted in Spring Boot Spring Security

Spring Boot Security – Form Based Authentication – Remember Me

Introduction The example Spring Boot Security form based authentication remember me will show you how to use custom login form with Spring’s j_spring_security_check to authenticate a user with remember me option. You may also look into form based authentication – remember me – on Spring MVC framework. The similar example we will implement here but using Spring Boot framework. We will add additional field…

Continue Reading... Spring Boot Security – Form Based Authentication – Remember Me