Code Monkey home page Code Monkey logo

rolepermissionexample's Introduction

ROLE WITH PERMISSION THROUGH SPRING SECURITY IN SPRING BOOT

Main Information

📖 Information

  • This is a Spring Boot example covering important and useful features.
  • Here is an explanation of the example:
    • Admin and User implement their own authentication and authorization through their defined role names.
    • The Admin handles with the following process shown above:
      • Admin with Role containing create permission only handles with creating product
      • Admin with Role containing get permission only handles with getting product by id
      • Admin with Role containing update permission only handles with updating product by id
      • Admin with Role containing delete permission only handles with deleting product by id
    • The User handles with the following process shown above:
      • User with Role containing get permission only handles with getting product by id

Explore Rest APIs

Method Url Description Request Body Header Valid Path Variable No Path Variable
POST /api/v1/authentication/user/register User Register RegisterRequest
POST /api/v1/authentication/user/login User Login LoginRequest
POST /api/v1/authentication/user/refresh-token User Refresh Token TokenRefreshRequest
POST /api/v1/authentication/user/logout User Logout TokenInvalidateRequest
POST /api/v1/products Create Product ProductCreateRequest
GET /api/v1/products/{productId} Get Product By Id ProductId
GET /api/v1/products Get Products ProductPagingRequest
PUT /api/v1/products/{productId} Update Product By Id ProductUpdateRequest ProductId
DELETE /api/v1/products/{productId} Delete Product By Id ProductId

Technologies


  • Java 21
  • Spring Boot 3.0
  • Restful API
  • Lombok
  • Maven
  • Junit5
  • Mockito
  • TestContainer
  • Integration Tests
  • Docker
  • Docker Compose
  • CI/CD (Github Actions)
  • Postman
  • Spring Boot Open Api

Postman

Import postman collection under postman_collection folder

Open Api

http://localhost:1225/swagger-ui/index.html

Prerequisites

Define Variable in .env file

DATABASE_USERNAME={DATABASE_USERNAME}
DATABASE_PASSWORD={DATABASE_PASSWORD}

  • Maven or Docker

Docker Run

The application can be built and run by the Docker engine. The Dockerfile has multistage build, so you do not need to build and run separately.

Please follow directions shown below in order to build and run the application with Docker Compose file;

$ cd rolepermissionexample
$ docker-compose up -d

If you change anything in the project and run it on Docker, you can also use this command shown below

$ cd rolepermissionexample
$ docker-compose up --build

Maven Run

To build and run the application with Maven, please follow the directions shown below;

$ cd rolepermissionexample
$ mvn clean install
$ mvn spring-boot:run

Screenshots

Click here to show the screenshots of project

Figure 1

Figure 2

Figure 3

Figure 4

Figure 5

Figure 6

Figure 7

Figure 8

Contributors

rolepermissionexample's People

Contributors

rapter1990 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.