Clerk
Clerk is a complete suite of embeddable UIs, flexible APIs, and admin dashboards to authenticate and manage users.
The Clerk Wrapper is a WebAssembly(Wasm) foreign data wrapper which allows you to read data from Clerk for use within your Postgres database.
Available Versions
Version | Wasm Package URL | Checksum |
---|---|---|
0.1.0 | https://github.com/supabase/wrappers/releases/download/wasm_clerk_fdw_v0.1.0/clerk_fdw.wasm |
613be26b59fa4c074e0b93f0db617fcd7b468d4d02edece0b1f85fdb683ebdc4 |
Preparation
Before you can query Clerk, you need to enable the Wrappers extension and store your credentials in Postgres.
Enable Wrappers
Make sure the wrappers
extension is installed on your database:
1 |
|
Enable the Clerk Wrapper
Enable the Wasm foreign data wrapper:
1 2 3 |
|
Store your credentials (optional)
By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server
in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.
1 2 3 4 5 6 7 |
|
Connecting to Clerk
We need to provide Postgres with the credentials to access Clerk and any additional options. We can do this using the create server
command:
1 2 3 4 5 6 7 8 9 10 |
|
1 2 3 4 5 6 7 8 9 10 |
|
Note the fdw_package_*
options are required, which specify the Wasm package metadata. You can get the available package version list from above.
Create a schema
We recommend creating a schema to hold all the foreign tables:
1 |
|
Options
The full list of foreign table options are below:
object
- Object name in Clerk, required.
Supported objects are listed below:
Object name |
---|
allowlist_identifiers |
blocklist_identifiers |
domains |
invitations |
jwt_templates |
oauth_applications |
organizations |
organization_invitations |
organization_memberships |
redirect_urls |
saml_connections |
users |
Entities
Allow-list
This is a list of all identifiers allowed to sign up to an instance.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
allowlist_identifiers | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
Block-list
This is a list of all identifiers which are not allowed to access an instance.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
blocklist_identifiers | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
Domains
This is a list of all domains for an instance.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
domains | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
Invitations
This is a list of all non-revoked invitations for your application.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
invitations | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
JWT Templates
This is a list of all JWT templates.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
jwt_templates | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
OAuth Applications
This is a list of OAuth applications for an instance.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
oauth_applications | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
Organizations
This is a list of organizations for an instance.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
organizations | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
Organization Invitations
This is a list of organization invitations for an instance.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
organization_invitations | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
Organization Memberships
This is a list of organization user memberships for an instance.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
organization_memberships | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
Redirect URLs
This is a list of all whitelisted redirect urls for the instance.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
redirect_urls | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
SAML Connections
This is a list of SAML Connections for an instance.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
saml_connections | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
Users
This is a list of all users.
Ref: Clerk API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
users | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Notes
- The
attrs
column contains additional attributes in JSON format
Query Pushdown Support
This FDW doesn't support query pushdown.
Supported Data Types
Postgres Data Type | Clerk Data Type |
---|---|
boolean | Boolean |
bigint | Number |
double precision | Number |
text | String |
timestamp | Time |
jsonb | Json |
The Clerk API uses JSON formatted data, please refer to Clerk Backend API docs for more details.
Limitations
This section describes important limitations and considerations when using this FDW:
- Large result sets may experience slower performance due to full data transfer requirement
- Query pushdown is not supported
- Materialized views using these foreign tables may fail during logical backups
Examples
Below are some examples on how to use Clerk foreign tables.
Basic example
This example will create a "foreign table" inside your Postgres database and query its data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
attrs
is a special column which stores all the object attributes in JSON format, you can extract any attributes needed from it. See more examples below.
Query JSON attributes
1 2 3 4 5 6 |
|