public static IServiceCollection AddBlazoradeMsal(this IServiceCollection services, Action <IServiceProvider, BlazoradeMsalOptions> config) { return(services .AddBlazoradeMsal() .AddSingleton((p) => { var options = new BlazoradeMsalOptions(); config?.Invoke(p, options); return options; })); }
private void AddMsal(IServiceProvider sp, BlazoradeMsalOptions config) { var options = sp.GetRequiredService <BlazoradeTeamsOptions>(); if (options.ClientId?.Length > 0) { config.ClientId = options.ClientId; config.TenantId = options.TenantId; config.RedirectUrl = options.LoginUrl; config.DefaultScopes = options.DefaultScopes ?? config.DefaultScopes; // We need to use the authentication dialog provided by Teams, in which we will perform a redirect authentication. config.InteractiveLoginMode = InteractiveLoginMode.Redirect; // Because we need to share the tokens from the authentication dialog with the main application. config.TokenCacheScope = TokenCacheScope.Persistent; } }
/// <summary> /// Creates an instance of the service class. /// </summary> public BlazoradeMsalService(BlazoradeMsalOptions options, IJSRuntime jsRuntime, NavigationManager navMan) { this.Options = options ?? throw new ArgumentNullException(nameof(options)); this.JSRuntime = jsRuntime ?? throw new ArgumentNullException(nameof(jsRuntime)); this.NavMan = navMan ?? throw new ArgumentNullException(nameof(navMan)); }