docs/versioned_docs/version-1.12.0/00200-core-concepts/00500-authentication.md
SpacetimeDB modules are exposed to the open internet and anyone can connect to them. Therefore, authentication is a critical part of using SpacetimeDB securely.
SpacetimeDB uses OpenID Connect (OIDC) identity tokens for authentication, making it compatible with most OIDC providers (e.g., Auth0, Firebase, Clerk, Google, GitHub, Facebook, and many more). You can choose any OIDC provider that fits your needs, or even implement your own.
If you're new to OIDC, check out our blog post about OIDC to learn more about how OIDC works and why it's a great choice for authentication.
To make it easier to get started with authentication, SpacetimeDB offers SpacetimeAuth, a fully managed OIDC provider built specifically for SpacetimeDB applications. SpacetimeAuth handles user management, authentication flows, and token issuance, so you don't have to worry about building and maintaining your own authentication service.
SpacetimeAuth is meant to be simple to use and easy to integrate with SpacetimeDB. While being production-ready and able to support most common use cases, it is not as feature-rich as some third-party OIDC providers. If you need advanced features or customization, you may want to consider using a third-party OIDC provider instead.
You can also use any third-party OIDC provider with SpacetimeDB. Most OIDC providers offer similar features, such as user management, authentication flows, and token issuance. When choosing a third-party OIDC provider, consider factors such as ease of integration, pricing, scalability, and security.
Sometimes, you may need to authenticate your servers, APIs or other services that interact with your SpacetimeDB database. OIDC tokens can also be used for this purpose, allowing secure communication between your services and SpacetimeDB.
To authenticate your services, you have e few options depending on your OIDC provider:
Obtaining an OIDC token is just the first step in securing your SpacetimeDB module, known as authentication. You also need to implement authorization to control what authenticated users can do within your module.
When a client connects to your SpacetimeDB module, the SpacetimeDB server validates the client's OIDC token and extracts the identity claims. These claims are then made available to your module's reducers, views and procedures via the context.
Check out the usage guide for more information on how to access and use authentication claims in your module: