All Projects → TransEmpiric → Webfluxtemplate

TransEmpiric / Webfluxtemplate

Licence: mit
Spring Webflux template application with working Spring Security, Web-sockets, Rest, Web MVC, and Authentication with JWT.

Programming Languages

java
68154 projects - #9 most used programming language
java8
65 projects

Projects that are alternatives of or similar to Webfluxtemplate

Cerberus
A demonstration of a completely stateless and RESTful token-based authorization system using JSON Web Tokens (JWT) and Spring Security.
Stars: ✭ 482 (+350.47%)
Mutual labels:  restful-api, spring-boot, spring, spring-security, json-web-token
Mall
mall项目是一套电商系统,包括前台商城系统及后台管理系统,基于SpringBoot+MyBatis实现,采用Docker容器化部署。 前台商城系统包含首页门户、商品推荐、商品搜索、商品展示、购物车、订单流程、会员中心、客户服务、帮助中心等模块。 后台管理系统包含商品管理、订单管理、会员管理、促销管理、运营管理、内容管理、统计报表、财务管理、权限管理、设置等模块。
Stars: ✭ 54,797 (+51112.15%)
Mutual labels:  mongodb, spring-boot, spring, 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 (-33.64%)
Mutual labels:  reactive, spring-boot, spring, spring-security
Spring Boot Demo
Spring Boot & Spring Cloud & Spring Security Demo Case(Spring学习示例实战项目)
Stars: ✭ 255 (+138.32%)
Mutual labels:  mongodb, spring-boot, spring, websocket
Atom
Java course materials
Stars: ✭ 293 (+173.83%)
Mutual labels:  gradle, spring-boot, spring, websocket
Springboot Starterkit
Starter Kit for Spring Boot based (REST APIs and WebMVC) micro services.
Stars: ✭ 596 (+457.01%)
Mutual labels:  mongodb, spring-boot, spring, spring-security
Spring Webflux Security Jwt
A JWT authorization and authentication implementation with Spring Reactive Webflux, Spring Boot 2 and Spring Security 5
Stars: ✭ 190 (+77.57%)
Mutual labels:  reactive, spring-boot, spring-security, jwt-authentication
Java Spring Cloud
Distributed tracing for Spring Boot, Cloud and other Spring projects
Stars: ✭ 326 (+204.67%)
Mutual labels:  mongodb, spring-boot, spring, websocket
Mmorpg
springboot编写的轻量级高性能mmorpg手游服务端框架,基本功能逐渐完善中。
Stars: ✭ 309 (+188.79%)
Mutual labels:  gradle, spring-boot, spring, websocket
Springboot Jwt Starter
A Spring Boot JWT starter kit for stateless and token-based authentication apps.
Stars: ✭ 538 (+402.8%)
Mutual labels:  spring-boot, spring, spring-security, jwt-authentication
Hex Arch Kotlin Spring Boot
Reference JVM multi module project for a reactive micro service and lambda using a hexagonal architecture, DDD, Kotlin, Spring Boot, Quarkus, Lambda, Gradle.
Stars: ✭ 83 (-22.43%)
Mutual labels:  gradle, reactive, spring-boot, spring
Eshop Soa
EShop基于Dubbo实现SOA服务化拆分,并基于RocketMQ解决了分布式事务(新版SpringBootSOASkeleton)
Stars: ✭ 65 (-39.25%)
Mutual labels:  spring-boot, spring, spring-security
Microservices Example
Example of a microservices architecture on the modern stack of Java technologies
Stars: ✭ 66 (-38.32%)
Mutual labels:  gradle, spring-boot, microservices-architecture
Sample Boot Hibernate
Spring Boot + JPA ( Hibernate ) + Java8 [ DDD Sample ]
Stars: ✭ 97 (-9.35%)
Mutual labels:  gradle, spring-boot, spring-security
Restfeel
RESTFeel: 一个企业级的API管理&测试平台。RESTFeel帮助你设计、开发、测试您的API。
Stars: ✭ 59 (-44.86%)
Mutual labels:  restful-api, gradle, mongodb
Springboot security restful api
SpringBoot + SpringSecurity + RESTful API --- Maven Project Demo
Stars: ✭ 68 (-36.45%)
Mutual labels:  restful-api, spring-boot, spring-security
Spring Cloud Microservices Development
Spring Cloud Microservices Development.《Spring Cloud 微服务架构开发实战》
Stars: ✭ 106 (-0.93%)
Mutual labels:  gradle, spring-boot, spring
Okta Blog Archive
Okta Developer Blog
Stars: ✭ 74 (-30.84%)
Mutual labels:  gradle, spring-boot, spring
Awbeci Ssb
spring spring-boot spring-security spring-social
Stars: ✭ 102 (-4.67%)
Mutual labels:  spring-boot, spring, spring-security
Springboard
Spring Boot based production grade starter kit.
Stars: ✭ 59 (-44.86%)
Mutual labels:  spring-boot, spring, spring-security

Spring 5 Webflux Template

This code can be used to build the next generation of applications using micro-services, reactive programing, webs-sockets, rest, mongoDB, JWT (JSON Web Tokens) and Netty.

What is this again?

This is a complete template example for Spring 5 Webflux. The application shows how to use Spring 5 Webflux with Spring Security, web-sockets, @RestContorler, @Controller, Reactive MongoDB, and JWT.

Spring 5 is still new. There are very few examples of how to use Spring Security with the Webflux stack. Reactive Oauth2 support is not ready yet. This application roles it's own Oauth2 like api with JWT tokens. This app has integrated web-sockets and rest services into the Reactive Spring Security implementation.

MongoDB

MongoDB is used for this example, so you'll need this up and running on your local machine, if you are on OSX, you can easily install MongoDB using Homebrew. The MongoDB config is defined in application.yml.

Running locally

	git clone https://github.com/TransEmpiric/webFluxTemplate.git
	cd webFluxTemplate
	./gradlew bootRun

If everything goes well you can go to the Secure Web-socket Example page http://localhost:8443/test/ws

Get a JWT for authentication

Endpoint:
http://localhost:8443/auth/token

Method:
POST:

Request headers:

content-type: application/json

Body:

{"username" : "jdev", "password":"jdev"}

Response:

{
"token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqZGV2IiwiYXVkIjoidW5rbm93biIsImV4cCI6MjEyMTcwNzgyMiwiaWF0IjoxNTE2OTA3ODIyfQ.TVwbWsz-BDfMQmgUDnB_GloXklEdS_ABMiF9iGzHrBNA1f4yOQb3day7vcFLNxcLefkQjZDlVlpU91AtkzQqLg",
"username": "jdev"
}

Use JWT on a secure rest endpoint

Endpoint:
http://localhost:8443/api/rest/user/list:

Method:
GET:

Request headers:

Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqZGV2IiwiYXVkIjoidW5rbm93biIsImV4cCI6MjEyMTcwNzgyMiwiaWF0IjoxNTE2OTA3ODIyfQ.TVwbWsz-BDfMQmgUDnB_GloXklEdS_ABMiF9iGzHrBNA1f4yOQb3day7vcFLNxcLefkQjZDlVlpU91AtkzQqLg

Response:

[
   {
      "id":"5a6a2ef094bf49a0b8319a30",
      "username":"jdev",
      "firstname":"Joe",
      "lastname":"Developer",
      "email":"[email protected]",
      "roles":[
         "ROLE_ADMIN"
      ],
      "enabled":true,
      "lastPasswordResetDate":1516908272107,
      "accountNonExpired":true,
      "accountNonLocked":true,
      "credentialsNonExpired":true,
      "authorities":[
         {
            "authority":"ROLE_ADMIN"
         }
      ]
   }
]

Use JWT on a secure web-socket endpoint

Go to http://localhost:8443/test/ws in a browser. JWT is hard coded in the JS within templates/websocket.ftl You need to replace with a new token if the hard coded token has expired

    <script type="application/javascript">
        // Use wss:// for HTTPS
        var socket = new WebSocket("ws://" + location.host + "/api/ws/echotest?token=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqZGV2IiwiYXVkIjoidW5rbm93biIsImV4cCI6MjEyMTYwODkyMywiaWF0IjoxNTE2ODA4OTIzfQ.QdSkOuGb8tp1QKjRKzUPlUqobNzF0PuDNk4Y7qAXqrVdbVaKiNJPalxUYapDoeQxE_Dz9WqhdrpdLpGQnlgkkw");

        addEvent("keypress", document.getElementById('input'), function(event) {
            socket.send(event.key);
        });
        var output = document.getElementById("output");
        socket.onmessage = function(e) {
            output.innerHTML = output.innerHTML + e.data;
        }
    </script>

Properties

Properties are in application.yml
You can set to HTTPS (test cert works) if you want, but make sure to update the call to web-socket endpoints with "wss://"

WILLDO

Verify password at auth end point with CustomPasswordEncoder
Make a UI for example token retrieval and a UI to use it
Finish Refresh Token code
Add React and/or Angular Front-end example to repo
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].