Skip to content

Commit

Permalink
✨ feat: implements APIs for managing ACLs
Browse files Browse the repository at this point in the history
Headscale currently lacks the APIs to manange the ACLs. The only way
possible currently is to load the ACLs via file and changes to the
policy requires reloading the headscale process. This also makes it
difficult to integrate your headscale via APIs with no ACL management.

This commit introduces two APIs that allow your to get and set the
policy.
  • Loading branch information
pallabpain committed Feb 24, 2024
1 parent 7a920ee commit 4d8e125
Show file tree
Hide file tree
Showing 20 changed files with 1,573 additions and 379 deletions.
440 changes: 440 additions & 0 deletions gen/go/headscale/v1/acl.pb.go

Large diffs are not rendered by default.

514 changes: 268 additions & 246 deletions gen/go/headscale/v1/headscale.pb.go

Large diffs are not rendered by default.

240 changes: 225 additions & 15 deletions gen/go/headscale/v1/headscale.pb.gw.go

Large diffs are not rendered by default.

209 changes: 127 additions & 82 deletions gen/go/headscale/v1/headscale_grpc.pb.go

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions gen/openapiv2/headscale/v1/acl.swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"swagger": "2.0",
"info": {
"title": "headscale/v1/acl.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}
1 change: 0 additions & 1 deletion gen/openapiv2/headscale/v1/apikey.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
Expand Down
1 change: 0 additions & 1 deletion gen/openapiv2/headscale/v1/device.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
Expand Down
121 changes: 102 additions & 19 deletions gen/openapiv2/headscale/v1/headscale.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,59 @@
"application/json"
],
"paths": {
"/api/v1/acl": {
"get": {
"summary": "--- ACL start ---",
"operationId": "HeadscaleService_GetACL",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1GetACLResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"HeadscaleService"
]
},
"post": {
"operationId": "HeadscaleService_SetACL",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1SetACLResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1SetACLRequest"
}
}
],
"tags": [
"HeadscaleService"
]
}
},
"/api/v1/apikey": {
"get": {
"operationId": "HeadscaleService_ListApiKeys",
Expand Down Expand Up @@ -419,7 +472,15 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/HeadscaleServiceSetTagsBody"
"type": "object",
"properties": {
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
],
Expand Down Expand Up @@ -823,17 +884,6 @@
}
},
"definitions": {
"HeadscaleServiceSetTagsBody": {
"type": "object",
"properties": {
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"protobufAny": {
"type": "object",
"properties": {
Expand All @@ -843,6 +893,14 @@
},
"additionalProperties": {}
},
"protobufNullValue": {
"type": "string",
"enum": [
"NULL_VALUE"
],
"default": "NULL_VALUE",
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\nThe JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
},
"rpcStatus": {
"type": "object",
"properties": {
Expand All @@ -856,7 +914,6 @@
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
Expand Down Expand Up @@ -1030,6 +1087,18 @@
"v1ExpirePreAuthKeyResponse": {
"type": "object"
},
"v1GetACLResponse": {
"type": "object",
"properties": {
"policy": {
"type": "object"
},
"updatedAt": {
"type": "string",
"format": "date-time"
}
}
},
"v1GetNodeResponse": {
"type": "object",
"properties": {
Expand All @@ -1044,7 +1113,6 @@
"routes": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1Route"
}
}
Expand All @@ -1056,7 +1124,6 @@
"routes": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1Route"
}
}
Expand All @@ -1076,7 +1143,6 @@
"apiKeys": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1ApiKey"
}
}
Expand All @@ -1088,7 +1154,6 @@
"nodes": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1Node"
}
}
Expand All @@ -1100,7 +1165,6 @@
"preAuthKeys": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1PreAuthKey"
}
}
Expand All @@ -1112,7 +1176,6 @@
"users": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1User"
}
}
Expand Down Expand Up @@ -1305,6 +1368,26 @@
}
}
},
"v1SetACLRequest": {
"type": "object",
"properties": {
"policy": {
"type": "object"
}
}
},
"v1SetACLResponse": {
"type": "object",
"properties": {
"policy": {
"type": "object"
},
"updatedAt": {
"type": "string",
"format": "date-time"
}
}
},
"v1SetTagsResponse": {
"type": "object",
"properties": {
Expand Down
1 change: 0 additions & 1 deletion gen/openapiv2/headscale/v1/node.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
Expand Down
1 change: 0 additions & 1 deletion gen/openapiv2/headscale/v1/preauthkey.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
Expand Down
1 change: 0 additions & 1 deletion gen/openapiv2/headscale/v1/routes.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
Expand Down
1 change: 0 additions & 1 deletion gen/openapiv2/headscale/v1/user.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
Expand Down
Loading

0 comments on commit 4d8e125

Please sign in to comment.