Skip to main content
Authentication is a critical part of any application. FrogBot provides a secure, portable way to manage user accounts out of the box. FrogBot Authentication is designed for both the Admin Panel and your own external applications, eliminating the need for paid third-party platforms and services. FrogBot does not require you to define a users collection. If no auth collection exists, FrogBot supplies its default users collection. If exactly one auth collection exists, FrogBot uses it as the owner relationship for chat chats regardless of its slug. With multiple auth collections, set admin.user to choose one. Here are some common use cases of Authentication in your own applications:
  • Customer accounts for an e-commerce app
  • User accounts for a SaaS product
  • P2P apps or social sites where users need to log in and manage their profiles
  • Online games where players need to track their progress over time
When Authentication is enabled on a Collection, FrogBot injects all necessary functionality to support the entire user flow. This includes all auth-related operations like account creation, logging in and out, and resetting passwords, all auth-related emails like email verification and password reset, as well as any necessary UI to manage users from the Admin Panel. To enable Authentication on a Collection, use the auth property in the Collection Config. Add auth.signIn for OAuth sign-in.
Authentication Admin Panel functionality Admin Panel screenshot depicting an Admins Collection with Auth enabled

Config Options

Any Collection can opt-in to supporting Authentication. Once enabled, each Document that is created within the Collection can be thought of as a “user”. This enables a complete authentication workflow on your Collection, such as logging in and out, resetting their password, and more.
Note: By default, FrogBot provides an auth-enabled User Collection which is used to access the Admin Panel.
To enable Authentication on a Collection, use the auth property in the Collection Config:
Tip: For default auth behavior, set auth: true. This is a good starting point for most applications.
Note: Auth-enabled Collections will be automatically injected with the hash, salt, and email fields. See field names for reserved-name guidance.
The following options are available: AuthEmailTemplate is ({ token, user }) => string | Promise<string>.

Disable local strategy

Set disableLocalStrategy: true to remove the email, password, and lockout fields, and to make the login, forgot password, reset password, unlock, and email verification operations fail. Pass an object to change what is kept.

Login With Username

You can allow users to login with their username instead of their email address by setting the loginWithUsername property to true. Example:
Or, you can pass an object with additional options:

Auto-Login

For testing and demo purposes you may want to skip forcing the user to login in order to access your application. Typically, all users should be required to login, however, you can speed up local development time by enabling auto-login. To enable auto-login, set the autoLogin property in the FrogBot Config:
Warning: The recommended way to use this feature is behind an Environment Variable. This will ensure it is disabled in production.
autoLogin defaults to false. To turn it on, pass an object: Without prefillOnly, every request that has no valid login token is authenticated as this user: the admin panel, REST and GraphQL requests, and frogbot.auth().

Auto-Refresh

Turning this property on will allow users to stay logged in indefinitely while their browser is open and on the admin panel, by automatically refreshing their authentication token before it expires. To enable auto-refresh for user tokens, set autoRefresh: true in the FrogBot Config. It defaults to false, which shows a prompt to stay logged in before the token expires:

Operations

All auth-related operations are available via FrogBot’s REST, Local, and GraphQL APIs. These operations are automatically added to your Collection when you enable Authentication. More details.

Strategies

Out of the box FrogBot ships with three powerful Authentication strategies: Each of these strategies can work together or independently. You can also create your own custom strategies to fit your specific needs. More details.

HTTP-Only Cookies

HTTP-only cookies are a highly secure method of storing identifiable data on a user’s device so that FrogBot can automatically recognize a returning user until their cookie expires. They are totally protected from common XSS attacks and cannot be read by JavaScript in the browser, unlike JWT’s. More details.

JSON Web Tokens

JWT (JSON Web Tokens) can also be utilized to perform authentication. Tokens are generated on login, refresh and me operations and can be attached to future requests to authenticate users. More details.

API Keys

API keys come from the API keys plugin. They’re particularly useful when you want to authenticate against FrogBot from a third-party service. More details.

Custom Strategies

There are cases where these may not be enough for your application. FrogBot is extendable by design so you can wire up your own strategy when you need to. More details.

Access Control

Default auth fields including email, username, and password can be overridden by defining a custom field with the same name in your collection config. This allows you to customize the field — including access control — while preserving the underlying auth functionality. For example, you might want to restrict the email field from being updated once it is created, or only allow it to be read by certain user roles. You can achieve this by redefining the field and setting access rules accordingly. Here’s an example of how to restrict access to default auth fields:
Note:
  • Access functions will apply across the application — I.e. if read access is disabled on email, it will not appear in the Admin panel UI or API.
  • Restricting read on the email or username disables the Unlock action in the Admin panel as this function requires access to a user-identifying field.
  • When overriding the password field, you may need to include hidden: true to prevent duplicate fields being displayed in the Admin panel.