Note
Version 0.5.x supports Axum 0.8.
Version 0.5.x supports Axum 0.8.
Version 0.4.x supports Axum 0.7.
Version 0.3.x supports Axum 0.6.
Setup
Actix
[]
= { = "<version>", = ["actix-web"] }
= "4"
Axum
[]
= { = "<version>", = ["axum"] }
= "0.8"
Examples
Actix
https://github.com/trchopan/firebase-auth/tree/main/examples/actix_basic.rs
use ;
use ;
// Use `FirebaseUser` extractor to verify the user token and decode the claims
async
async
Axum
https://github.com/trchopan/firebase-auth/tree/main/examples/axum_basic.rs
use ;
use ;
async
async
async
More complete example with Axum, SQLite and slqx
This is more real world application with Firebase Authentication and SQLite as database.
Using Custom Claims
examples/actix-web-custom-claims
Custom claims are provided as defined FirebaseUser
struct and use actix or axum trait to implement the extraction from the request.
How to call the endpoint with Bearer Token
Obtain the Bearer token
Use firebase sdk to get the User Token.
For example: getIdToken()
Request the endpoint with Authorization Bearer
Make the request using the User's token. Note that it will expire so you will need to get it again if expired.
TOKEN="<paste your token here>"
curl --header "Authorization: Bearer $TOKEN" http://127.0.0.1:8080/hello
Firebase Document
Verify ID tokens using a third-party JWT library
License
Copyright (c) 2022-, Quang Tran.