All Projects → Nasruddin → spring-boot-jwt-auth

Nasruddin / spring-boot-jwt-auth

Licence: other
🔑 Sample Spring boot application secured using JWT auth in custom header(X-Auth-Token).

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to spring-boot-jwt-auth

JWTweak
Detects the algorithm of input JWT Token and provide options to generate the new JWT token based on the user selected algorithm.
Stars: ✭ 85 (+49.12%)
Mutual labels:  authorization, jwt-tokens
Spring Security React Ant Design Polls App
Full Stack Polls App built using Spring Boot, Spring Security, JWT, React, and Ant Design
Stars: ✭ 1,336 (+2243.86%)
Mutual labels:  authorization, spring-security
Cerberus
A demonstration of a completely stateless and RESTful token-based authorization system using JSON Web Tokens (JWT) and Spring Security.
Stars: ✭ 482 (+745.61%)
Mutual labels:  authorization, spring-security
secure-oauth2-oidc-workshop
Hands-On Workshop for OAuth 2.0 and OpenID Connect 1.0
Stars: ✭ 58 (+1.75%)
Mutual labels:  authorization, spring-security
Registration Login Spring Hsql
Registration and Login Example with Spring Security, Spring Boot, Spring Data JPA, HSQL, JSP
Stars: ✭ 208 (+264.91%)
Mutual labels:  authorization, spring-security
spring-boot-security-postgresql
Spring Boot, Spring Security, PostgreSQL: JWT Authentication & Authorization example
Stars: ✭ 65 (+14.04%)
Mutual labels:  authorization, spring-security
Spring Boot Oauth2 Jwt Swagger Ui
Spring Boot , OAuth 2 , JWT (Json Web Token) and Swagger UI
Stars: ✭ 77 (+35.09%)
Mutual labels:  authorization, swagger-ui
Mall
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Stars: ✭ 54,797 (+96035.09%)
Mutual labels:  spring-security, swagger-ui
Pac4j
Security engine for Java (authentication, authorization, multi frameworks): OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 2,097 (+3578.95%)
Mutual labels:  authorization, spring-security
Registration Login Spring Xml Maven Jsp Mysql
Registration and Login Example with Spring MVC, Spring Security, Spring Data JPA, XML Configuration, Maven, JSP, and MySQL.
Stars: ✭ 134 (+135.09%)
Mutual labels:  authorization, spring-security
fastapi-auth0
FastAPI authentication and authorization using auth0.com
Stars: ✭ 104 (+82.46%)
Mutual labels:  authorization, swagger-ui
Sureness
A simple and efficient open-source security framework that focus on protection of restful api.
Stars: ✭ 254 (+345.61%)
Mutual labels:  authorization, spring-security
spring-boot-login-example
Spring Boot Login and Registration example with MySQL, JWT, Rest Api - Spring Boot Spring Security Login example
Stars: ✭ 50 (-12.28%)
Mutual labels:  authorization, spring-security
opa-spring-security
Open Policy Agent for Spring Security
Stars: ✭ 19 (-66.67%)
Mutual labels:  authorization, spring-security
firebase-spring-boot-rest-api-authentication
Firebase Spring Boot Rest API Authentication
Stars: ✭ 172 (+201.75%)
Mutual labels:  authorization, spring-security
Spring Boot Webflux Jjwt
Example Spring Boot and WebFlux (Reactive Web) with Spring Security and JWT for token Authentication and Authorization
Stars: ✭ 71 (+24.56%)
Mutual labels:  authorization, spring-security
TASK-Management-System
Spring Boot and Angular 7 web application for task management .
Stars: ✭ 34 (-40.35%)
Mutual labels:  spring-security, spring-security-jwt
Spring Boot In Action
Spring Boot 系列实战合集
Stars: ✭ 4,153 (+7185.96%)
Mutual labels:  spring-security, spring-security-jwt
Sample Spring Oauth2 Microservices
some examples that show basic and more advanced implementations of oauth2 authorization mechanism in spring-cloud microservices environment
Stars: ✭ 109 (+91.23%)
Mutual labels:  authorization, spring-security
Spring Security Pac4j
pac4j security library for Spring Security: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 231 (+305.26%)
Mutual labels:  authorization, spring-security

jwt-auth-springboot

🔑 Sample Spring boot application for Authentication and Authorization

Features

  • Customizable header(X-Auth-Token) to pass Auth token.
  • JWT for token creation and validation.
  • Role based authorization.
  • Device based auth.
  • Custom Validators
  • OpenApi and Swagger integration.

Running the sample app

mvn spring-boot:run

Registering a User

curl -X POST "http://localhost:9000/api/auth/register" -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"username\":\"nasruddin\",\"password\":\"p@ssw00d\",\"device\":\"web\",\"email\":\"[email protected]\"}"
{
  "id": 1,
  "username": "nasruddin",
  "password": "$2a$10$LWgocVblwyrOolL0SyUdt.fUpqdGZ8kzddUGw4d/NeFc0f/lcHf9a",
  "email": "[email protected]",
  "lastPasswordReset": "2020-12-09T15:04:10.391+00:00",
  "authorities": "ADMIN"
}

cache-control: no-cache,no-store,max-age=0,must-revalidate 
connection: keep-alive 
content-type: application/json 
date: Wed,09 Dec 2020 15:04:10 GMT 
expires: 0 
keep-alive: timeout=60 
pragma: no-cache 
transfer-encoding: chunked 
vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers 
x-content-type-options: nosniff 
x-xss-protection: 1; mode=block 

Login a User / Fetch Token

curl -X POST "http://localhost:9000/api/auth" -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"username\":\"nasruddin\",\"password\":\"p@ssw00d\",\"device\":\"web\"}"
{
  "token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuYXNydWRkaW4iLCJhdWRpZW5jZSI6IndlYiIsImNyZWF0ZWQiOjE2MDc1MjY0NzkzMjEsImV4cCI6MTYwODEzMTI3OX0.AWNn3WcAo8E65r2nT049fKBhQoPVoAeNpENvPQp-sLJEj6ubo5bBk0waeV1mZD6Ydvqcrj0XE0LBuwE9fI3qEw"
}

 cache-control: no-cache,no-store,max-age=0,must-revalidate 
 connection: keep-alive 
 content-type: application/json 
 date: Wed,09 Dec 2020 15:07:59 GMT 
 expires: 0 
 keep-alive: timeout=60 
 pragma: no-cache 
 transfer-encoding: chunked 
 vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers 
 x-content-type-options: nosniff 
 x-xss-protection: 1; mode=block 

Accessing User/Protected API

Without setting X-AUTH-TOKEN

curl -X GET "http://localhost:9000/api/user/nasruddin" -H  "accept: */*"
{
  "timestamp": "2020-12-09T15:10:49.028+00:00",
  "status": 401,
  "error": "Unauthorized",
  "message": "",
  "path": "/api/user/nasruddin"
}

cache-control: no-cache,no-store,max-age=0,must-revalidate 
connection: keep-alive 
content-type: application/json 
date: Wed,09 Dec 2020 15:10:49 GMT 
expires: 0 
keep-alive: timeout=60 
pragma: no-cache 
transfer-encoding: chunked 
vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers 
x-content-type-options: nosniff 
x-xss-protection: 1; mode=block 

With setting X-AUTH-TOKEN

curl -X GET "http://localhost:9000/api/user/nasruddin" -H  "accept: */*" -H  "X-Auth-Token: eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuYXNydWRkaW4iLCJhdWRpZW5jZSI6IndlYiIsImNyZWF0ZWQiOjE2MDc1MjY0NzkzMjEsImV4cCI6MTYwODEzMTI3OX0.AWNn3WcAo8E65r2nT049fKBhQoPVoAeNpENvPQp-sLJEj6ubo5bBk0waeV1mZD6Ydvqcrj0XE0LBuwE9fI3qEw"
{
  "id": 1,
  "username": "nasruddin",
  "password": "$2a$10$LWgocVblwyrOolL0SyUdt.fUpqdGZ8kzddUGw4d/NeFc0f/lcHf9a",
  "email": "[email protected]",
  "lastPasswordReset": "2020-12-09T15:04:10.391+00:00",
  "authorities": "ADMIN"
}

cache-control: no-cache,no-store,max-age=0,must-revalidate 
 connection: keep-alive 
 content-type: application/json 
 date: Wed,09 Dec 2020 15:12:19 GMT 
 expires: 0 
 keep-alive: timeout=60 
 pragma: no-cache 
 transfer-encoding: chunked 
 vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers 
 x-content-type-options: nosniff 
 x-xss-protection: 1; mode=block 

Admin API

curl -X GET "http://localhost:9000/api/admin" -H  "accept: */*" -H  "X-Auth-Token: eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuYXNydWRkaW4iLCJhdWRpZW5jZSI6IndlYiIsImNyZWF0ZWQiOjE2MDc1Mjc1MTUzNjMsImV4cCI6MTYwODEzMjMxNX0.zHcWtUW43dXOQs8WGy1ItrMyc8gyBNf8j_irFz09lGkR7flYsNi3-o8mjYe1rqjg4SzcG8qRdbqEC7dvGASjTQ"
:O

cache-control: no-cache,no-store,max-age=0,must-revalidate 
connection: keep-alive 
content-length: 2 
content-type: text/plain;charset=UTF-8 
date: Wed,09 Dec 2020 15:26:01 GMT 
expires: 0 
keep-alive: timeout=60 
pragma: no-cache 
vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers 
x-content-type-options: nosniff 
x-xss-protection: 1; mode=block 

OpenAPI Swagger

Swagger

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