|
|
|
|
@ -25,26 +25,29 @@ namespace Microsoft.Extensions.DependencyInjection
|
|
|
|
|
{
|
|
|
|
|
options.ClaimActions.MapAbpClaimTypes();
|
|
|
|
|
|
|
|
|
|
options.Events = new OpenIdConnectEvents
|
|
|
|
|
configureOptions?.Invoke(options);
|
|
|
|
|
|
|
|
|
|
options.Events ??= new OpenIdConnectEvents();
|
|
|
|
|
var authorizationCodeReceived = options.Events.OnAuthorizationCodeReceived ?? (_ => Task.CompletedTask);
|
|
|
|
|
|
|
|
|
|
options.Events.OnAuthorizationCodeReceived = receivedContext =>
|
|
|
|
|
{
|
|
|
|
|
OnAuthorizationCodeReceived = receivedContext =>
|
|
|
|
|
SetAbpTenantId(receivedContext);
|
|
|
|
|
return authorizationCodeReceived.Invoke(receivedContext);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SetAbpTenantId(AuthorizationCodeReceivedContext receivedContext)
|
|
|
|
|
{
|
|
|
|
|
var tenantKey = receivedContext.HttpContext.RequestServices
|
|
|
|
|
.GetRequiredService<IOptionsSnapshot<AbpAspNetCoreMultiTenancyOptions>>().Value.TenantKey;
|
|
|
|
|
|
|
|
|
|
if (receivedContext.HttpContext.Request != null &&
|
|
|
|
|
receivedContext.Request.Cookies.ContainsKey(tenantKey))
|
|
|
|
|
if (receivedContext.Request.Cookies.ContainsKey(tenantKey))
|
|
|
|
|
{
|
|
|
|
|
receivedContext.TokenEndpointRequest.SetParameter(tenantKey,
|
|
|
|
|
receivedContext.Request.Cookies[tenantKey]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
configureOptions?.Invoke(options);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|