A Vaadin example application that use Firebase Authentication as its user database

Overview

Vaadin + Firebase Auth example

A trivial example to use Firebase Authentication with a Vaadin application. The app is built based on start.vaadin.com template, with Spring Security setup enabled, but instead of storing users in local JPA backend, Firebase Authentication is used.

This example uses the "web" library to create the access token on the browser side and then shares that with the Vaadin application. An alternative approach would be to implement this completely on the server side by doing to the authentication request as described in this SoF response or by checking if the official Android library could be used.

Things to check out in this example.

  • FirebaseService class. A class that initializes Firebase server side API, populates demo data if needed, and validates the token coming from client. and transforms into Authentication object for Spring Security.
  • LoginView and its client side code in frontend/login.ts. This uses Vaadin Login element (could just use simple inputs as well) and Firebase JS modules to login. The token is then sent to server, validated and stores an Authentication based on the token details in Spring Security context (saved further in Java session).
  • Adapted Spring Security configuartion in the security package.

Improvements needed for larger app

  • Currently the example doesn't support roles, but those should be rather easy to implement with "custom claims".
  • Session persistency. Currently, the token passed to server side will probably become invalid even if user Vaadin session is active. Should timely pass the refreshed token to the server side. Service worker appraoch could be used. Or just fetching the refreshed token asynchronously when the session should be verified.

Running the application

To run the example yourself, you'll need to create a Firebase Project and enable Firebase Authentication (refer to their docs). The GOOGLE_APPLICATION_CREDENTIALS environment variable needs to contain the path to your app credentials (or change the behaviour in FirebaseService) and you need to replace the Web/JS firebaseConfig with your Firebase web config in login.ts file.

Useful links

You might also like...

A small and easy-to-use one-time password generator library for Java according to RFC 4226 (HOTP) and RFC 6238 (TOTP).

OTP-Java A small and easy-to-use one-time password generator for Java according to RFC 4226 (HOTP) and RFC 6238 (TOTP). Table of Contents Features Ins

Dec 30, 2022

Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Dec 29, 2022

Tink is a multi-language, cross-platform, open source library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.

Tink A multi-language, cross-platform library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse. Ubuntu

Jan 3, 2023

Unofficial Clubhouse web app client. For personal use only. It's a personal open-source project and not affiliated with any company.

Unofficial Clubhouse web app client. For personal use only. It's a personal open-source project and not affiliated with any company.

Purpose of this web app That's a personal project and not affiliated with any company. This is the web client app to make your Club House experience b

Nov 15, 2022

Are you suffering from forgetting to do HoYoLAB check-in? Use this and be free from it!

Are you suffering from forgetting to do HoYoLAB check-in? Use this and be free from it!

GADC 가득 Auto Daily Check-in for Genshin Impact Are you suffering from forgetting to do HoYoLAB check-in? Use this and be free from it! 원신 일일 출첵 매일 까먹으

Jul 11, 2022

Messenger - A Java based project making use of Sockets for communication between the applications running on different JRE

Messenger - A Java based project making use of Sockets for communication between the applications running on different JRE. Multiple clients can connect at the same time and can send messages to each other, they also get the information of status of their friends connected to the server .

Jan 2, 2022

A small and easy-to-use one-time password generator library for Java according to RFC 4226 (HOTP) and RFC 6238 (TOTP).

OTP-Java A small and easy-to-use one-time password generator for Java according to RFC 4226 (HOTP) and RFC 6238 (TOTP). Table of Contents Features Ins

Dec 30, 2022

Removal of JndiLookup in now obsolete Minecraft versions, or versions that still have log4j 2.10 and is unable to use

NukeJndiLookupFromLog4j Removal of JndiLookup in now obsolete Minecraft versions, or versions that still have log4j 2.10 and is unable to use -Dlog4

Dec 15, 2022

Hdiv CE | Application Self-Protection

Hdiv CE | Application Self-Protection

New to Hdiv? Check this out Hdiv: Application Self-Protection Hdiv is a leading provider of open source software for real-time, self-protected applica

Nov 14, 2022
Owner
Matti Tahvonen
Developer advocate working at @Vaadin. Web apps since '90s with Perl, Java, PHP, JavaScript...
Matti Tahvonen
Security engine for Java (authentication, authorization, multi frameworks): OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...

pac4j is an easy and powerful security engine for Java to authenticate users, get their profiles and manage authorizations in order to secure web appl

PAC4J 2.2k Dec 30, 2022
JAP is an open source authentication middleware, it is highly decoupled from business code and has good modularity and flexiblity. Developers could integrate JAP into web applications effortlessly.

?? JAP 是什么? JAP 是一款开源的登录中间件,基于模块化设计,并且与业务高度解耦,使用起来非常灵活,开发者可以毫不费力地将 JAP 集

Fujie 140 Dec 1, 2022
A simple HWID authentication system for your minecraft mod.

HWID-Authentication-System A simple HWID authentication system for your minecraft mod. This is a simple mod which can prevent unwanted users from runn

null 43 Dec 10, 2022
A simple HWID authentication system for your minecraft mod.

HWID-Authentication-System A simple HWID authentication system for your minecraft mod. This is a simple mod which can prevent unwanted users from runn

null 43 Dec 10, 2022
Password4j is a user-friendly cryptographic library that supports Argon2, Bcrypt, Scrypt, PBKDF2 and various cryptographic hash functions.

Password4j is a Java user-friendly cryptographic library for hashing and checking passwords with different Key derivation functions (KDFs) and Cryptog

Password4J 246 Jan 5, 2023
simple interface to verify user authenticity

React Native Simple Biometrics A simple and straight forward API to ask a user to authenticate with on device biometrics. This can be used to quickly

smallcase 135 Dec 29, 2022
AES block cipher modes with user interface.

AES Ciphers An implementation of The common AES block cipher modes of operations (ECB, CBC, CTR), with user interface. It allows you to encrypt and de

Abd El-Twab M. Fakhry 6 Nov 21, 2022
JNDI-Exploit is an exploit on Java Naming and Directory Interface (JNDI) from the deleted project fromthe user feihong on GitHub.

JNDI-Exploit JNDI-Exploit is a fork from the deleted project ftom the user feihong-cs on GitHub. To learn more about JNDI and what you can do with thi

Nil MALHOMME 4 Dec 6, 2022
Example Java Cryptographic License Files

Example of verifying cryptographically signed and encrypted license files using Java, Bouncy Castle, Ed25519 and AES-256-GCM

Keygen 1 Apr 1, 2022
Employee Management System using Spring Boot, Spring Security, Thymeleaf and MySQL database.

Employee Management System Employee Management System using Spring Boot, Spring Security, Thymeleaf and MySQL database. YouTube Video Series Employee

Ramesh Fadatare 62 Jan 1, 2023