Skip to content

Commit 11f8dca

Browse files
feat: webauthn support (#251)
* feat: creating webauthn related tables * feat: webauthn support * fix: fixing table locked issue with in-memory db * fix: additional indexes, updateEmail_Transactional * chore: changelog, version number * fix: review fixes * fix: handling potential error while saving options * fix: fix test --------- Co-authored-by: Sattvik Chakravarthy <sattvik@supertokens.com>
1 parent 3eab6c7 commit 11f8dca

File tree

7 files changed

+1332
-3
lines changed

7 files changed

+1332
-3
lines changed

CHANGELOG.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,92 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
## [8.1.0]
11+
12+
- Adds support for webauthn (passkeys)
13+
- Adds additional indexing for `emailverification_verified_emails`
14+
15+
### Migration
16+
17+
```sql
18+
CREATE INDEX IF NOT EXISTS emailverification_verified_emails_app_id_email_index ON emailverification_verified_emails
19+
(app_id, email);
20+
21+
CREATE TABLE IF NOT EXISTS webauthn_account_recovery_tokens (
22+
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
23+
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
24+
user_id CHAR(36) NOT NULL,
25+
email VARCHAR(256) NOT NULL,
26+
token VARCHAR(256) NOT NULL,
27+
expires_at BIGINT NOT NULL,
28+
CONSTRAINT webauthn_account_recovery_token_pkey PRIMARY KEY (app_id, tenant_id, user_id, token),
29+
CONSTRAINT webauthn_account_recovery_token_user_id_fkey FOREIGN KEY (app_id, tenant_id, user_id) REFERENCES
30+
all_auth_recipe_users(app_id, tenant_id, user_id) ON DELETE CASCADE
31+
);
32+
33+
CREATE TABLE IF NOT EXISTS webauthn_credentials (
34+
id VARCHAR(256) NOT NULL,
35+
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
36+
rp_id VARCHAR(256) NOT NULL,
37+
user_id CHAR(36),
38+
counter BIGINT NOT NULL,
39+
public_key BYTEA NOT NULL,
40+
transports TEXT NOT NULL,
41+
created_at BIGINT NOT NULL,
42+
updated_at BIGINT NOT NULL,
43+
CONSTRAINT webauthn_credentials_pkey PRIMARY KEY (app_id, rp_id, id),
44+
CONSTRAINT webauthn_credentials_user_id_fkey FOREIGN KEY (app_id, user_id) REFERENCES webauthn_users
45+
(app_id, user_id) ON DELETE CASCADE
46+
);
47+
48+
CREATE TABLE IF NOT EXISTS webauthn_generated_options (
49+
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
50+
tenant_id VARCHAR(64) DEFAULT 'public'NOT NULL,
51+
id CHAR(36) NOT NULL,
52+
challenge VARCHAR(256) NOT NULL,
53+
email VARCHAR(256),
54+
rp_id VARCHAR(256) NOT NULL,
55+
rp_name VARCHAR(256) NOT NULL,
56+
origin VARCHAR(256) NOT NULL,
57+
expires_at BIGINT NOT NULL,
58+
created_at BIGINT NOT NULL,
59+
user_presence_required BOOLEAN DEFAULT false NOT NULL,
60+
user_verification VARCHAR(12) DEFAULT 'preferred' NOT NULL,
61+
CONSTRAINT webauthn_generated_options_pkey PRIMARY KEY (app_id, tenant_id, id),
62+
CONSTRAINT webauthn_generated_options_tenant_id_fkey FOREIGN KEY (app_id, tenant_id) REFERENCES tenants
63+
(app_id, tenant_id) ON DELETE CASCADE
64+
);
65+
66+
CREATE TABLE IF NOT EXISTS webauthn_user_to_tenant (
67+
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
68+
tenant_id VARCHAR(64) DEFAULT 'public' NOT NULL,
69+
user_id CHAR(36) NOT NULL,
70+
email VARCHAR(256) NOT NULL,
71+
CONSTRAINT webauthn_user_to_tenant_email_key UNIQUE (app_id, tenant_id, email),
72+
CONSTRAINT webauthn_user_to_tenant_pkey PRIMARY KEY (app_id, tenant_id, user_id),
73+
CONSTRAINT webauthn_user_to_tenant_user_id_fkey FOREIGN KEY (app_id, tenant_id, user_id) REFERENCES
74+
all_auth_recipe_users(app_id, tenant_id, user_id) ON DELETE CASCADE
75+
);
76+
77+
CREATE TABLE IF NOT EXISTS webauthn_users (
78+
app_id VARCHAR(64) DEFAULT 'public' NOT NULL,
79+
user_id CHAR(36) NOT NULL,
80+
email VARCHAR(256) NOT NULL,
81+
rp_id VARCHAR(256) NOT NULL,
82+
time_joined BIGINT NOT NULL,
83+
CONSTRAINT webauthn_users_pkey PRIMARY KEY (app_id, user_id),
84+
CONSTRAINT webauthn_users_user_id_fkey FOREIGN KEY (app_id, user_id) REFERENCES app_id_to_user_id(app_id,
85+
user_id) ON DELETE CASCADE
86+
);
87+
88+
CREATE INDEX IF NOT EXISTS webauthn_user_to_tenant_email_index ON webauthn_user_to_tenant (app_id, email);
89+
CREATE INDEX IF NOT EXISTS webauthn_user_challenges_expires_at_index ON webauthn_generated_options (app_id, tenant_id, expires_at);
90+
CREATE INDEX IF NOT EXISTS webauthn_credentials_user_id_index ON webauthn_credentials (user_id);
91+
CREATE INDEX IF NOT EXISTS webauthn_account_recovery_token_token_index ON webauthn_account_recovery_tokens (app_id, tenant_id, token);
92+
CREATE INDEX IF NOT EXISTS webauthn_account_recovery_token_expires_at_index ON webauthn_account_recovery_tokens (expires_at DESC);
93+
CREATE INDEX IF NOT EXISTS webauthn_account_recovery_token_email_index ON webauthn_account_recovery_tokens (app_id, tenant_id, email);
94+
```
95+
1096
## [8.0.3]
1197

1298
- Fixes `StorageTransactionLogicException` in bulk import when not using userRoles and totpDevices in import json.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'java-library'
33
}
44

5-
version = "8.0.3"
5+
version = "8.1.0"
66

77
repositories {
88
mavenCentral()

0 commit comments

Comments
 (0)