AccessProvider.create()
Learn: Access providers |
---|
We recommend you use FSL to create and update access providers. See FSL access provider schema. |
Create an access provider.
Signature
AccessProvider.create(data: { name: String, issuer: String, jwks_uri: String, roles: String | { role: String, predicate: String } | Array<String | { role: String, predicate: String }> | Null, data: { *: Any } | Null }) => AccessProvider
Description
Creates an
AccessProvider
document with the provided document fields.
AccessProvider
documents are FQL versions of a database’s FSL
access provider schema.
AccessProvider
documents have the AccessProvider type. See
Access providers.
Staged schema
If a database has staged schema, this method adds an access provider to the staged schema, not the active schema.
If the database has no staged schema, using this method is equivalent to making an unstaged schema change. Changes are applied immediately to the database’s active schema.
Avoid concurrent schema changes
Concurrent unstaged schema changes can cause contended transactions, even if the changes affect different resources. This includes unstaged changes made using:
-
The Fauna CLI
-
The Fauna Dashboard
-
The Fauna Core HTTP API’s Schema endpoints
A schema change triggers a transaction that validates the entire database schema. To avoid errors, do one of the following instead:
-
Perform unstaged schema changes sequentially
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
data |
Document fields for the new
For supported document fields, see
|
Return value
Type | Description |
---|---|
The new |
Examples
AccessProvider.create({
name: "someIssuer",
issuer: "https://example.com/",
jwks_uri: "https://example.com/.well-known/jwks.json",
roles: [
"customer",
{
role: "manager",
predicate: "(jwt) => jwt!.scope.includes(\"manager\")"
}
],
data: {
desc: "Access provider for issuer"
}
})
{
name: "someIssuer",
coll: AccessProvider,
ts: Time("2099-06-25T13:08:04.020Z"),
issuer: "https://example.com/",
audience: "https://db.fauna.com/db/ysjons5xryyr4",
data: {
desc: "Access provider for issuer"
},
jwks_uri: "https://example.com/.well-known/jwks.json",
roles: [
"customer",
{
role: "manager",
predicate: "(jwt) => jwt!.scope.includes(\"manager\")"
}
]
}
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!