Skip to content

Commit

Permalink
update to latest webauthn changes (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
marius-se authored Jul 6, 2023
1 parent 167ed36 commit 596436b
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 86 deletions.
96 changes: 48 additions & 48 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "864c8d9e0ead5de7ba70b61c8982f89126710863",
"version" : "1.15.0"
"revision" : "78db67e5bf4a8543075787f228e8920097319281",
"version" : "1.18.0"
}
},
{
"identity" : "async-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/async-kit.git",
"state" : {
"revision" : "9acea4c92f51a5885c149904f0d11db4712dda80",
"version" : "1.16.0"
"revision" : "a61da00d404ec91d12766f1b9aac7d90777b484d",
"version" : "1.17.0"
}
},
{
Expand All @@ -32,26 +32,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/fluent.git",
"state" : {
"revision" : "4db22cc7797b3a687de65e32e11108cf92fb32da",
"version" : "4.7.0"
"revision" : "4b4d8bf15a06fd60137e9c543e5503c4b842654e",
"version" : "4.8.0"
}
},
{
"identity" : "fluent-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/fluent-kit.git",
"state" : {
"revision" : "dd6b7f8fb71b83d832ab88270704a29c63d8bd91",
"version" : "1.40.0"
"revision" : "2d7dce5cb04156eecdb17e7349f4eac4206e8a17",
"version" : "1.42.4"
}
},
{
"identity" : "fluent-sqlite-driver",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/fluent-sqlite-driver.git",
"state" : {
"revision" : "60d01964a8768bde8116a2c66110da080b51e9f6",
"version" : "4.3.1"
"revision" : "33e920bd53c9a3a77f82733aaf26a82495afddd4",
"version" : "4.4.0"
}
},
{
Expand All @@ -68,17 +68,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/leaf-kit.git",
"state" : {
"revision" : "62169b44cc79734e11bf44b8d7154865dee5936b",
"version" : "1.10.1"
"revision" : "13f2fc4c8479113cd23876d9a434ef4573e368bb",
"version" : "1.10.2"
}
},
{
"identity" : "multipart-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/multipart-kit.git",
"state" : {
"revision" : "0d55c35e788451ee27222783c7d363cb88092fab",
"version" : "4.5.2"
"revision" : "1adfd69df2da08f7931d4281b257475e32c96734",
"version" : "4.5.4"
}
},
{
Expand All @@ -95,35 +95,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/routing-kit.git",
"state" : {
"revision" : "ffac7b3a127ce1e85fb232f1a6271164628809ad",
"version" : "4.6.0"
"revision" : "611bc45c5dfb1f54b84d99b89d1f72191fb6b71b",
"version" : "4.7.2"
}
},
{
"identity" : "sql-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/sql-kit.git",
"state" : {
"revision" : "fcc29f543b3de7b661cbe7540805974234cb9740",
"version" : "3.24.0"
"revision" : "5026e7c0f2e464ea1af9f5948701aa8922ab14eb",
"version" : "3.27.0"
}
},
{
"identity" : "sqlite-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/sqlite-kit.git",
"state" : {
"revision" : "76da703f89f1dc92f05da79782ebc44c52f17453",
"version" : "4.2.1"
"revision" : "f66ddded9a330454856f5ba272cccc9e0c995b17",
"version" : "4.3.0"
}
},
{
"identity" : "sqlite-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/sqlite-nio.git",
"state" : {
"revision" : "596b680292adf5597741ab3ce92b3a1946fd4216",
"version" : "1.4.0"
"revision" : "2b7bcf3d2e4d2f68d52a66d12d2057867cee383a",
"version" : "1.5.2"
}
},
{
Expand All @@ -140,17 +140,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-asn1.git",
"state" : {
"revision" : "805deae27a7506dcad043604c00a9dc52d465dcb",
"version" : "0.7.0"
"revision" : "a53d9f676cbc84ccc1643cf559a470ee5732ebb6",
"version" : "0.8.0"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "ff3d2212b6b093db7f177d0855adbc4ef9c5f036",
"version" : "1.0.3"
"revision" : "6c89474e62719ddcc1e9614989fff2f68208fe10",
"version" : "1.1.0"
}
},
{
Expand All @@ -167,8 +167,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-certificates.git",
"state" : {
"revision" : "678756a6590c8fc30ab85a01442152bab9b83928",
"version" : "0.3.0"
"revision" : "9099e78aad1693ce5a2e5b108d8e1337fbff433b",
"version" : "0.6.0"
}
},
{
Expand All @@ -185,8 +185,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "da0fe44138ab86e380f40a2acbd8a611b07d3f64",
"version" : "2.4.0"
"revision" : "33a20e650c33f6d72d822d558333f2085effa3dc",
"version" : "2.5.0"
}
},
{
Expand All @@ -203,53 +203,53 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "e8bced74bc6d747745935e469f45d03f048d6cbd",
"version" : "2.3.4"
"revision" : "34025104068262db0cc998ace178975c5ff4f36b",
"version" : "2.4.0"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "45167b8006448c79dda4b7bd604e07a034c15c49",
"version" : "2.48.0"
"revision" : "6213ba7a06febe8fef60563a4a7d26a4085783cf",
"version" : "2.54.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "d75ed708d00353acf173ca23018b6bd46f949464",
"version" : "1.17.0"
"revision" : "0e0d0aab665ff1a0659ce75ac003081f2b1c8997",
"version" : "1.19.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "38feec96bcd929028939107684073554bf01abeb",
"version" : "1.25.2"
"revision" : "a8ccf13fa62775277a5d56844878c828bbb3be1a",
"version" : "1.27.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "4fb7ead803e38949eb1d6fabb849206a72c580f3",
"version" : "2.23.0"
"revision" : "e866a626e105042a6a72a870c88b4c531ba05f83",
"version" : "2.24.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "c0d9a144cfaec8d3d596aadde3039286a266c15c",
"version" : "1.15.0"
"revision" : "41f4098903878418537020075a4d8a6e20a0b182",
"version" : "1.17.0"
}
},
{
Expand All @@ -275,8 +275,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/vapor.git",
"state" : {
"revision" : "d1a89f8f54c409751a5891a3dd22f78171be5741",
"version" : "4.74.1"
"revision" : "9a340de4995e5a9dade4ff4c51cd2e6ae30c12d6",
"version" : "4.77.0"
}
},
{
Expand All @@ -293,17 +293,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/webauthn-swift.git",
"state" : {
"revision" : "07f9c205a7f1cb55ed7d90c5a9a2e716943c98e8",
"version" : "0.0.1"
"revision" : "a823806af73eeea9542e0f223bae8270b4f4e95e",
"version" : "0.0.2"
}
},
{
"identity" : "websocket-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/websocket-kit.git",
"state" : {
"revision" : "2b8885974e8d9f522e787805000553f4f7cce8a0",
"version" : "2.7.0"
"revision" : "53fe0639a98903858d0196b699720decb42aee7b",
"version" : "2.14.0"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
.package(url: "https://github.com/vapor/fluent-sqlite-driver.git", from: "4.0.0"),
.package(url: "https://github.com/m-barthelemy/vapor-queues-fluent-driver.git", from: "3.0.0-beta1"),
.package(url: "https://github.com/vapor/leaf.git", from: "4.0.0"),
.package(url: "https://github.com/swift-server/webauthn-swift.git", from: "0.0.1")
.package(url: "https://github.com/swift-server/webauthn-swift.git", from: "0.0.2")
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion Public/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ function bufferEncode(value) {
}

function bufferDecode(value) {
return Uint8Array.from(atob(value), c => c.charCodeAt(0));
return Uint8Array.from(atob(value.replace(/_/g, '/').replace(/-/g, '+')), c => c.charCodeAt(0));
}
8 changes: 4 additions & 4 deletions Sources/App/Models/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ final class User: Model, Content {
}
}

extension User: WebAuthnUser {
var userID: String { id!.uuidString }
var name: String { username }
var displayName: String { username }
extension User {
var webAuthnUser: PublicKeyCredentialUserEntity {
PublicKeyCredentialUserEntity(id: [UInt8](id!.uuidString.utf8), name: username, displayName: username)
}
}

extension User: ModelSessionAuthenticatable {}
6 changes: 4 additions & 2 deletions Sources/App/configure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import QueuesFluentDriver
public func configure(_ app: Application) throws {
// uncomment to serve files from /Public folder
app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))

app.middleware.use(app.sessions.middleware)
app.sessions.use(.memory)

if app.environment == .testing {
app.databases.use(.sqlite(.file(Environment.get("SQLITE_DATABASE_PATH") ?? "db.sqlite")), as: .sqlite)
Expand All @@ -29,9 +31,9 @@ public func configure(_ app: Application) throws {

app.views.use(.leaf)
app.webAuthn = WebAuthnManager(
config: WebAuthnConfig(
relyingPartyDisplayName: Environment.get("RP_DISPLAY_NAME") ?? "Vapor Passkey Demo",
config: WebAuthnManager.Config(
relyingPartyID: Environment.get("RP_ID") ?? "localhost",
relyingPartyName: Environment.get("RP_DISPLAY_NAME") ?? "Vapor Passkey Demo",
relyingPartyOrigin: Environment.get("RP_ORIGIN") ?? "http://localhost:8080"
)
)
Expand Down
Loading

0 comments on commit 596436b

Please sign in to comment.