SignatureAuthenticationExtensions.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // 大名科技(天津)有限公司 版权所有
  2. //
  3. // 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
  4. //
  5. // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动
  6. //
  7. // 任何基于本项目二次开发而产生的一切法律纠纷和责任,均与作者无关
  8. using Microsoft.AspNetCore.Authentication;
  9. namespace Admin.NET.Core;
  10. /// <summary>
  11. /// Signature 身份验证扩展
  12. /// </summary>
  13. public static class SignatureAuthenticationExtensions
  14. {
  15. /// <summary>
  16. /// 注册 Signature 身份验证处理模块
  17. /// </summary>
  18. /// <param name="builder"></param>
  19. /// <returns></returns>
  20. public static AuthenticationBuilder AddSignatureAuthentication(this AuthenticationBuilder builder)
  21. {
  22. return builder.AddSignatureAuthentication(options => { });
  23. }
  24. /// <summary>
  25. /// 注册 Signature 身份验证处理模块
  26. /// </summary>
  27. /// <param name="builder"></param>
  28. /// <param name="options"></param>
  29. /// <returns></returns>
  30. public static AuthenticationBuilder AddSignatureAuthentication(this AuthenticationBuilder builder, Action<SignatureAuthenticationOptions> options)
  31. {
  32. return builder.AddScheme<SignatureAuthenticationOptions, SignatureAuthenticationHandler>(SignatureAuthenticationDefaults.AuthenticationScheme, options);
  33. }
  34. }