Anonymous Authentication
Overview
The Anonymous authentication provider allows users to log in to your application without providing credentials. Anonymous user objects have a unique ID value but no other metadata fields or configuration options.
Warning
An Anonymous user object is not intended to persist data. Once a user logs out, the user cannot retrieve any previous user data.
Potential use cases for anonymous authentication include:
Authenticating the readers of a blog or news service.
Allowing end users to try the features of an application before registering for an account.
Simplifying the creation of users while developing and testing the client application.
Account Linking
When someone authenticates anonymously, the provider generates an anonymous user object. If the app does not explicitly log this anonymous user out, the same anonymous user is reused. The anonymous user persists until either of these things occur:
Explicit logout.
User deletion. Atlas App Services deletes anonymous user objects that have been inactive for 90 days.
To persist data associated with an Anonymous user, you can associate that existing Anonymous identity with a user account created by a different authentication provider.
Important
Anonymous user expiration
App Services may delete an Anonymous user object that is 90 days old (or older). When an account is deleted, it is not recoverable and any associated user data is lost. Documents created or modified by the user remain unaffected.
Configuration
You can enable the Anonymous authentication provider from the App Services UI in the Authentication options.
Select Authentication in the left sidebar.
Select the "Allow users to log in anonymously" entry of the Provider list.
Click the Provider Enabled toggle to move it into the "On" state.
Click the Save button in the lower right of the page to save your changes to the App configuration.
Click Review & Deploy Changes in the dropdown that appears at the top of the page.
Review the changes to your app's configuration and click Deploy in the lower right of the dialog to make your changes available to application users.
To enable and configure the Anonymous authentication provider with
the App Services CLI, define a configuration
object for it in /auth/providers.json
.
Anonymous provider configurations have the following form:
{ "anon-user": { "name": "anon-user", "type": "anon-user", "disabled": <boolean> } }
Tip
The name
of an authentication provider is always the same as its type
.
Note
The anonymous authentication provider does not have any provider-specific configuration options.
Examples
For code examples that demonstrate how to register and log in using anonymous authentication, see the documentation for the Realm SDKs:
Summary
Anonymous authentication allows users to interact with your application creating an identity.
To persist data from an anonymous session after a user creates an identity with a different authentication provider, you can link the two identities.