mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-14 06:51:15 +00:00
API - CRUD for peers, interfaces and users (#340)
Public REST API implementation to handle peers, interfaces and users. It also includes some simple provisioning endpoints. The Swagger API documentation is available under /api/v1/doc.html
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "WireGuard Portal API - a testing API endpoint",
|
||||
"title": "WireGuard Portal API",
|
||||
"description": "WireGuard Portal API - UI Endpoints",
|
||||
"title": "WireGuard Portal SPA-UI API",
|
||||
"contact": {
|
||||
"name": "WireGuard Portal Developers",
|
||||
"url": "https://github.com/h44z/wg-portal"
|
||||
@@ -175,6 +175,26 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/config/settings": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Configuration"
|
||||
],
|
||||
"summary": "Get the frontend settings object.",
|
||||
"operationId": "config_handleSettingsGet",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The JavaScript contents",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/csrf": {
|
||||
"get": {
|
||||
"produces": [
|
||||
@@ -499,6 +519,91 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/interface/{id}/apply-peer-defaults": {
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Interface"
|
||||
],
|
||||
"summary": "Apply all peer defaults to the available peers.",
|
||||
"operationId": "interfaces_handleApplyPeerDefaultsPost",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The interface identifier",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "The interface data",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Interface"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No content if applying peer defaults was successful"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/interface/{id}/save-config": {
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Interface"
|
||||
],
|
||||
"summary": "Save the interface configuration in wg-quick format to a file.",
|
||||
"operationId": "interfaces_handleSaveConfigPost",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The interface identifier",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No content if saving the configuration was successful"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/now": {
|
||||
"get": {
|
||||
"description": "Nothing more to describe...",
|
||||
@@ -526,9 +631,50 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/peer/config-mail": {
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Peer"
|
||||
],
|
||||
"summary": "Send peer configuration via email.",
|
||||
"operationId": "peers_handleEmailPost",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The peer mail request data",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.PeerMailRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "No content if mail sending was successful"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/peer/config-qr/{id}": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"image/png",
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
@@ -536,11 +682,20 @@
|
||||
],
|
||||
"summary": "Get peer configuration as qr code.",
|
||||
"operationId": "peers_handleQrCodeGet",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The peer identifier",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
"type": "file"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
@@ -568,6 +723,15 @@
|
||||
],
|
||||
"summary": "Get peer configuration as string.",
|
||||
"operationId": "peers_handleConfigGet",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The peer identifier",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
@@ -634,6 +798,59 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/peer/iface/{iface}/multiplenew": {
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Peer"
|
||||
],
|
||||
"summary": "Create multiple new peers for the given interface.",
|
||||
"operationId": "peers_handleCreateMultiplePost",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The interface identifier",
|
||||
"name": "iface",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "The peer creation request data",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.MultiPeerRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/model.Peer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/peer/iface/{iface}/new": {
|
||||
"post": {
|
||||
"produces": [
|
||||
@@ -725,6 +942,47 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/peer/iface/{iface}/stats": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Peer"
|
||||
],
|
||||
"summary": "Get peer stats for the given interface.",
|
||||
"operationId": "peers_handleStatsGet",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "The interface identifier",
|
||||
"name": "iface",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.PeerStats"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/peer/{id}": {
|
||||
"get": {
|
||||
"produces": [
|
||||
@@ -1041,6 +1299,70 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{id}/api/disable": {
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"summary": "Disable the REST API for the given user.",
|
||||
"operationId": "users_handleApiDisablePost",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.User"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{id}/api/enable": {
|
||||
"post": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"summary": "Enable the REST API for the given user.",
|
||||
"operationId": "users_handleApiEnablePost",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.User"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{id}/peers": {
|
||||
"get": {
|
||||
"produces": [
|
||||
@@ -1061,6 +1383,44 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{id}/stats": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Users"
|
||||
],
|
||||
"summary": "Get peer stats for the given user.",
|
||||
"operationId": "users_handleStatsGet",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.PeerStats"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Error"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
@@ -1072,6 +1432,53 @@
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"model.ConfigOption-array_string": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Overridable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Value": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.ConfigOption-int": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Overridable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Value": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.ConfigOption-string": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Overridable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Value": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.ConfigOption-uint32": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Overridable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Value": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.Error": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1083,25 +1490,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.Int32ConfigOption": {
|
||||
"model.ExpiryDate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Overridable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Value": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.IntConfigOption": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Overridable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Value": {
|
||||
"type": "integer"
|
||||
"time.Time": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1290,6 +1683,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.MultiPeerRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Identifiers": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Suffix": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.Peer": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1304,7 +1711,7 @@
|
||||
"description": "all allowed ip subnets, comma seperated",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringSliceConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-array_string"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1328,7 +1735,7 @@
|
||||
"description": "the dns server that should be set if the interface is up, comma separated",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringSliceConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-array_string"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1336,7 +1743,7 @@
|
||||
"description": "the dns search option string that should be set if the interface is up, will be appended to DnsStr",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringSliceConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-array_string"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1344,7 +1751,7 @@
|
||||
"description": "the endpoint address",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-string"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1352,13 +1759,17 @@
|
||||
"description": "the endpoint public key",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ExpiresAt": {
|
||||
"description": "expiry dates for peers",
|
||||
"type": "string"
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.ExpiryDate"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ExtraAllowedIPs": {
|
||||
"description": "all allowed ip subnets on the server side, comma seperated",
|
||||
@@ -1371,7 +1782,7 @@
|
||||
"description": "a firewall mark",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.Int32ConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-uint32"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1392,7 +1803,7 @@
|
||||
"description": "the device MTU",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.IntConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-int"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1404,7 +1815,7 @@
|
||||
"description": "the persistent keep-alive interval",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.IntConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-int"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1412,7 +1823,7 @@
|
||||
"description": "action that is executed after the device is down",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-string"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1420,7 +1831,7 @@
|
||||
"description": "action that is executed after the device is up",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-string"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1428,7 +1839,7 @@
|
||||
"description": "action that is executed before the device is down",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-string"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1436,7 +1847,7 @@
|
||||
"description": "action that is executed before the device is up",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-string"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1458,7 +1869,7 @@
|
||||
"description": "the routing table",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.StringConfigOption"
|
||||
"$ref": "#/definitions/model.ConfigOption-string"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1468,6 +1879,66 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.PeerMailRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Identifiers": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"LinkOnly": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.PeerStatData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"BytesReceived": {
|
||||
"type": "integer"
|
||||
},
|
||||
"BytesTransmitted": {
|
||||
"type": "integer"
|
||||
},
|
||||
"EndpointAddress": {
|
||||
"type": "string"
|
||||
},
|
||||
"IsConnected": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"IsPingable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"LastHandshake": {
|
||||
"type": "string"
|
||||
},
|
||||
"LastPing": {
|
||||
"type": "string"
|
||||
},
|
||||
"LastSessionStart": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.PeerStats": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Enabled": {
|
||||
"description": "peer stats tracking enabled",
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"Stats": {
|
||||
"description": "stats, map key = Peer identifier",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/model.PeerStatData"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.SessionInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1491,34 +1962,35 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.StringConfigOption": {
|
||||
"model.Settings": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Overridable": {
|
||||
"ApiAdminOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Value": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.StringSliceConfigOption": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Overridable": {
|
||||
"MailLinkOnly": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Value": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
"PersistentConfigSupported": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"SelfProvisioning": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model.User": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ApiEnabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ApiToken": {
|
||||
"type": "string"
|
||||
},
|
||||
"ApiTokenCreated": {
|
||||
"type": "string"
|
||||
},
|
||||
"Department": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1545,6 +2017,14 @@
|
||||
"Lastname": {
|
||||
"type": "string"
|
||||
},
|
||||
"Locked": {
|
||||
"description": "if this field is set, the user is locked",
|
||||
"type": "boolean"
|
||||
},
|
||||
"LockedReason": {
|
||||
"description": "the reason why the user has been locked",
|
||||
"type": "string"
|
||||
},
|
||||
"Notes": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@@ -1,5 +1,35 @@
|
||||
basePath: /api/v0
|
||||
definitions:
|
||||
model.ConfigOption-array_string:
|
||||
properties:
|
||||
Overridable:
|
||||
type: boolean
|
||||
Value:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
model.ConfigOption-int:
|
||||
properties:
|
||||
Overridable:
|
||||
type: boolean
|
||||
Value:
|
||||
type: integer
|
||||
type: object
|
||||
model.ConfigOption-string:
|
||||
properties:
|
||||
Overridable:
|
||||
type: boolean
|
||||
Value:
|
||||
type: string
|
||||
type: object
|
||||
model.ConfigOption-uint32:
|
||||
properties:
|
||||
Overridable:
|
||||
type: boolean
|
||||
Value:
|
||||
type: integer
|
||||
type: object
|
||||
model.Error:
|
||||
properties:
|
||||
Code:
|
||||
@@ -7,19 +37,10 @@ definitions:
|
||||
Message:
|
||||
type: string
|
||||
type: object
|
||||
model.Int32ConfigOption:
|
||||
model.ExpiryDate:
|
||||
properties:
|
||||
Overridable:
|
||||
type: boolean
|
||||
Value:
|
||||
type: integer
|
||||
type: object
|
||||
model.IntConfigOption:
|
||||
properties:
|
||||
Overridable:
|
||||
type: boolean
|
||||
Value:
|
||||
type: integer
|
||||
time.Time:
|
||||
type: string
|
||||
type: object
|
||||
model.Interface:
|
||||
properties:
|
||||
@@ -160,6 +181,15 @@ definitions:
|
||||
example: /auth/google/login
|
||||
type: string
|
||||
type: object
|
||||
model.MultiPeerRequest:
|
||||
properties:
|
||||
Identifiers:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
Suffix:
|
||||
type: string
|
||||
type: object
|
||||
model.Peer:
|
||||
properties:
|
||||
Addresses:
|
||||
@@ -169,7 +199,7 @@ definitions:
|
||||
type: array
|
||||
AllowedIPs:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringSliceConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-array_string'
|
||||
description: all allowed ip subnets, comma seperated
|
||||
CheckAliveAddress:
|
||||
description: optional ip address or DNS name that is used for ping checks
|
||||
@@ -185,25 +215,26 @@ definitions:
|
||||
type: string
|
||||
Dns:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringSliceConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-array_string'
|
||||
description: the dns server that should be set if the interface is up, comma
|
||||
separated
|
||||
DnsSearch:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringSliceConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-array_string'
|
||||
description: the dns search option string that should be set if the interface
|
||||
is up, will be appended to DnsStr
|
||||
Endpoint:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-string'
|
||||
description: the endpoint address
|
||||
EndpointPublicKey:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-string'
|
||||
description: the endpoint public key
|
||||
ExpiresAt:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.ExpiryDate'
|
||||
description: expiry dates for peers
|
||||
type: string
|
||||
ExtraAllowedIPs:
|
||||
description: all allowed ip subnets on the server side, comma seperated
|
||||
items:
|
||||
@@ -211,7 +242,7 @@ definitions:
|
||||
type: array
|
||||
FirewallMark:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.Int32ConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-uint32'
|
||||
description: a firewall mark
|
||||
Identifier:
|
||||
description: peer unique identifier
|
||||
@@ -225,30 +256,30 @@ definitions:
|
||||
type: string
|
||||
Mtu:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.IntConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-int'
|
||||
description: the device MTU
|
||||
Notes:
|
||||
description: a note field for peers
|
||||
type: string
|
||||
PersistentKeepalive:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.IntConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-int'
|
||||
description: the persistent keep-alive interval
|
||||
PostDown:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-string'
|
||||
description: action that is executed after the device is down
|
||||
PostUp:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-string'
|
||||
description: action that is executed after the device is up
|
||||
PreDown:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-string'
|
||||
description: action that is executed before the device is down
|
||||
PreUp:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-string'
|
||||
description: action that is executed before the device is up
|
||||
PresharedKey:
|
||||
description: the pre-shared Key of the peer
|
||||
@@ -263,12 +294,52 @@ definitions:
|
||||
type: string
|
||||
RoutingTable:
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.StringConfigOption'
|
||||
- $ref: '#/definitions/model.ConfigOption-string'
|
||||
description: the routing table
|
||||
UserIdentifier:
|
||||
description: the owner
|
||||
type: string
|
||||
type: object
|
||||
model.PeerMailRequest:
|
||||
properties:
|
||||
Identifiers:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
LinkOnly:
|
||||
type: boolean
|
||||
type: object
|
||||
model.PeerStatData:
|
||||
properties:
|
||||
BytesReceived:
|
||||
type: integer
|
||||
BytesTransmitted:
|
||||
type: integer
|
||||
EndpointAddress:
|
||||
type: string
|
||||
IsConnected:
|
||||
type: boolean
|
||||
IsPingable:
|
||||
type: boolean
|
||||
LastHandshake:
|
||||
type: string
|
||||
LastPing:
|
||||
type: string
|
||||
LastSessionStart:
|
||||
type: string
|
||||
type: object
|
||||
model.PeerStats:
|
||||
properties:
|
||||
Enabled:
|
||||
description: peer stats tracking enabled
|
||||
example: true
|
||||
type: boolean
|
||||
Stats:
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/model.PeerStatData'
|
||||
description: stats, map key = Peer identifier
|
||||
type: object
|
||||
type: object
|
||||
model.SessionInfo:
|
||||
properties:
|
||||
IsAdmin:
|
||||
@@ -284,24 +355,25 @@ definitions:
|
||||
UserLastname:
|
||||
type: string
|
||||
type: object
|
||||
model.StringConfigOption:
|
||||
model.Settings:
|
||||
properties:
|
||||
Overridable:
|
||||
ApiAdminOnly:
|
||||
type: boolean
|
||||
Value:
|
||||
type: string
|
||||
type: object
|
||||
model.StringSliceConfigOption:
|
||||
properties:
|
||||
Overridable:
|
||||
MailLinkOnly:
|
||||
type: boolean
|
||||
PersistentConfigSupported:
|
||||
type: boolean
|
||||
SelfProvisioning:
|
||||
type: boolean
|
||||
Value:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
model.User:
|
||||
properties:
|
||||
ApiEnabled:
|
||||
type: boolean
|
||||
ApiToken:
|
||||
type: string
|
||||
ApiTokenCreated:
|
||||
type: string
|
||||
Department:
|
||||
type: string
|
||||
Disabled:
|
||||
@@ -320,6 +392,12 @@ definitions:
|
||||
type: boolean
|
||||
Lastname:
|
||||
type: string
|
||||
Locked:
|
||||
description: if this field is set, the user is locked
|
||||
type: boolean
|
||||
LockedReason:
|
||||
description: the reason why the user has been locked
|
||||
type: string
|
||||
Notes:
|
||||
type: string
|
||||
Password:
|
||||
@@ -337,8 +415,8 @@ info:
|
||||
contact:
|
||||
name: WireGuard Portal Developers
|
||||
url: https://github.com/h44z/wg-portal
|
||||
description: WireGuard Portal API - a testing API endpoint
|
||||
title: WireGuard Portal API
|
||||
description: WireGuard Portal API - UI Endpoints
|
||||
title: WireGuard Portal SPA-UI API
|
||||
version: "0.0"
|
||||
paths:
|
||||
/auth/{provider}/callback:
|
||||
@@ -448,6 +526,19 @@ paths:
|
||||
summary: Get the dynamic frontend configuration javascript.
|
||||
tags:
|
||||
- Configuration
|
||||
/config/settings:
|
||||
get:
|
||||
operationId: config_handleSettingsGet
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: The JavaScript contents
|
||||
schema:
|
||||
type: string
|
||||
summary: Get the frontend settings object.
|
||||
tags:
|
||||
- Configuration
|
||||
/csrf:
|
||||
get:
|
||||
operationId: base_handleCsrfGet
|
||||
@@ -536,6 +627,62 @@ paths:
|
||||
summary: Update the interface record.
|
||||
tags:
|
||||
- Interface
|
||||
/interface/{id}/apply-peer-defaults:
|
||||
post:
|
||||
operationId: interfaces_handleApplyPeerDefaultsPost
|
||||
parameters:
|
||||
- description: The interface identifier
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: The interface data
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/model.Interface'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No content if applying peer defaults was successful
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
summary: Apply all peer defaults to the available peers.
|
||||
tags:
|
||||
- Interface
|
||||
/interface/{id}/save-config:
|
||||
post:
|
||||
operationId: interfaces_handleSaveConfigPost
|
||||
parameters:
|
||||
- description: The interface identifier
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No content if saving the configuration was successful
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
summary: Save the interface configuration in wg-quick format to a file.
|
||||
tags:
|
||||
- Interface
|
||||
/interface/all:
|
||||
get:
|
||||
operationId: interfaces_handleAllGet
|
||||
@@ -762,16 +909,49 @@ paths:
|
||||
summary: Update the given peer record.
|
||||
tags:
|
||||
- Peer
|
||||
/peer/config-mail:
|
||||
post:
|
||||
operationId: peers_handleEmailPost
|
||||
parameters:
|
||||
- description: The peer mail request data
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/model.PeerMailRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No content if mail sending was successful
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
summary: Send peer configuration via email.
|
||||
tags:
|
||||
- Peer
|
||||
/peer/config-qr/{id}:
|
||||
get:
|
||||
operationId: peers_handleQrCodeGet
|
||||
parameters:
|
||||
- description: The peer identifier
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- image/png
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
type: string
|
||||
type: file
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
@@ -786,6 +966,12 @@ paths:
|
||||
/peer/config/{id}:
|
||||
get:
|
||||
operationId: peers_handleConfigGet
|
||||
parameters:
|
||||
- description: The peer identifier
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -833,6 +1019,41 @@ paths:
|
||||
summary: Get peers for the given interface.
|
||||
tags:
|
||||
- Peer
|
||||
/peer/iface/{iface}/multiplenew:
|
||||
post:
|
||||
operationId: peers_handleCreateMultiplePost
|
||||
parameters:
|
||||
- description: The interface identifier
|
||||
in: path
|
||||
name: iface
|
||||
required: true
|
||||
type: string
|
||||
- description: The peer creation request data
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/model.MultiPeerRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/model.Peer'
|
||||
type: array
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
summary: Create multiple new peers for the given interface.
|
||||
tags:
|
||||
- Peer
|
||||
/peer/iface/{iface}/new:
|
||||
post:
|
||||
operationId: peers_handleCreatePost
|
||||
@@ -893,6 +1114,33 @@ paths:
|
||||
summary: Prepare a new peer for the given interface.
|
||||
tags:
|
||||
- Peer
|
||||
/peer/iface/{iface}/stats:
|
||||
get:
|
||||
operationId: peers_handleStatsGet
|
||||
parameters:
|
||||
- description: The interface identifier
|
||||
in: path
|
||||
name: iface
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/model.PeerStats'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
summary: Get peer stats for the given interface.
|
||||
tags:
|
||||
- Peer
|
||||
/user/{id}:
|
||||
delete:
|
||||
operationId: users_handleDelete
|
||||
@@ -972,6 +1220,48 @@ paths:
|
||||
summary: Update the user record.
|
||||
tags:
|
||||
- Users
|
||||
/user/{id}/api/disable:
|
||||
post:
|
||||
operationId: users_handleApiDisablePost
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/model.User'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
summary: Disable the REST API for the given user.
|
||||
tags:
|
||||
- Users
|
||||
/user/{id}/api/enable:
|
||||
post:
|
||||
operationId: users_handleApiEnablePost
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/model.User'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
summary: Enable the REST API for the given user.
|
||||
tags:
|
||||
- Users
|
||||
/user/{id}/peers:
|
||||
get:
|
||||
operationId: users_handlePeersGet
|
||||
@@ -984,6 +1274,10 @@ paths:
|
||||
items:
|
||||
$ref: '#/definitions/model.Peer'
|
||||
type: array
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
@@ -991,6 +1285,27 @@ paths:
|
||||
summary: Get peers for the given user.
|
||||
tags:
|
||||
- Users
|
||||
/user/{id}/stats:
|
||||
get:
|
||||
operationId: users_handleStatsGet
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/model.PeerStats'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Error'
|
||||
summary: Get peer stats for the given user.
|
||||
tags:
|
||||
- Users
|
||||
/user/all:
|
||||
get:
|
||||
operationId: users_handleAllGet
|
||||
|
1932
internal/app/api/core/assets/doc/v1_swagger.json
Normal file
1932
internal/app/api/core/assets/doc/v1_swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
1358
internal/app/api/core/assets/doc/v1_swagger.yaml
Normal file
1358
internal/app/api/core/assets/doc/v1_swagger.yaml
Normal file
File diff suppressed because it is too large
Load Diff
3917
internal/app/api/core/assets/js/rapidoc-min.js
vendored
3917
internal/app/api/core/assets/js/rapidoc-min.js
vendored
File diff suppressed because one or more lines are too long
@@ -8,10 +8,16 @@
|
||||
<rapi-doc
|
||||
spec-url="{{ $.ApiSpecUrl }}"
|
||||
theme="dark"
|
||||
render-style="focused"
|
||||
allow-server-selection="false"
|
||||
allow-authentication="false"
|
||||
allow-authentication="true"
|
||||
load-fonts="false"
|
||||
schema-style="table"
|
||||
schema-expand-level="1"
|
||||
default-schema-tab="model"
|
||||
fill-request-fields-with-example="true"
|
||||
show-method-in-nav-bar="as-colored-block"
|
||||
show-components="true"
|
||||
allow-spec-url-load="false"
|
||||
allow-spec-file-load="false"
|
||||
allow-spec-file-download="true"
|
||||
|
@@ -88,6 +88,8 @@ func NewServer(cfg *config.Config, endpoints ...ApiEndpointSetupFunc) (*Server,
|
||||
s.server.StaticFS("/doc", http.FS(fsMust(fs.Sub(apiStatics, "assets/doc"))))
|
||||
|
||||
// Setup routes
|
||||
s.server.UseRawPath = true
|
||||
s.server.UnescapePathValues = true
|
||||
s.setupRoutes(endpoints...)
|
||||
s.setupFrontendRoutes()
|
||||
|
||||
|
Reference in New Issue
Block a user