@@ -16,32 +16,37 @@ public static class ServerSideAddBlazorAuthExtensions
1616 /// using default implementations of <see cref="IAuthenticationService"/> and <see cref="IIdentityClaimsService"/>.
1717 /// </summary>
1818 /// <param name="builder">The <see cref="IHostApplicationBuilder"/> to add services to.</param>
19+ /// <param name="configure">An <see cref="Action"/> to configure <see cref="BlazorAuthServerOptions"/>.</param>
1920 /// <returns><see cref="IHostApplicationBuilder"/> to allow chaining.</returns>
20- public static IHostApplicationBuilder AddBlazorAuth ( this IHostApplicationBuilder builder )
21+ public static IHostApplicationBuilder AddBlazorAuth ( this IHostApplicationBuilder builder , Action < BlazorAuthServerOptions > ? configure = null )
2122 {
22- return builder . AddBlazorAuth < DefaultAuthenticationService , IdentityClaimsService > ( ) ;
23+ return builder . AddBlazorAuth < DefaultAuthenticationService , IdentityClaimsService > ( configure ) ;
2324 }
2425
2526 /// <summary>
2627 /// Adds server-side Blazor.Auth services to the specified <see cref="IHostApplicationBuilder"/>, <br />
2728 /// using the default implementation of <see cref="IIdentityClaimsService"/>.
2829 /// </summary>
2930 /// <typeparam name="TAuthenticationService">The type of the server-side authentication service.</typeparam>
30- public static IHostApplicationBuilder AddBlazorAuth < TAuthenticationService > ( this IHostApplicationBuilder builder )
31+ public static IHostApplicationBuilder AddBlazorAuth < TAuthenticationService > ( this IHostApplicationBuilder builder , Action < BlazorAuthServerOptions > ? configure = null )
3132 where TAuthenticationService : class , IAuthenticationService
3233 {
33- return builder . AddBlazorAuth < TAuthenticationService , IdentityClaimsService > ( ) ;
34+ return builder . AddBlazorAuth < TAuthenticationService , IdentityClaimsService > ( configure ) ;
3435 }
3536
3637 /// <summary>
3738 /// Adds server-side Blazor.Auth services to the specified <see cref="IHostApplicationBuilder"/>.
3839 /// </summary>
3940 /// <typeparam name="TAuthenticationService">The type of the server-side authentication service.</typeparam>
4041 /// <typeparam name="TIdentityClaimsService">The type of the identity claims service.</typeparam>
41- public static IHostApplicationBuilder AddBlazorAuth < TAuthenticationService , TIdentityClaimsService > ( this IHostApplicationBuilder builder )
42+ public static IHostApplicationBuilder AddBlazorAuth < TAuthenticationService , TIdentityClaimsService > ( this IHostApplicationBuilder builder , Action < BlazorAuthServerOptions > ? configure = null )
4243 where TAuthenticationService : class , IAuthenticationService
4344 where TIdentityClaimsService : class , IIdentityClaimsService
4445 {
46+ var options = new BlazorAuthServerOptions ( ) ;
47+ configure ? . Invoke ( options ) ;
48+ builder . Services . AddSingleton ( options ) ;
49+
4550 builder . AddBlazorCookies ( ) ;
4651 builder . Services . AddScoped < IBlazorAuthLogger , BlazorAuthLogger > ( ) ;
4752
0 commit comments