Class ApiKeyConstants
Well-known constants for API key authentication.
public static class ApiKeyConstants
- Inheritance
-
ApiKeyConstants
- Inherited Members
Fields
AccessLevelClaim
Claim type for the access level.
[Obsolete("Use TeamClaimTypes.AccessLevel instead.")]
public const string AccessLevelClaim = "AccessLevel"
Field Value
AnyKeyPolicyName
Authorization policy name accepting any valid API key, team or system.
public const string AnyKeyPolicyName = "AnyApiKeyPolicy"
Field Value
Remarks
PolicyName and SystemPolicyName are disjoint, not a hierarchy.
The first refuses a system key; the second refuses a team key. ASP.NET Core combines
policies when several are required, so RequireAuthorization(PolicyName, SystemPolicyName)
admits nothing — a trap the naming invites, since "system" reads like "team plus more".
Use this where an endpoint should be reachable by either kind, which was previously only possible
by hand-writing a policy. It asserts nothing about IsSystemKey in either direction, which is
also what Tharga.Mcp's RequireAuth policy does — so an MCP endpoint already behaves
this way and needs no policy named here.
HeaderName
HTTP header name for the API key.
public const string HeaderName = "X-API-KEY"
Field Value
OpenApiSchemeId
OpenAPI security scheme identifier.
public const string OpenApiSchemeId = "ApiKey"
Field Value
PolicyName
Authorization policy name for team API keys. Use with
[Authorize(Policy = ApiKeyConstants.PolicyName)].
public const string PolicyName = "ApiKeyPolicy"
Field Value
Remarks
Rejects system keys. This and SystemPolicyName are disjoint, not a hierarchy — see AnyKeyPolicyName.
SchemeName
Authentication scheme name.
public const string SchemeName = "ApiKeyScheme"
Field Value
SystemPolicyName
Authorization policy name for system API keys (keys not bound to a team).
public const string SystemPolicyName = "SystemApiKeyPolicy"
Field Value
Remarks
Rejects team keys. See AnyKeyPolicyName.
TeamKeyClaim
Claim type for the team key.
[Obsolete("Use TeamClaimTypes.TeamKey instead.")]
public const string TeamKeyClaim = "TeamKey"
Field Value
ThargaApiPolicyName
Authorization policy for the toolkit's own HTTP endpoints. Requires an authenticated caller against
ThargaControllerOptions.AuthenticationSchemes — the API-key scheme by default.
public const string ThargaApiPolicyName = "ThargaApiPolicy"