소스 검색

Committing changes

main
rpm-mcarman 2 년 전
부모
커밋
d2553dac16
5개의 변경된 파일25개의 추가작업 그리고 17개의 파일을 삭제
  1. +2
    -2
      Package.resolved
  2. +1
    -1
      Package.swift
  3. +10
    -0
      Sources/App/Models/mdlAssociate.swift
  4. +9
    -14
      Sources/App/configure.swift
  5. +3
    -0
      Sources/App/routes.swift

+ 2
- 2
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"
}
},
{


+ 1
- 1
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(


+ 10
- 0
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")


+ 9
- 14
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(


+ 3
- 0
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())
}

불러오는 중...
취소
저장