Skip to content

This is a template to create a reusable spring security module for your organization using Spring Boot 3.

Notifications You must be signed in to change notification settings

supernovabirth/spring-boot-3-security-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reusable Module Template for Spring Security Integration with Spring Boot 3

Overview

This project provides a template for creating a reusable module that integrate with Spring Security. It is designed to handle common security-related tasks in enterprise environments, such as:

  • User Authentication: Logging in users by interacting with existing authentication mechanisms.
  • Credential Management: Seamlessly retrieving and managing user credentials from existing login processes.
  • Role Retrieval: Accessing user roles from various external role services, regardless of their format or implementation.

Purpose

This template is not a ready-to-use module but a foundational starting point for developers looking to create custom security modules within their Spring applications. It is particularly useful in environments where multiple systems and services are involved, each with its own authentication and role management processes.

Features

  • Pluggable Role Service Integration: Easily extendable to support different external role services with varying response formats.
  • OAuth Secured Roles Service Calls: Supports OAuth token retrieval using either client credentials or username/password, providing flexibility in integrating with secured APIs.
  • Caching Support: Built-in support for caching user roles using Ehcache, reducing the need for repeated external service calls. (Yet to be implemented)
  • SOLID Principles: The module template follows SOLID design principles, ensuring clean, maintainable, and extendable code.

Usage

To use this template:

  1. Clone the Repository: Start by cloning the repository to your local development environment.
  2. Implement Role Retrieval: Extend the provided RoleRetrievalStrategy to handle your specific role service's response format.
  3. Configure Authentication: If your role service is secured with OAuth2, customize the OAuth token retrieval to match your enterprise authentication requirements (username/password or client ID/secret).
  4. Configure Caching: Set up caching policies in ehcache.xml as needed for your environment.
  5. Integrate with Your Application: Include this module in your Spring application, injecting it into your security configuration or services as required.

Getting Started

  1. Clone the Repository:

    git clone https://github.com/supernovabirth/spring-boot-3-security-template.git
  2. Update Configuration: Modify the application.properties to set up the OAuth configuration and other necessary properties.

  3. Customize the Module: Implement your own RoleRetrievalStrategy and update the OAuthTokenService as needed to fit your enterprise's role service.

  4. Integration: Add the module to your Spring Security configuration and start using it in your application to manage user authentication and roles.

Contributions

Contributions to improve this template are welcome. Please feel free to fork the repository, make your changes, and submit a pull request.

About

This is a template to create a reusable spring security module for your organization using Spring Boot 3.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published