有没有办法在不使用数据库的情况下在Blazor中进行外部身份验证?

问题描述

所以本质上我有Blazor服务器端应用程序。我正在尝试使用Azure AD SAML添加外部身份验证。我正在使用Sustainsys.Saml2.AspNetCore2软件包进行外部身份验证。我对ASP.NET或Blazor中的不同身份验证方法不熟悉。

我将Blazor服务器端模板用于对个人帐户进行身份验证设置的docker linux容器,并添加了Azure AD SAML作为外部帐户。

这是我的Configure ServicesStartup.cs内部的样子

public void ConfigureServices(IServiceCollection services)
        {
            this.LoadConfigurations();
            services.AddDataProtection();
            services.AddDbContext<ApplicationDbContext>(options =>
                options.UsesqlServer(
                    Configuration.GetConnectionString("DefaultConnection")));
            services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
                .AddEntityFrameworkStores<ApplicationDbContext>();

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddElasticsearch(this.Configuration);
            services.AddHttpContextAccessor();
            services.AddScoped<AuthenticationStateProvider,RevalidatingIdentityAuthenticationStateProvider<IdentityUser>>();
            services.AddAuthentication()
                .AddSaml2("AAD","Azure AD",options =>
                {
                    options.SPOptions.EntityId = new EntityId("spn:" + this.Configuration["AzureAD:EnterpriseAppId"]);
                    options.SPOptions.ReturnUrl = new Uri(this.Configuration["AzureAD:ReturnUrl"]);
                    options.IdentityProviders.Add(
                        new IdentityProvider(
                            new EntityId(this.Configuration["AzureAD:AzureADId"]),options.SPOptions)
                        {
                            LoadMetadata = true,MetadataLocation = this.Configuration["AzureAD:AppMetadataUrl"]
                        }
                        );
                });
        }

我们在这里使用sqlServer数据库并存储用户身份吗?该应用程序使用通用的登录页面

Login

在我的用例中,我想要的只是通过Azure AD对用户进行身份验证。我不希望他们创建和使用本地帐户,也不想拥有任何本地数据库。我到处看,却找不到不使用数据库解决方案。有人可以帮助我找到正确的方向吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)