in firebase, Spring, Spring boot

Firebase and Spring boot integration

Firebase can be integrated into the backend so that clients that are authenticated with firebase can call backend REST APIs.

To accomplish this few key parts must be added to the backend

  1. Maven Dependencies
  2. Filter
  3. Authentication provider
  4. Token parsing
  5. Registration

GitHub repository isĀ here.

To add firebase dependencies one library must be added

Every request to the backend must have especial header that is used by FirebaseFilter. Filter checks if header named “X-Authorization-Firebase” exists, if does not this means that request should not be processed by this filter. When token is found it is parsed using firebaseService.parseToken(xAuth) and correct Authentication is created FirebaseAuthenticationToken that is put in the securityContextHolder. Job of the filter is here done and authentication process is being taken over by authentication provider.

Authentication provider uses the FirebaseAuthenticationToken to map the token to database user and set its roles.

Firebase backend configuration is done in one Configuration class. Here I have added firebase reference bean and initialization.

Initialization of firebase depends of two properties , configuration path and database url.

This is it. Be sure to checkout the GitHub repository here.

https://github.com/savicprvoslav/Spring-Boot-starter

 

Write a Comment

Comment

  1. Hello.
    I have an android application in which a driver gets authentificated through firebase. then when a client sends his request, the request goes to a spring boot server. my server should get access to myfirebase DB of drivers to gets longitude and latitude of the closest driver. how can i implement that ? how can a spring boot server get access to an android firebase DB project. thank u