For AI agents: the complete documentation index is available at https://docs.halo.run/llms.txt, the full documentation bundle is available at https://docs.halo.run/llms-full.txt, and this page is available as Markdown at https://docs.halo.run/developer-guide/plugin/extension-points/server/username-password-authentication-manager.md.

用户名密码认证管理器

用户名密码认证管理器扩展点用于替换 Halo 默认的用户名密码认证管理器实现,例如:使用第三方的身份验证服务,一个例子是 LDAP。

public interface UsernamePasswordAuthenticationManager
    extends ReactiveAuthenticationManager, ExtensionPoint {}

实现类通过继承的 authenticate 方法完成认证:返回认证结果表示认证成功;返回 Mono.empty() 或抛出非 AuthenticationException 异常时,Halo 会回退到内置用户名密码认证;抛出 AuthenticationException 时则直接按认证失败处理。

UsernamePasswordAuthenticationManager 对应的 ExtensionPointDefinition 如下:

apiVersion: plugin.halo.run/v1alpha1
kind: ExtensionPointDefinition
metadata:
  name: username-password-authentication-manager
spec:
  className: run.halo.app.security.authentication.login.UsernamePasswordAuthenticationManager
  displayName: Username password authentication manager
  type: SINGLETON
  description: "Provides a way to extend the username password authentication."

即声明 ExtensionDefinition 自定义模型对象时对应的 extensionPointNameusername-password-authentication-manager

源码参考:扩展点接口认证管理器委托与回退逻辑