{
  "$id": "https://opendatafabric.org/schemas/auth/v1alpha1/SubjectHandle",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Resolved reference to a party a grant is given to.",
  "$defs": {
    "Resource": {
      "description": "A specific `User`, `ServiceAccount`, `Node`, or members of a `Group`.",
      "type": "object",
      "required": [
        "type",
        "id",
        "name"
      ],
      "properties": {
        "type": {
          "type": "string",
          "format": "type-uri",
          "description": "Type URI of the subject resource."
        },
        "account": {
          "$ref": "https://opendatafabric.org/schemas/auth/v1alpha1/ResourceOwnerHandle",
          "description": "Account that owns the subject resource (for service accounts and groups).",
          "unevaluatedProperties": false
        },
        "id": {
          "type": "string",
          "format": "resource-id",
          "description": "ID of the subject resource."
        },
        "did": {
          "type": "string",
          "format": "did",
          "description": "DID of the subject resource, if applicable."
        },
        "name": {
          "type": "string",
          "format": "resource-name",
          "description": "Name of the subject resource."
        }
      }
    },
    "Authenticated": {
      "description": "Matches any authenticated principal.",
      "type": "object",
      "required": [],
      "properties": {}
    },
    "Anonymous": {
      "description": "Matches any unauthenticated principal.",
      "type": "object",
      "required": [],
      "properties": {}
    },
    "Everyone": {
      "description": "Matches any principal, authenticated or not.",
      "type": "object",
      "required": [],
      "properties": {}
    }
  },
  "oneOf": [
    {
      "allOf": [
        {
          "properties": {
            "kind": {
              "type": "string",
              "const": "Resource"
            }
          },
          "required": [
            "kind"
          ]
        },
        {
          "$ref": "#/$defs/Resource"
        }
      ]
    },
    {
      "allOf": [
        {
          "properties": {
            "kind": {
              "type": "string",
              "const": "Authenticated"
            }
          },
          "required": [
            "kind"
          ]
        },
        {
          "$ref": "#/$defs/Authenticated"
        }
      ]
    },
    {
      "allOf": [
        {
          "properties": {
            "kind": {
              "type": "string",
              "const": "Anonymous"
            }
          },
          "required": [
            "kind"
          ]
        },
        {
          "$ref": "#/$defs/Anonymous"
        }
      ]
    },
    {
      "allOf": [
        {
          "properties": {
            "kind": {
              "type": "string",
              "const": "Everyone"
            }
          },
          "required": [
            "kind"
          ]
        },
        {
          "$ref": "#/$defs/Everyone"
        }
      ]
    }
  ]
}
