A Vapor/Swift library that checks the https://haveibeenpwned.com/passwords API (all credit to Troy Hunt).
SwiftPwned is available through SPM. To install it, simply add the following to your Package.swift file:
.package(url: "https://github.com/gotranseo/swift-pwned.git", from: "1.0.0")
Don't forget to also add it to dependencies array.
In your configure.swift
add the following code:
import SwiftPwned
services.register { c -> SwiftPwned in
return try SwiftPwned(client: c.make())
}
let pwnedClient = try container.make(PwnedClient.self)
try pwnedClient.pwned(password: "password").wait() // true
Note: Don't actually use
wait()
, respond to the future appropriately.