Skip to content

miller79/spring-security-demo

Repository files navigation

Spring Security Demo

Introduction

This repository is created to demonstrate how to create a Spring Security application that uses OAuth 2.0 with custom security Authorization rules. The main focuses of this repository include the following:

  • How to secure an API with OAuth 2.0
  • How to customize Roles from the JWT token
  • How to add custom Roles from another source
  • How to pass the Authorization down to another microservice
  • How to call another microservice using client credentials
  • Utilizing only Spring to accomplish each task

Architecture

Introduction

This project contains 3 applications, two that represent the servlet and reactive approach to creating an API and one that is a basic secured microservice that the first two services call.

main-api-servlet

This application is an API created using Spring Boot using a servlet approach. This application provides endpoints that provide demos including the following:

  • RestClient and RestTemplate
  • Method Level Security
  • Custom Security Filters
  • Integration tests using the following:
    • MockMvc
    • MockRestServiceServer
    • MockServerRestClientCustomizer
    • WithMockUser

main-api-reactive

This application is an API created using Spring Boot using a reactive approach. This application provides endpoints that provide demos including the following:

  • WebClient
  • Method Level Security
  • Custom Security Filters
  • Integration tests using the following:
    • OkHttp
    • WithMockUser

microservice

This application is a simple Spring Boot microservice using a reactive approach that contains one endpoint that is secured using OAuth 2.0. It demonstrates how to set it up and how to perform an integration test.

Diagram

spring-security-diagram

spring-security-interaction-diagram

Resources

About

Demonstrates how to use Spring Security with common production patterns.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages