ApiKeyDefaults
Package Trax.Api.Auth.ApiKeyNamespace Trax.Api.Auth.ApiKeySource ApiKeyDefaults.cs
NO WARRANTY. Trax auth is plumbing, not a security product. You are solely responsible for securing systems that use it. See API Security.
The constants of the Trax API-key scheme that AddTraxApiKeyAuth registers.
Signature
public static class ApiKeyDefaults
{
public const string SchemeName = "TraxApiKey";
public const string PolicyName = "ApiKeyPolicy";
public const string HeaderName = "X-Api-Key";
}Members
| Constant | Value | Description |
|---|---|---|
SchemeName | TraxApiKey | The authentication scheme name. A principal it authenticates carries the id TraxApiKey:{id}. |
PolicyName | ApiKeyPolicy | The authorization policy AddTraxApiKeyAuth registers. It is satisfied only by a caller the API-key scheme authenticated, wherever it is evaluated: the endpoint gate, GateOperations, [TraxAuthorize(Policy = ...)], sockets. |
HeaderName | X-Api-Key | The default request header. ApiKeyAuthenticationOptions.HeaderName overrides it. |
Example
services.AddTraxGraphQL(graphql => graphql.RequireAuthorization(ApiKeyDefaults.PolicyName));
app.MapGet("/reports", () => Results.Ok()).RequireAuthorization(ApiKeyDefaults.PolicyName);