Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Authentication 使用firebase的asp.net核心身份验证_Authentication_Asp.net Core_.net Core_Firebase Authentication_Bearer Token - Fatal编程技术网

Authentication 使用firebase的asp.net核心身份验证

Authentication 使用firebase的asp.net核心身份验证,authentication,asp.net-core,.net-core,firebase-authentication,bearer-token,Authentication,Asp.net Core,.net Core,Firebase Authentication,Bearer Token,我正在尝试创建一个asp.net核心api,该api使用firebase身份验证验证用户身份,并将其所有数据存储在内部postgreSQL数据库中,包括授权规则(如管理和其他自定义规则) 我设法使用firebase nuget包验证令牌: public void ConfigureServices(IServiceCollection services) { services.AddDbContext<ApplicationDBContext>(option

我正在尝试创建一个asp.net核心api,该api使用firebase身份验证验证用户身份,并将其所有数据存储在内部postgreSQL数据库中,包括授权规则(如管理和其他自定义规则)

我设法使用firebase nuget包验证令牌:

 public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<ApplicationDBContext>(options => options.UseNpgsql(
           Configuration.GetConnectionString("DeafultConnectionString")));

        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        services.AddFirebaseAuthentication(Configuration.GetSection("FirebaseAuth:issuer").Value,
            Configuration.GetSection("FirebaseAuth:audience").Value);

      //  services.AddIdentity<Auth.ApplicationUser, IdentityRole>().AddEntityFrameworkStores<ApplicationDBContext>();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseHsts();
        }

        app.UseAuthentication();
        app.UseHttpsRedirection();
        app.UseMvc();
    }
}
public void配置服务(IServiceCollection服务)
{
services.AddDbContext(options=>options.UseNpgsql(
GetConnectionString(“DeafultConnectionString”);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddFirebaseAuthentication(Configuration.GetSection(“FirebaseAuth:issuer”).Value,
Configuration.GetSection(“FirebaseAuth:audience”).Value);
//services.AddIdentity().AddEntityFrameworkStores();
}
//此方法由运行时调用。使用此方法配置HTTP请求管道。
公共无效配置(IApplicationBuilder应用程序,IHostingEnvironment环境)
{
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
其他的
{
app.UseHsts();
}
app.UseAuthentication();
app.UseHttpsRedirection();
app.UseMvc();
}
}
而且这个效果非常好! 我试图理解如何连接数据库来存储用户详细信息,但我无法理解它是如何完成的。 有什么帮助吗