Code Monkey home page Code Monkey logo

spring-boot-jwt-authentication's Introduction

JWT Authentication with Spring Boot’s inbuilt OAuth2 Resource Server

This repo hosts the source code corresponding to the article JWT Authentication with Spring Boot’s inbuilt OAuth2 Resource Server.

This example project demonstrates the usage of Spring Boot OAuth2 Resource Server with JWT configuration to protect a REST API with JWT based authentication.

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...

Note: A sample implementation of a ReactJs app is included in the frontend directory.

Solution 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.

Sample ReactJs App

  • A sample ReactJs app to consume the created API is located in frontend directory. Simply run npm install and npm start within that to start the app.

Endpoints

  • /login -> Public endpoint which returns a signed JWT for valid user credentials (username/password)
  • /user -> A protected endpoint which returns the user details of the requesting user.

See Also

  1. See https://github.com/IMS94/spring-boot-jwt-authorization for an extension of this for role based access control (RBAC)

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.