Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

Credential

Learn: Credentials

A credential associates a password with an identity document. You can use the credential and password to create an authentication token for an end user, system, or other identity.

Credential collection

Fauna stores credentials as documents in the Credential system collection. You can also access this collection using the Credentials alias.

Credential documents have the following FQL structure:

{
  id: "401328088768577609",
  coll: Credential,
  ts: Time("2099-06-21T18:39:00.735Z"),
  document: Customer("401328088729780297")
  password: "sekret"
  data: {
    desc: "Credential for VIP customer"
  }
}
Field name Type Read-only Required Description

id

ID

ID for the Credential document. The ID is a string-encoded, 64-bit unsigned integer in the 253-1 range. The ID is unique within the collection.

IDs are assigned at document creation. To create a credential with a user-provided id using Credential.create(), you must use a secret with the create_with_id privilege for the Credential collection. If not provided, Fauna generates the id.

coll

true

Collection name: Credential.

ts

true

Last time the document was created or updated.

document

Ref< { *: Any } >

true

Reference to the credential’s identity document. The identity document can be in any user-defined collection.

password

End-user password to associate with the credential’s identity document. Only provided when creating, replacing, or updating a credential.

You can use the password to generate a token for the credential using credential.login().

Passwords are not returned in Credential documents.

data

{ *: Any } | Null

Arbitrary user-defined metadata for the document.

Static methods

You can use the following static methods to manage the Credential collection in FQL.

Method Description

Get a Set of all credentials.

Get a credential by its document id.

Create a credential.

Get the first credential that matches a provided predicate.

Get "Credential" as a String.

Get a Set of credentials that match a provided predicate.

Instance methods

You can use the following instance methods to manage specific Credential documents in FQL.

Method Description

Delete a credential.

Test if a credential exists.

Create a token for a provided credential and its password.

Replace a credential.

Update a credential.

Test whether a provided password is valid for a credential.

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!