All Projects → shuaicj → Zuul Auth Example

shuaicj / Zuul Auth Example

Licence: mit
Use Zuul and Spring Security for a global authentication.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Zuul Auth Example

Simplemall
基于SpringCloud的微服务架构实战案例项目,以一个简单的购物流程为示例,融合spring cloud 相关组件,如spring-cloud-netflix、swagger等
Stars: ✭ 687 (+153.51%)
Mutual labels:  zuul, spring-security, jwt-authentication
Springcloud Shop
基于Spring Boot、Spring Cloud的微服务商城demo
Stars: ✭ 198 (-26.94%)
Mutual labels:  zuul, spring-security
Sample Spring Oauth2 Microservices
some examples that show basic and more advanced implementations of oauth2 authorization mechanism in spring-cloud microservices environment
Stars: ✭ 109 (-59.78%)
Mutual labels:  zuul, 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 (-81.55%)
Mutual labels:  spring-security, jwt-authentication
Spring Webflux Security Jwt
A JWT authorization and authentication implementation with Spring Reactive Webflux, Spring Boot 2 and Spring Security 5
Stars: ✭ 190 (-29.89%)
Mutual labels:  spring-security, jwt-authentication
Jwt Spring Security Jpa
Backend MVP showcasing JWT (Json Web Token) authentication with multiple login, timeout / refresh / logout (with in memory invalidation) using Spring Security & MySQL JPA.
Stars: ✭ 202 (-25.46%)
Mutual labels:  spring-security, jwt-authentication
spring-boot-refresh-token-jwt
Spring Boot Refresh Token using JWT example - Expire and Renew JWT Token
Stars: ✭ 156 (-42.44%)
Mutual labels:  spring-security, jwt-authentication
Spring Boot Spring Security Jwt Authentication
Spring Boot + Security: Token Based Authentication example with JWT, Authorization, Spring Data & MySQL
Stars: ✭ 292 (+7.75%)
Mutual labels:  spring-security, jwt-authentication
spring-examples
Starter projects with Spring using Java and Kotlin. Contains modules that covers Security with JWT, Spring with Kotlin, Dependency injection simplified etc.
Stars: ✭ 33 (-87.82%)
Mutual labels:  spring-security, jwt-authentication
jersey-jwt-springsecurity
Example of REST API with JWT authentication using Spring Boot, Spring Security, Jersey and Jackson.
Stars: ✭ 44 (-83.76%)
Mutual labels:  spring-security, jwt-authentication
Jwt Spring Security Demo
This is a demo for using JWT (JSON Web Token) with Spring Security and Spring Boot. I completely rewrote my first version. Now this solution is based on the code base from the JHipster Project. I tried to extract the minimal configuration and classes that are needed for JWT-Authentication and did some changes.
Stars: ✭ 2,843 (+949.08%)
Mutual labels:  spring-security, jwt-authentication
Clean Architecture Delivery Example
A example of clean architecture in Java 8 and Spring Boot 2.0
Stars: ✭ 140 (-48.34%)
Mutual labels:  spring-security, jwt-authentication
Webfluxtemplate
Spring Webflux template application with working Spring Security, Web-sockets, Rest, Web MVC, and Authentication with JWT.
Stars: ✭ 107 (-60.52%)
Mutual labels:  spring-security, jwt-authentication
spring-boot-security-postgresql
Spring Boot, Spring Security, PostgreSQL: JWT Authentication & Authorization example
Stars: ✭ 65 (-76.01%)
Mutual labels:  spring-security, jwt-authentication
Springboot Jwt Starter
A Spring Boot JWT starter kit for stateless and token-based authentication apps.
Stars: ✭ 538 (+98.52%)
Mutual labels:  spring-security, jwt-authentication
angular-11-spring-boot-jwt-authentication
Angular 11 Spring Boot JWT Authentication example with Authorization | User Registration & Login
Stars: ✭ 62 (-77.12%)
Mutual labels:  spring-security, jwt-authentication
zainabed-spring-security-jwt
Authentication & Authorization module for standalone Spring Boot app or Spring Cloud applications
Stars: ✭ 24 (-91.14%)
Mutual labels:  spring-security, jwt-authentication
TASK-Management-System
Spring Boot and Angular 7 web application for task management .
Stars: ✭ 34 (-87.45%)
Mutual labels:  spring-security, jwt-authentication
spring-security-jwt-csrf
A demonstration of stateless JWT authentication with Spring Security, Spring Boot and Vue js
Stars: ✭ 62 (-77.12%)
Mutual labels:  spring-security, jwt-authentication
SpringBoot
SpringBoot SpringCloud开发整合
Stars: ✭ 31 (-88.56%)
Mutual labels:  spring-security

Zuul Auth Example

Use Zuul and Spring Security for a global authentication via the popular JWT token.

Modules

1. auth-center

The service to issue the JWT token.

  • The client POST {username,password} to /login.
  • This service will authenticate the username and password via Spring Security, generate the token, and issue it to client.
2. backend-service

Provide three simple services:

  • /admin
  • /user
  • /guest
3. api-gateway

The Zuul gateway:

  • Define Zuul routes to auth-center and backend-service.
  • Verify JWT token.
  • Define role-based auth via Spring Security:
    • /login is public to all.
    • /backend/admin can only be accessed by role ADMIN.
    • /backend/user can only be accessed by role USER.
    • /backend/guest is public to all.

Run and Verify

1. Compile and package
mvn clean package
2. Start services
java -jar auth-center/target/auth-center-1.0.0.jar
java -jar backend-service/target/backend-service-1.0.0.jar
java -jar api-gateway/target/api-gateway-1.0.0.jar
3. Get tokens
curl -i -H "Content-Type: application/json" -X POST -d '{"username":"shuaicj","password":"shuaicj"}' http://localhost:8080/login

You will see the token in response header for user shuaicj. Note that the status code 401 will be returned if you provide incorrect username or password. And similarly, get token for user admin:

curl -i -H "Content-Type: application/json" -X POST -d '{"username":"admin","password":"admin"}' http://localhost:8080/login

The user admin is defined with two roles: USER and ADMIN, while shuaicj is only a USER.

4. Verify

The general command to verify if the auth works is as follows:

curl -i -H "Authorization: Bearer token-you-got-in-step-3" http://localhost:8080/backend/user

or without token:

curl -i http://localhost:8080/backend/user

You can change the token and the URL as need. To sum up, the following table represents all possible response status codes while sending requests to different URLs with different tokens:

/backend/admin /backend/user /backend/guest
admin token (role USER ADMIN) 200 200 200
shuaicj token (role USER) 403 200 200
no token 401 401 200
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].