Is there a way to add claims in an ASP.NET Core middleware after Authentication?

后端 未结 5 1703
梦谈多话
梦谈多话 2021-02-04 02:30

I have this in my startup:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperE         


        
5条回答
  •  甜味超标
    2021-02-04 03:12

    It depends on what do you want to do and which scheme you use.

    For example, if you use JwtBearer then you could utilize JwtBearerOptions.Events to handle particular events raised by the middleware. You need to set that in your ConfigureServices method of Startup class.

    That would give you more granular control of what precise case you want to have your Claims added to, for example, OnTokenValidated.

提交回复
热议问题