Logto
repository·master·Indexed 12 days ago
https://github.com/logto-io/logtoAn open-source authentication infrastructure for SaaS and AI applications. It provides multi-tenancy, enterprise SSO, and RBAC, simplifying the implementation of OIDC, OAuth 2.1, and SAML. Includes a Management API SDK (@logto/api), an Account Center for user profile and security management, and native social connectors such as Alipay for iOS and Android.
What's inside Logto
- The SAML (Security Assertion Markup Language) connector allows Logto to act as a Service Provider (SP), enabling users to sign in to Logto using an external Identity Provider (IdP) such as Okta, OneLogin, or Salesforce. This facilitates federated authentication, allowing users to access Logto resources using their existing enterprise credentials.
Get started with the Vonage SMS connector
masterThe Vonage SMS connector is an official Logto plugin that enables users to register and sign in to their Logto accounts using SMS verification codes. It leverages Vonage's cloud-based communication services to deliver these messages.Use the OIDC standard connector
masterThe OIDC connector allows Logto to connect to any social identity provider (IdP) that supports the OpenID Connect protocol. This enables your application to:
- Add social sign-in buttons to your login page.
- Link existing user accounts to social identities.
- Sync user profile information (like names and avatars) from the provider.
- Access third-party APIs by securely storing tokens in Logto's Secret Vault for automation tasks (e.g., managing Google Calendar events).
Note: The OIDC connector is a special type of connector in Logto; you can add multiple connectors based on the OIDC protocol.
Use the Social mock connector for integration tests
masterTheSocial mock connectoris a specialized connector designed exclusively for integration testing purposes. It allows developers to simulate social login flows without requiring actual third-party social provider credentials or network connectivity to external services.Use the SMSBao SMS Connector
masterThe SMSBao SMS Connector is an official Logto connector that integrates with the SMSBao domestic SMS API. It enables end-users to complete verification processes such as login, registration, and password resets via SMS verification codes.
Prerequisites
- SMSBao Account: Register an account at SMSBao official website and complete the necessary account configurations.
- SMS Templates: Create and have your SMS templates approved in the SMSBao backend. The template content configured in Logto must match the approved content in SMSBao exactly, using Logto placeholders like
{{code}}.
Limitations
- Supports domestic SMS only.
- Does not support balance inquiries, uplink SMS push, international SMS, or voice verification code APIs.
- SMSBao returns
0for success; any other return code is treated as a sending error.
Use the Mock mail connector for integration tests
masterTheconnector-mock-emailis a specialized connector designed exclusively for integration testing environments. It simulates email delivery without sending actual emails, allowing you to verify email-related workflows (such as magic link generation or password resets) within your automated test suites.What is Machine-to-Machine (M2M) authentication in Logto?
masterMachine-to-machine (M2M) authentication is used when an application (rather than a user) needs to communicate directly with resources without UI or user interaction. Common examples include background services that update user data or statistics services that pull order data.
Logto uses Role-Based Access Control (RBAC). To allow an M2M app to access a resource, you must assign it specific M2M roles. There are two primary use cases:
- Accessing the Logto Management API: Requires assigning a role that includes the
allpermission from the built-in Logto Management API resource. - Accessing your own API resource: Requires assigning roles that include specific permissions defined within your own API resources.
- Accessing the Logto Management API: Requires assigning a role that includes the
Important requirements for Yunpian SMS templates
masterWhen using the Yunpian SMS connector, adhere to these rules to avoid delivery failures:
- Template Matching: The template content configured in Logto must be identical to the content approved in the Yunpian console.
- Variable Syntax:
- In the Yunpian console, use
#code#as the placeholder for the verification code. - In the Logto configuration, use
{{code}}as the placeholder for the verification code.
- In the Yunpian console, use
- Signatures: Yunpian automatically adds the default signature based on your API KEY. Do not include the signature manually in the template content you provide to Logto.
- Testing: Always perform a test before moving to production to ensure the configuration is correct.
Access Google APIs using stored tokens
masterIf you have configured the Google connector to store tokens, your application can retrieve these stored Google access tokens from the Secret Vault to perform backend tasks on behalf of the user, such as:
- Managing Google Drive files
- Creating Google Calendar events
- Sending emails through Gmail
Rotate private signing keys with a grace period
masterTo ensure a smooth transition when rotating private signing keys and prevent downtime or authentication failures for clients with cached JWKS, you can use a grace period.
During the grace period, the new signing key is marked as
Nextwhile the existing key remainsCurrent. Once the period ends, the new key becomesCurrentand the old one becomesPrevious.You can configure this via the
PRIVATE_KEY_ROTATION_GRACE_PERIODenvironment variable or the--gracePeriodCLI option.logto rotate-signing-keys --gracePeriod <duration>Convention for localized strings using msg()
masterTo maintain consistent translations, follow this convention when using the
msg()function:- Always provide a human-readable
id. - Always provide a
desc(description) to provide context for translators or LLMs.
Avoid using
msg()with only a string literal.// ✅ Good msg('Not set', { id: 'general.fallback-title', desc: 'A fallback title when the title or heading of a component is not provided.', }) // ❌ Bad msg('Not set')- Always provide a human-readable
Understand .NET Core authentication URI terminology
masterWhen integrating Logto with .NET Core authentication middleware, it is important to distinguish between the different URI terms used by .NET Core and Logto to avoid configuration errors:
Logto Concept .NET Core Term Description Logto redirect URI CallbackPathThe URI that Logto redirects the user back to after a successful sign-in. Logto post sign-out redirect URI SignedOutCallbackPathThe URI that Logto redirects the user to after they have signed out. Application redirect URI RedirectUriThe final URI the user is redirected to after the Logto middleware has completed its necessary actions. Sign-in Flow Sequence
- The user starts the Sign-in path in your application.
- The application redirects the user to Logto.
- Logto redirects the user back to your application's
CallbackPath. - The .NET Core middleware processes the callback and finally redirects the user to the
RedirectUri.