-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24fa991
commit 749a88c
Showing
2 changed files
with
31 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Petr Pavlik on 21.01.2024. | ||
// | ||
|
||
import Vapor | ||
import FirebaseJWTMiddleware | ||
|
||
protocol JWTUser { | ||
var userID: String { get } | ||
var email: String? { get } | ||
} | ||
|
||
extension FirebaseJWTPayload : JWTUser { | ||
|
||
} | ||
|
||
extension Request { | ||
var jwtUser: some JWTUser { | ||
get async throws { | ||
// This is where you can swap Firebase Auth for another JWT-based provider (Amazon Congnito, Clerk, ...) | ||
try await self.firebaseJwt.asyncVerify() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters