Skip to content

Instantly share code, notes, and snippets.

@nkcmr
Last active May 11, 2018 19:32
Show Gist options
  • Save nkcmr/2d0077f176bc066c004be82f76b03a17 to your computer and use it in GitHub Desktop.
Save nkcmr/2d0077f176bc066c004be82f76b03a17 to your computer and use it in GitHub Desktop.
JSON schema for authr rules as of authr-v1.1.1
{
"type": "object",
"additionalProperties": false,
"required": [
"access",
"where"
],
"properties": {
"access": {
"type": "string",
"enum": [
"allow",
"deny"
]
},
"where": {
"type": "object",
"additionalProperties": false,
"required": [
"rsrc_type",
"rsrc_match",
"action"
],
"properties": {
"rsrc_type": {
"$ref": "#/definitions/SlugSet"
},
"rsrc_match": {
"$ref": "#/definitions/ConditionSet"
},
"action": {
"$ref": "#/definitions/SlugSet"
}
}
},
"$meta": {}
},
"definitions": {
"ConditionSet": {
"definitions": {
"inner": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#/definitions/ConditionSet/definitions/Condition"
},
{
"$ref": "#/definitions/ConditionSet"
}
]
}
},
"Condition": {
"type": "array",
"maxItems": 3,
"minItems": 3,
"items": [
{},
{
"type": "string",
"enum": [
"=",
"!=",
"~=",
"~",
"~*",
"!~",
"!~*",
"$in",
"$nin",
"&",
"-"
]
},
{}
]
}
},
"oneOf": [
{
"$ref": "#/definitions/ConditionSet/definitions/inner"
},
{
"type": "object",
"additionalProperties": false,
"required": [
"$and"
],
"properties": {
"$and": {
"$ref": "#/definitions/ConditionSet/definitions/inner"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"$or"
],
"properties": {
"$or": {
"$ref": "#/definitions/ConditionSet/definitions/inner"
}
}
}
]
},
"SlugSet": {
"definitions": {
"inner": {
"oneOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"minLength": 1
}
}
]
}
},
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"$not"
],
"properties": {
"$not": {
"$ref": "#/definitions/SlugSet/definitions/inner"
}
}
},
{
"$ref": "#/definitions/SlugSet/definitions/inner"
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment