Azure AD B2C Integrating with Restful API



因此,我按照此处指定的演练进行操作。

以下是流程:

用户在 SigInSignUp 策略页(由 Azure AD B2C 提供(上输入用户名/密码,并重定向到我编写的用于检查某些业务逻辑的 ASP.NET Web API。

此时,我想根据作为输出声明的一部分返回的标志重定向到不同的 URL。我怎样才能做到这一点?

我想

根据我作为输出声明的一部分返回的标志重定向到不同的 URL。

注册OnTicketReceived

builder.AddOpenIdConnect(options => {
options.Events = new OpenIdConnectEvents {OnTicketReceived = OnTicketReceived };
});

使用事件处理程序对响应执行某些操作(如重定向(,或设置稍后读取的标志。

private Task OnTicketReceived(TicketReceivedContext context)
{
// set a flag for later. Maybe middleware?
context.HttpContext.Items["DoSomething"] = true;
// Or just handle the response completely
if(context.Principal.HasClaim(claim => ...predicate about the claim... ))
{
context.Response.Clear();
context.Response.Headers.Add("Location", "http://wherever.you.want.com");
// tell the OpenIdConnect middleware we got this
context.HandleResponse();
}
Debug.WriteLine(nameof(OnTicketReceived));
//context.Principal = TransformClaims(context, context.Principal);
return Task.CompletedTask;
}

最新更新