Vaadin Flow example with JWT authentication

Overview

Vaadin Flow example with JWT authentication

This example project is generated using start.vaadin.com, with Spring Security on. After that the Spring Security configuration is modified so that it JWT is used to store the authentication information, instead of the usual Java Servlet Session.

Even though Vaadin Flow app needs session for end-users anyways, this approach improves developer and end user experience when deploying new versions (no need to re-login when new UI is deployed).

The HelloWorldView contains a hack that makes this rather trivial Vaadin UI non-serializable and this way lose the session on server restart. This is just to make testing the approach easier. To compare to "default behaviour", uncomment the JWT configuration from SecurityConfiguration and restart the application (also clear cookies).

Running the application

The project is a standard Maven project. To run it from the command line, type mvnw (Windows), or ./mvnw (Mac & Linux), then open http://localhost:8080 in your browser.

You can also import the project to your IDE of choice as you would with any Maven project. Read more on how to import Vaadin projects to different IDEs (Eclipse, IntelliJ IDEA, NetBeans, and VS Code).

Deploying to Production

To create a production build, call mvnw clean package -Pproduction (Windows), or ./mvnw clean package -Pproduction (Mac & Linux). This will build a JAR file with all the dependencies and front-end resources, ready to be deployed. The file can be found in the target folder after the build completes.

Once the JAR file is built, you can run it using java -jar target/flowwithjwtauthentication-1.0-SNAPSHOT.jar

Project structure

  • MainLayout.java in src/main/java contains the navigation setup (i.e., the side/top bar and the main menu). This setup uses App Layout.
  • views package in src/main/java contains the server-side Java views of your application.
  • views folder in frontend/ contains the client-side JavaScript views of your application.
  • themes folder in frontend/ contains the custom CSS styles.

Useful links

You might also like...

An intelliJ plugin providing a UI layer for git-flow, which in itself is a collection of Git extensions to provide high-level repository operations for Vincent Driessen's branching model.

An intelliJ plugin providing a UI layer for git-flow, which in itself is a collection of Git extensions to provide high-level repository operations for Vincent Driessen's branching model.

Git Flow Integration Plus for Intellij An intelliJ plugin providing a UI layer for git-flow, which in itself is a collection of Git extensions to prov

Nov 8, 2022

Zero-Dependency RFC 8252 OAuth 2.0 Authorization Flow

Tiny OAuth2 Client This is a minimal zero-dependency implementation of the RFC 8252 OAuth 2.0 for Native Apps, relying on Loopback Interface Redirecti

Jun 17, 2022

This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practical coding example and required JAR dependencies

SpringMVC-Database-Integration This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practic

Nov 2, 2021

A Spring Security based Authentication microservice with MySQL

Spring Security Microservice using JWT and MySQL Background This is an open source, production-ready application that provides role-based user authent

Sep 28, 2021

Mc-msa-token-getter - Scripts to retrieve MC authentication tokens for use in modding dev envs.

Minecraft MSA Token Getter Python and Java scripts to retrieve MC authentication tokens for use in modding dev envs. Requires a properly configured Az

Jan 3, 2022

Authentication and authorization for application, api and user

多树AUTH / MT-AUTH 用户,应用,API管理中心 MT-AUTH是一款基于Spring Boot, OAuth2与事件驱动的角色的权限管理(RBAC)系统,通过集成Spring Cloud Gateway实现了API鉴权,缓存,跨域,CSRF防护,特殊字符过滤等常用功能 项目特点 基于事

Dec 14, 2022

⚡️ Capacitor plugin for Firebase Authentication.

⚡️ Capacitor plugin for Firebase Authentication.

⚠️ Deprecated repository This project has been moved to the following monorepo: robingenz/capacitor-firebase. Firebase Authentication @robingenz/capac

Oct 9, 2022

:herb: 基于springboot的快速学习示例,整合自己遇到的开源框架,如:rabbitmq(延迟队列)、Kafka、jpa、redies、oauth2、swagger、jsp、docker、spring-batch、异常处理、日志输出、多模块开发、多环境打包、缓存cache、爬虫、jwt、GraphQL、dubbo、zookeeper和Async等等:pushpin:

:herb: 基于springboot的快速学习示例,整合自己遇到的开源框架,如:rabbitmq(延迟队列)、Kafka、jpa、redies、oauth2、swagger、jsp、docker、spring-batch、异常处理、日志输出、多模块开发、多环境打包、缓存cache、爬虫、jwt、GraphQL、dubbo、zookeeper和Async等等:pushpin:

欢迎大家留言和PR~ Tip: 技术更新换代太快,本仓库仅做参考,自己的项目具体使用哪个版本还需谨慎思考~(不推荐使用最新的版本,推荐使用(最新-1|2)的版本,会比较稳定) spring-boot-quick 前言   自己很早就想搞一个总的仓库就是将自己平时遇到的和学习到的东西整合在一起,方便后

Jan 2, 2023
Owner
Matti Tahvonen
Developer advocate working at @Vaadin. Web apps since '90s with Perl, Java, PHP, JavaScript...
Matti Tahvonen
ReactJS, Spring Boot JWT Authentication Example

springboot-reactjs-jwt-authentication ReactJS - SpringBoot - JWT - Flow Local setup Step 1: Download or clone the source code from GitHub to a local m

Sibin Rasiya 16 Dec 2, 2022
Spring Boot Refresh Token using JWT example - Expire and Renew JWT Token

Spring Boot Refresh Token with JWT example Build JWT Refresh Token in the Java Spring Boot Application. You can know how to expire the JWT, then renew

null 152 Dec 28, 2022
Spring Boot Login and Registration example with MySQL, JWT, Rest Api - Spring Boot Spring Security Login example

Spring Boot Login example with Spring Security, MySQL and JWT Appropriate Flow for User Login and Registration with JWT Spring Boot Rest Api Architect

null 58 Jan 5, 2023
Spring Boot Security Login example with JWT and H2 example

Spring Boot Security Login example with JWT and H2 example Appropriate Flow for User Login and Registration with JWT and HttpOnly Cookie Spring Boot R

null 50 Dec 21, 2022
Build your own Minecraft authentication system with Mojang authentication server support.

Build your own Minecraft authentication system with Mojang authentication server support. A fork of yushijinhun/authlib-injector.

Ethan Zuo 15 Dec 17, 2022
Spring Boot REST API authentication best practices using JWT

Spring Boot REST API authentication best practices using JWT Token based API authentication with Spring Security and JWT (JSON web Token) Overview Thi

Prafful Lachhwani 34 Dec 22, 2022
Implementing JWT authentication with spring boot.

Jwt-SpringBoot Implementing JWT authentication with spring boot. Normally you would create an endpoint to create the credentials(token), then this tok

@#aeyarm 2 May 7, 2022
Squadio-App is a Users-Accounts financial system. exposes Rest APIs with JWT authentication/Authorization process .

squadio-app Description Squadio-App is a Users-Accounts financial system. exposes Rest APIs with JWT authentication/Authorization process . How to Run

Bashar Othman 1 Jan 29, 2022
Spring REST API for financial management, developed with Java 11, JWT for authentication, JUnit for unit testing and Oracle Database

control_financial Spring REST API for financial management, developed with Java 11, JWT for authentication, JUnit for unit testing and Oracle Database

Vinicius Cassaro 1 May 27, 2022
Spring Boot & MongoDB Login and Registration example with JWT, Spring Security, Spring Data MongoDB

Spring Boot Login and Registration example with MongoDB Build a Spring Boot Auth with HttpOnly Cookie, JWT, Spring Security and Spring Data MongoDB. Y

null 15 Dec 30, 2022