AuthManager
Overview
AuthManager is the user authentication management module in NocoBase, used to register different user authentication types.
Basic Usage
Concepts
AuthType: Different user authentication methods, such as password, SMS, OIDC, SAML, etc.Authenticator: The entity for an authentication method, actually stored in a collection, corresponding to a configuration record of a certainAuthType. One authentication method can have multiple authenticators, corresponding to multiple configurations, providing different user authentication methods.Authenticator name: The unique identifier for an authenticator, used to determine the authentication method for the current request.
Class Methods
constructor()
Constructor, creates an AuthManager instance.
Signature
constructor(options: AuthManagerOptions)
Types
Details
AuthManagerOptions
JwtOptions
setStorer()
Sets the methods for storing and retrieving authenticator data.
Signature
setStorer(storer: Storer)
Types
Details
Authenticator
Storer
Storer is the interface for authenticator storage, containing one method.
get(name: string): Promise<Authenticator>- Gets an authenticator by its identifier. In NocoBase, the actual returned type is AuthModel.
registerTypes()
Registers an authentication type.
Signature
registerTypes(authType: string, authConfig: AuthConfig)
Types
Details
listTypes()
Gets the list of registered authentication types.
Signature
listTypes(): { name: string; title: string }[]
Details
get()
Gets an authenticator.
Signature
get(name: string, ctx: Context)
Details
middleware()
Authentication middleware. Gets the current authenticator and performs user authentication.

