GithubHelp home page GithubHelp logo

ims94 / spring-boot-jwt-authorization Goto Github PK

View Code? Open in Web Editor NEW
52.0 1.0 30.0 547 KB

Example project to do role based access control (RBAC) using Spring Boot and JWT

Java 100.00%
spring-boot spring-security jwt jwt-authentication authorization rbac role-based-access-control roles security rest-api

spring-boot-jwt-authorization's Introduction

Role Based Access Control (RBAC) with Spring Boot and JWT

This repo hosts the source code for the article Role Based Access Control (RBAC) with Spring Boot and JWT.

This example project demonstrates how to use the Spring Boot's inbuilt OAuth2 Resoure Server to authenticate and authorize REST APIs with JWT. First, we have enabled JWT authentication and secondly, have introduced Role Based Access Control (RBAC) by mapping a roles claim in JWT to granted authorities in Spring Security.

Furthermore, provides a "/login" endpoint to generate and issue JWTs upon successful login by the users.

This approach is ideal to be used as the backend for a single page application (SPA) written using a frontend framework like ReactJS, Angular, etc...

Solution Overview

Solution Overview

Role Based Access Control

An example of role based access control.

RBAC Example

JWT Authentication Overview

Solution Overview

Getting Started

  • Use mvn clean install in the project root directory to build the project.
  • Run the main class, com.example.springboot.jwt.JwtApplication to start the application.

Endpoints

  • /login -> Public endpoint which returns a signed JWT for valid user credentials (username/password)
  • /products -> Contains several endpoints to add and remove product entities. Protected by JWT authentication and authorized based on role.

spring-boot-jwt-authorization's People

Contributors

ims94 avatar

Stargazers

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

Watchers

 avatar

spring-boot-jwt-authorization's Issues

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.