|
using System.Security.Claims;
using System.Security.Principal;
...
app.UseStaticFiles();
app.Use(async (context, next) =>
{
if (!context.User.Identities.Any(i => i.IsAuthenticated))
{
//Assign all anonymous users the same generic identity, which is authenticated
context.User = new ClaimsPrincipal(new GenericIdentity("anonymous"));
}
await next.Invoke();
});
... |
Hi tanks for your answer. I'we see that is possible to set the headers in grid datamanager.
It's impossible to pass directly inside the tag the @await Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.GetTokenAsync(httpContextAccessor.HttpContext, "access_token") instruction.
It's possible to pass with a javascript function ?
Thanks
Stefano Capobianco
Hi i've found a workaround. I've added a load event in the header of ejGrid
<ej-grid id="Grid" locale="it-IT" allow-sorting="true" allow-paging="true"
is-responsive="true" enable-responsive-row="true" show-stacked-header="true"
toolbar-click="GridToolbarClicked" action-complete="GridActionComplete"
row-data-bound="GridRowDatabound" databound="GridShowToolbarTooltip"
load="GridLoad">
and i've added the following function
function GridLoad(args) {
alert('@await Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.GetTokenAsync(httpContextAccessor.HttpContext, "access_token")');
this.model.dataSource.dataSource.headers = [];
this.model.dataSource.dataSource.headers.push({ "Authorization": "Bearer " + '@await Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.GetTokenAsync(httpContextAccessor.HttpContext, "access_token")' });
}
and the authentication mechanism work fine
Thanks
Stefano Capobianco