Task OnApiKeyValidated(ApiKeyValidatedContext context) { if (context.ApiKey == configuration.GetSection("ApiKeys")["DefaultKey"]) { context.Success(); } return(Task.CompletedTask); }
public void Validacia1(ApiKeyValidatedContext context) { // foreach (var kluc in this.databaza.ApiKeys) { // if (context.ApiKey == kluc.Key) // { context.Principal = new ClaimsPrincipal(); context.Success(); // } // else if (context.ApiKey == "789") // { throw new NotSupportedException("You must upgrade."); // } //} }