Use header instead of url parameter

This commit is contained in:
Christoph Hagen 2022-06-11 00:20:43 +02:00
parent 7f31536315
commit 23692377e8

View File

@ -4,7 +4,9 @@ import Vapor
private let decoder = JSONDecoder()
private func authorize(_ request: Request) throws {
let key = try request.query.get(String.self, at: "key")
guard let key = request.headers.first(name: "key") else {
throw Abort(.badRequest)
}
guard server.hasAuthorization(for: key) else {
throw Abort(.forbidden)
}