Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Passkeys Guide #455

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Add Passkeys Guide #455

wants to merge 14 commits into from

Conversation

marius-se
Copy link

This PR adds a guide about integrating Passkeys into a server-side Swift application

Setting up Passkeys is not trivial, but very rewarding. An in-depth tutorial on how to integrate Passkeys could increase the number of projects using this "new" (/old) technology and spread the word.

I haven't written any type of blog post before, so please let it rain criticism! I want to get better at (technical) writing :)

cc @0xTim

Copy link
Collaborator

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments - will let others chime in as well

server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
dependencies: [
// ...
.product(name: "WebAuthn", package: "webauthn-swift")
// ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean the // ... or the entire Package.swift block?


extension Request {
var webAuthn: WebAuthnManager {
WebAuthnManager(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How expensive is this to create? i.e. should we do it on the Application and expose it via Request?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheap, it's just a simple stateless struct with 3 properties. I extended Request only to reduce the boilerplate

```

Here we configure 3 things:
1. The `relyingPartyID` identifies your app based solely on the domain (not the scheme, port, or path) it can be accessed on. All created Passkeys will be scoped to this identifier. That means a Passkey created at `example.org` can only be used on the same domain. This prevents other websites from talking to random Passkeys. However this also means if you want to change your domain at some point all users need to re-create their Passkeys!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably good to mention scoping to subdomains and how that affects things as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep


#### Setting up the Relying Party

If you haven't already downloaded the [demo project](https://github.com/brokenhandsio/swift-webauthn-guide), you should do so now. There's a `starter` and `final` project. Open the starter project and add the Swift WebAuthn library to your `Package.swift`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomerd any issues with this being linked here or would you prefer it to live in say the Swift Server Community org?

server/guides/webauthn.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@alexandersandberg alexandersandberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Left some smaller comments.

It would also be great to add a link to this new guide on /server/guides/, as it can be difficult to find otherwise. We're working on improving the documentation page to highlight this /server/guides/ index page as well.

server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
server/guides/webauthn.md Outdated Show resolved Hide resolved
@marius-se
Copy link
Author

@alexandersandberg sorry I think I messed up GitHub's diff visualisation by renaming the webauthn.md file to passkeys.md 😬

Also added an entry on the guides index page!

Copy link
Collaborator

@alexandersandberg alexandersandberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server/guides/passkeys.md Outdated Show resolved Hide resolved
server/guides/passkeys.md Outdated Show resolved Hide resolved
marius-se and others added 2 commits December 20, 2023 10:11
Co-authored-by: Alexander Sandberg <[email protected]>
Co-authored-by: Alexander Sandberg <[email protected]>
Copy link
Collaborator

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@0xTim
Copy link
Collaborator

0xTim commented Jan 26, 2024

@marius-se if you can fix the conflict we can get this merged

@0xTim 0xTim enabled auto-merge (squash) January 26, 2024 20:23
auto-merge was automatically disabled March 28, 2024 17:09

Head branch was pushed to by a user without write access

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants