I'm trying to get client id and client secret dynamicaly without passing string parameter of "xyzClientId" and "xyzClientSecret"
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
bool isTenantForbidden = false;
var headers = context.HttpContext.Request.Headers;
headers.Add("xyzClientId", "someclientId");
headers.Add("xyzClientSecret", "someClientSecret");
headers.TryGetValue("xyzClientId", out var clientId);
headers.TryGetValue("xyxClientSecret", out var clientSecret);
var tenant = this.tenantService.GetTenant(clientId, clientSecret);
isTenantForbidden = await this.ForbidTenant(tenant);
if (isTenantForbidden)
{
throw new Exception("Restricted resource!");
}
await next();
}
How I get these access informations like getting Bearer token:
context.HttpContext.Request.Headers.TryGetValue("Authorization", out authorizationToken);