All Projects → isopropylcyanide → Jwt Spring Security Jpa

isopropylcyanide / Jwt Spring Security Jpa

Licence: apache-2.0
Backend MVP showcasing JWT (Json Web Token) authentication with multiple login, timeout / refresh / logout (with in memory invalidation) using Spring Security & MySQL JPA.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Jwt Spring Security Jpa

spring-boot-login-example
Spring Boot Login and Registration example with MySQL, JWT, Rest Api - Spring Boot Spring Security Login example
Stars: ✭ 50 (-75.25%)
Mutual labels:  spring-security, jwt-token, jwt-authentication, jwt-auth
Jwt
Go JWT signing, verifying and validating
Stars: ✭ 394 (+95.05%)
Mutual labels:  jwt, jwt-authentication, jwt-token, jwt-auth
React Login
A client side implementation of authentication using react.js for my blog on medium. This is the second part of my previous blog on how to implement scalable node.js server.
Stars: ✭ 105 (-48.02%)
Mutual labels:  jwt, jwt-authentication, jwt-token, jwt-auth
Jose2go
Golang (GO) implementation of Javascript Object Signing and Encryption specification
Stars: ✭ 150 (-25.74%)
Mutual labels:  jwt, jwt-authentication, jwt-token, jwt-auth
Jose Jwt
Ultimate Javascript Object Signing and Encryption (JOSE) and JSON Web Token (JWT) Implementation for .NET and .NET Core
Stars: ✭ 692 (+242.57%)
Mutual labels:  jwt, jwt-authentication, jwt-token
Httpie Jwt Auth
JWTAuth (JSON Web Tokens) auth plugin for HTTPie
Stars: ✭ 140 (-30.69%)
Mutual labels:  jwt, jwt-authentication, jwt-token
Spring Webflux Security Jwt
A JWT authorization and authentication implementation with Spring Reactive Webflux, Spring Boot 2 and Spring Security 5
Stars: ✭ 190 (-5.94%)
Mutual labels:  jwt, spring-security, jwt-authentication
Php Storageless Sessions
Sessions handler which stores session data in HMAC-signed and encrypted cookies
Stars: ✭ 29 (-85.64%)
Mutual labels:  jwt, jwt-authentication, jwt-token
Go Book Store Api
Go Sample project to understand Mysql CRUD operation with best practises Includes logging, JWT, Swagger and Transactions
Stars: ✭ 18 (-91.09%)
Mutual labels:  jwt, jwt-authentication, jwt-token
Jwt
Kotlin JWT 🔑 implementation (Json Web Token) as required by APNs 🔔 (Apple Push Notifications) or Sign in with Apple 🍏
Stars: ✭ 31 (-84.65%)
Mutual labels:  jwt, jwt-authentication, jwt-token
Laravel Vue Starter
Well Documented Laravel Starter App From Development to Production. For Full Blown RESTFUL API and SPA with Beautiful UI Using Buefy / ElementUi For Reusable Vue Components
Stars: ✭ 76 (-62.38%)
Mutual labels:  jwt, jwt-authentication, jwt-token
Doorkeeper Jwt
JWT Token support for Doorkeeper
Stars: ✭ 174 (-13.86%)
Mutual labels:  jwt, jwt-token, jwt-auth
Simplemall
基于SpringCloud的微服务架构实战案例项目,以一个简单的购物流程为示例,融合spring cloud 相关组件,如spring-cloud-netflix、swagger等
Stars: ✭ 687 (+240.1%)
Mutual labels:  jwt, spring-security, jwt-authentication
Springboot Jwt Starter
A Spring Boot JWT starter kit for stateless and token-based authentication apps.
Stars: ✭ 538 (+166.34%)
Mutual labels:  jwt, spring-security, jwt-authentication
Node Express Mongoose Passport Jwt Rest Api Auth
Node, express, mongoose, passport and JWT REST API authentication example
Stars: ✭ 146 (-27.72%)
Mutual labels:  jwt, jwt-authentication, jwt-token
F License
Open Source License Key Generation and Verification Tool written in Go
Stars: ✭ 535 (+164.85%)
Mutual labels:  jwt, jwt-authentication, jwt-token
Jwtpermission
基于token验证的Java Web权限控制框架,使用jjwt,支持redis和db多种存储方式,可用于前后端分离项目,功能完善、使用简单、易于扩展。
Stars: ✭ 186 (-7.92%)
Mutual labels:  jwt, jwt-token, jwt-auth
Nest Angular
NestJS, Angular 6, Server Side Rendering (Angular Universal), GraphQL, JWT (JSON Web Tokens) and Facebook/Twitter/Google Authentication, Mongoose, MongoDB, Webpack, TypeScript
Stars: ✭ 307 (+51.98%)
Mutual labels:  jwt, jwt-authentication, jwt-auth
Jwt Auth Guard
JWT Auth Guard for Laravel and Lumen Frameworks.
Stars: ✭ 319 (+57.92%)
Mutual labels:  jwt, jwt-authentication, jwt-auth
Laravel Jwt
Laravel with JWT Authentication for API development
Stars: ✭ 31 (-84.65%)
Mutual labels:  jwt-authentication, jwt-token, jwt-auth

Jwt-Spring-Security-JPA

Travis (.org) GitHub

A demo project explaining the backend authentication using JWT (Json Web Token) authentication using Spring Security & MySQL JPA.

There's support for the following features:

  • Conventional email/username based registration with admin support
  • Conventional Login using Spring Security and generation of JWT token
  • Multiple device login and logout support
  • In memory store for blacklisting logged out tokens
  • Support for expiration bases email verification. Mail is sent upon registration.
  • Resend the email confirmation email if old one expires
  • Support for password updation once logged in
  • Support for forgot-password functionality with password reset token sent to mail.
  • Supports admin protected urls leveraging Spring security
  • API to refresh JWT tokens once the temporary JWT expires.
  • API to check availability of username/email during registration.


Swagger Docs

The project has been configured with a basic Swagger docket that exposes the commonly used API's along with the expected params. image


JWT

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

Exception Handling

The app throws custom exceptions wherever necessary which are captured through a controller advice. It then returns the appropriate error response to the caller

  • AppException
  • BadRequestException
  • ResourceAlreadyInUseException
  • ResourceNotFoundException
  • UserLoginException
  • UserRegistrationException
  • MethodArgumentNotValidException
  • UserLogoutException
  • TokenRefreshException
  • UpdatePasswordException
  • PasswordResetException
  • PasswordResetLinkException

Moreover, entities are validated using JSR-303 Validation constraints.


Steps to Setup the Spring Boot Back end app

  1. Clone the application

    git clone https://github.com/isopropylcyanide/Jwt-Spring-Security-JPA.git
    cd AuthApp
    
  2. Create a MySQL database

    create database login_db
    
  3. Change MySQL username and password as per your MySQL installation

    • open src/main/resources/application.properties file.

    • change spring.datasource.username and spring.datasource.password properties as per your mysql installation

    • open src/main/resources/mail.properties file.

    • change spring.mail.username and spring.mail.password properties as per your mail installation

  4. Run the app

    You can run the spring boot app by typing the following command -

    mvn spring-boot:run
    

    The server will start on port 9004. Token default expiration is 600000ms i.e 10 minutes.

  5. Add the default Roles

    The spring boot app uses role based authorization powered by spring security. Please execute the following sql queries in the database to insert the USER and ADMIN roles.

    INSERT INTO ROLE (ROLE_NAME) VALUES ('ROLE_USER');
    INSERT INTO ROLE (ROLE_NAME) VALUES ('ROLE_ADMIN');
    

    Any new user who signs up to the app is assigned the ROLE_USER by default.


Contribution

  • Please fork the project and adapt it to your use case.
  • Submit a pull request.

Demo Screens

  1. Registering a user

image

  1. Logging in a valid user

image

  1. Logging in an invalid user

image

  1. Using the token in request header & accessing resource

image

  1. Accessing admin resource with invalid permissions/token

image

  1. Logging out the user device

image

  1. Resetting the password

image

  1. Refreshing the authentication token

image

  1. Confirming the user email verification token

image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].