-
Notifications
You must be signed in to change notification settings - Fork 338
feat(templates): add passkeys-backend template #531
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ae9bdd3
add passkeys backend functions and some test
nicolas-camacho d178bb5
update test with response on unsuccessfull
nicolas-camacho 3757470
passkey web demo view with functionality
nicolas-camacho eafbe8c
remove unnecesary console logs
nicolas-camacho e03aa33
fix user id creation
nicolas-camacho 01479d2
variables, names and type parameter modified
nicolas-camacho a1d80b4
replaced passkey to passkeys
nicolas-camacho fd8b846
removed unused relation
nicolas-camacho d93cbe5
add usage and deploy section and fix typos
nicolas-camacho 6a6cfb5
last functional sample backend
nicolas-camacho 61d974f
migrate passkeys backend to comms
nicolas-camacho 0de51a4
Setup ready for PR
nicolas-camacho 845f2c2
unused variabe removed
nicolas-camacho e6bdde4
Merge branch 'main' into add-passkey-demo
nicolas-camacho fc93745
using webauthn-json packacge
nicolas-camacho 32881f6
simplifiead object structuring and use of twilio client function
nicolas-camacho 0498d8e
reciving complete authn object
nicolas-camacho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,7 @@ | |
"verify-sna", | ||
"flex-dialpad", | ||
"verify-prefill", | ||
"reminder-message" | ||
"reminder-message", | ||
"passkeys-backend" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
API_URL= | ||
RELYING_PARTY= | ||
ACCOUNT_SID= | ||
AUTH_TOKEN= | ||
robinske marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dkundel | ||
alisontanu | ||
pthirumurthi | ||
nicolas-camacho |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changelog | ||
|
||
## [Unreleased] | ||
|
||
## [1.0.0] | ||
### Added | ||
- Initial release. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# passkeys-backend | ||
|
||
Verify enables developers to easily add Passkeys into their existing authentication flows, similar to Verify TOTP and Push. The Verify API supports passkey registration, public key storage, and auth flows. On the client-side, developers can optionally embed an open-source library (SDK) that handles interactions with operating systems and customizable UI widgets that maximize conversion. | ||
|
||
## How to use the template | ||
|
||
The best way to use the Function templates is through the Twilio CLI as described below. If you'd like to use the template without the Twilio CLI, [check out our usage docs](../docs/USING_FUNCTIONS.md). | ||
|
||
Make sure befores you use the template you have to set up your enviroment variables and | ||
customize the associated files with your client applications origins you can find this | ||
customization [here](#service-customization). | ||
|
||
## Pre-requisites | ||
|
||
### Environment variables | ||
|
||
This project requires some environment variables to be set. A file named `.env` is used to store the values for those environment variables. To keep your tokens and secrets secure, make sure to not commit the `.env` file in git. When setting up the project with `twilio serverless:init ...` the Twilio CLI will create a `.gitignore` file that excludes `.env` from the version history. | ||
|
||
You can find a `.env.example` file to copy for creating your own `.env` file | ||
|
||
In your `.env` file, set the following values: | ||
|
||
| Variable | Description | Required | | ||
| :------- | :---------- | :------- | | ||
| API_URL | Passkeys API to point at | yes | | ||
| RELYING_PARTY | Customer app or client | yes | ||
| ACCOUNT_SID | Twilio account where the service belong | yes | | ||
| AUTH_TOKEN | Authentication token for twilio account | yes | | ||
|
||
### Service customization | ||
|
||
Besides the enviroment variables files, the project also contain two files called `assetlink.json` and `apple-app-site-association` inside `./assets/.well-know/`, that is a public file that contains the identificators for the apps that will be connecting the service. | ||
|
||
`apple-app-site-association` contains identificator hash for the origin app in iOS: | ||
|
||
| Variable | Description | Required | | ||
| :------- | :---------- | :------- | | ||
| ORIGIN_IOS_APP_HASH | Replace it with the identificator of the iOS app | yes | | ||
|
||
`assetlink.json` contains identificator hash for the origin apps in android and web: | ||
|
||
| Variable | Description | Required | | ||
| :------- | :---------- | :------- | | ||
| RELYING_PARTY | Replace it with the value of the relaying party | yes | | ||
| FINGERPRINT_CERTIFICATION_HASH | Replace it with the hash fingerprint given by android app in format SHA256 | yes | | ||
|
||
|
||
### Function Parameters | ||
|
||
`/registration/start` expects the following parameters: | ||
|
||
| Parameter | Description | Required | | ||
| :-------- | :---------- | :------- | | ||
| username | user identification name | yes | ||
|
||
|
||
`/registration/verification` expects the following parameters: | ||
|
||
| Parameter | Description | Required | | ||
| :-------- | :---------- | :------- | | ||
| id | A base64url encoded representation of `rawId`. | yes | | ||
| rawId | The globally unique identifier for this `PublicKeyCredential`. | yes | | ||
| attestationObject | A base64url encoded object given by the `AuthenticatorAttestationResponse` | yes | | ||
| clientDataJson | A base64url encoded object given by the `AuthenticatorAttestationResponse` | yes | | ||
| transports | An Array with the transport methods given by the `AuthenticatorAttestationResponse` | yes | | ||
|
||
|
||
`/authentication/start` a GET request, does not expect parameters | ||
|
||
`/authentication/verification` expects the following parameters: | ||
|
||
| Parameter | Description | Required | | ||
| :-------- | :---------- | :------- | | ||
| id | A base64url encoded representation of `rawId`. | yes | | ||
| rawId | The globally unique identifier for this `PublicKeyCredential`. | yes | | ||
| authenticatorData | A base64url encoded object given by the `AuthenticatorAttestationResponse` | yes | | ||
| clientDataJson | A base64url encoded object given by the `AuthenticatorAttestationResponse` | yes | | ||
| signature | A base64url encoded object given by the `AuthenticatorAttestationResponse` | yes | | ||
| userHandle | A base64url encoded object given by the `AuthenticatorAttestationResponse` | yes | | ||
|
||
## Deploying | ||
|
||
Deploy your functions and assets with either of the following commands. Note: you must run these commands from inside your project folder. [More details in the docs.](https://www.twilio.com/docs/labs/serverless-toolkit) | ||
|
||
With the [Twilio CLI](https://www.twilio.com/docs/twilio-cli/quickstart): | ||
|
||
``` | ||
twilio serverless:deploy | ||
``` |
7 changes: 7 additions & 0 deletions
7
passkeys-backend/assets/.well-know/apple-app-site-association
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"webcredentials": { | ||
"apps": [ | ||
"{ORIGIN_IOS_APP_HASH}" | ||
] | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[ | ||
{ | ||
"relation": [ | ||
"delegate_permission/common.handle_all_urls", | ||
"delegate_permission/common.get_login_creds" | ||
], | ||
"target": { | ||
"namespace": "web", | ||
"site": "{RELYING_PARTY}" | ||
} | ||
}, | ||
{ | ||
"relation": [ | ||
"delegate_permission/common.handle_all_urls", | ||
"delegate_permission/common.get_login_creds" | ||
], | ||
"target": { | ||
"namespace": "android_app", | ||
"package_name": "com.twilio.passkeys.android", | ||
"sha256_cert_fingerprints": ["{FINGERPRINT_CERTIFICATION_HASH}"] | ||
} | ||
} | ||
] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.