From d2553dac16eaa4a8b597a0bf8eed322ebc77736d Mon Sep 17 00:00:00 2001 From: rpm-mcarman <65228808+rpm-mcarman@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:17:40 -0400 Subject: [PATCH] Committing changes --- Package.resolved | 4 ++-- Package.swift | 2 +- Sources/App/Models/mdlAssociate.swift | 10 ++++++++++ Sources/App/configure.swift | 23 +++++++++-------------- Sources/App/routes.swift | 3 +++ 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Package.resolved b/Package.resolved index d0ec225..b0fa620 100644 --- a/Package.resolved +++ b/Package.resolved @@ -68,8 +68,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/vapor/jwt-kit.git", "state" : { - "revision" : "e05513b5aec24f88012b6e3034115b6bc915356a", - "version" : "4.13.2" + "revision" : "c2595b9ad7f512d7f334830b4df1fed6e917946a", + "version" : "4.13.4" } }, { diff --git a/Package.swift b/Package.swift index c1b30ce..fbbf189 100644 --- a/Package.swift +++ b/Package.swift @@ -13,7 +13,7 @@ let package = Package( .package(url: "https://github.com/vapor/fluent.git", from: "4.9.0"), // 🐘 Fluent driver for Postgres. .package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.8.0"), - .package(url: "https://github.com/vapor/jwt.git", from: "4.0.0-rc.1"), + .package(url: "https://github.com/vapor/jwt.git", from: "4.2.2"), ], targets: [ .executableTarget( diff --git a/Sources/App/Models/mdlAssociate.swift b/Sources/App/Models/mdlAssociate.swift index fac4b32..afd15e3 100644 --- a/Sources/App/Models/mdlAssociate.swift +++ b/Sources/App/Models/mdlAssociate.swift @@ -10,6 +10,7 @@ import Fluent import Vapor import Foundation import FluentKit +import JWT final class mdlAssociate: Model, Content { static let schema = "associate" @@ -42,6 +43,15 @@ final class mdlAssociate: Model, Content { } } extension mdlAssociate{ + struct User: JWTPayload{ + var id: Int + var email: String + var password: String + + func verify(using signer: JWTSigner) throws{ + + } + } struct Create: AsyncMigration { func prepare(on database: Database) async throws { try await database.schema("associate") diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index b24fc25..9c2ff2d 100644 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -2,28 +2,23 @@ import NIOSSL import Fluent import FluentPostgresDriver import Vapor -import JWT extension String { var bytes: [UInt8] { .init(self.utf8) } } -extension JWKIdentifier { - static let `public` = JWKIdentifier(string: "public") - static let `private` = JWKIdentifier(string: "private") -} + // configures your application public func configure(_ app: Application) async throws { - - let privateKey = try String(contentsOfFile: app.directory.workingDirectory + "jwtRS256.key") - let privateSigner = try JWTSigner.rs256(key: .private(pem: privateKey.bytes)) - - let publicKey = try String(contentsOfFile: app.directory.workingDirectory + "jwtRS256.key.pub") - let publicSigner = try JWTSigner.rs256(key: .public(pem: publicKey.bytes)) - - app.jwt.signers.use(privateSigner, kid: .private) - app.jwt.signers.use(publicSigner, kid: .public, isDefault: true) +// let privateKey = try String(contentsOfFile: app.directory.workingDirectory + "jwtRS256.key") +// let privateSigner = try JWTSigner.rs256(key: .private(pem: privateKey.bytes)) +// +// let publicKey = try String(contentsOfFile: app.directory.workingDirectory + "jwtRS256.key.pub") +// let publicSigner = try JWTSigner.rs256(key: .public(pem: publicKey.bytes)) +// +// app.jwt.signers.use(privateSigner, kid: .private) +// app.jwt.signers.use(publicSigner, kid: .public, isDefault: true) app.middleware.use(CORSMiddleware()) let corsConfiguration = CORSMiddleware.Configuration( diff --git a/Sources/App/routes.swift b/Sources/App/routes.swift index a857f1c..6963994 100644 --- a/Sources/App/routes.swift +++ b/Sources/App/routes.swift @@ -13,4 +13,7 @@ func routes(_ app: Application) throws { } try baseApp.register(collection: cntrlAssociate()) try baseApp.register(collection: cntrlDepartment()) + try baseApp.register(collection: cntrlDocument()) + try baseApp.register(collection: cntrlDocType()) + }