https://github.com/emvakar/fjwtmiddleware
FJWTMiddleware is middleware for server applications based on Vapor Framework. This project provides JSON Web Token (JWT) authentication using Firebase Authentication as the authentication provider.
https://github.com/emvakar/fjwtmiddleware
authentication firebase jwt server server-side-swift swift vapor
Last synced: 11 months ago
JSON representation
FJWTMiddleware is middleware for server applications based on Vapor Framework. This project provides JSON Web Token (JWT) authentication using Firebase Authentication as the authentication provider.
- Host: GitHub
- URL: https://github.com/emvakar/fjwtmiddleware
- Owner: emvakar
- Created: 2023-03-24T13:32:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-17T20:53:35.000Z (over 2 years ago)
- Last Synced: 2025-01-31T02:01:34.757Z (about 1 year ago)
- Topics: authentication, firebase, jwt, server, server-side-swift, swift, vapor
- Language: Swift
- Homepage: http://www.karimov.tech/fjwt
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FJWTMiddleware
This project is built upon an existing [vapor-firebase-jwt-middleware](https://github.com/barisatamer/vapor-firebase-jwt-middleware.git) repository, which has not been maintained for a long time and has not merged my pull requests. Due to this, I decided to create my own repository for this project, starting with the codebase of the unsupported one.
## Description 🎧
FJWTMiddleware is middleware for server applications based on Vapor Framework. This project provides JSON Web Token (JWT) authentication using Firebase Authentication as the authentication provider.
To use this middleware, you need to create a Firebase project and add its configuration data to the server settings. In addition, you need to configure routes in the Vapor application that will be protected by authentication, and then add the middleware to provide JWT verification.
After successful JWT verification, the application can obtain user data from the token and use it for its purposes.
This project provides a ready-made solution for JWT authentication using Firebase, which simplifies the development of server applications based on Vapor Framework and reduces the time and effort required to implement an authentication system.
## Installation 📦
To include it in your package, add the following to your `Package.swift` file.
```swift
let package = Package(
name: "Project",
dependencies: [
...
.package(name: "FJWTMiddleware", url: "https://github.com/emvakar/vapor-fjwt-middleware.git", from: "1.0.0"),
],
targets: [
.target(name: "App", dependencies: [
.product(name: "FJWTMiddleware", package: "FJWTMiddleware"),
...
])
]
)
```
## Usage 🚀
1. **Configure Project ID**
```swift
app.firebaseJwt.applicationIdentifier =
```
2. **Import header files**
```swift
import FJWTMiddleware
```
3. **Adding Middleware to a Routing Group**
```swift
let group = router.grouped(FJWTMiddleware())
group.get("welcome") { req in
return "Hello, world!"
}
```
## References
- [Verifying Firebase ID Tokens](https://firebase.google.com/docs/auth/admin/verify-id-tokens?authuser=1)