// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag package docs import ( "bytes" "encoding/json" "strings" "text/template" "github.com/swaggo/swag" ) var doc = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { "description": "{{escape .Description}}", "title": "{{.Title}}", "contact": { "name": "WireGuard Portal Project", "url": "https://github.com/h44z/wg-portal" }, "license": { "name": "MIT", "url": "https://github.com/h44z/wg-portal/blob/master/LICENSE.txt" }, "version": "{{.Version}}" }, "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { "/backend/device": { "get": { "security": [ { "ApiBasicAuth": [] } ], "produces": [ "application/json" ], "tags": [ "Interface" ], "summary": "Get the given device", "operationId": "GetDevice", "parameters": [ { "type": "string", "description": "Device Name", "name": "DeviceName", "in": "query", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/wireguard.Device" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "put": { "security": [ { "ApiBasicAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Interface" ], "summary": "Updates the given device based on the given device model (UNIMPLEMENTED)", "operationId": "PutDevice", "parameters": [ { "type": "string", "description": "Device Name", "name": "DeviceName", "in": "query", "required": true }, { "description": "Device Model", "name": "Device", "in": "body", "required": true, "schema": { "$ref": "#/definitions/wireguard.Device" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/wireguard.Device" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "patch": { "security": [ { "ApiBasicAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Interface" ], "summary": "Updates the given device based on the given partial device model (UNIMPLEMENTED)", "operationId": "PatchDevice", "parameters": [ { "type": "string", "description": "Device Name", "name": "DeviceName", "in": "query", "required": true }, { "description": "Device Model", "name": "Device", "in": "body", "required": true, "schema": { "$ref": "#/definitions/wireguard.Device" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/wireguard.Device" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } } }, "/backend/devices": { "get": { "security": [ { "ApiBasicAuth": [] } ], "produces": [ "application/json" ], "tags": [ "Interface" ], "summary": "Get all devices", "operationId": "GetDevices", "responses": { "200": { "description": "OK", "schema": { "type": "array", "items": { "$ref": "#/definitions/wireguard.Device" } } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } } } } }, "/backend/peer": { "get": { "security": [ { "ApiBasicAuth": [] } ], "produces": [ "application/json" ], "tags": [ "Peers" ], "summary": "Retrieves the peer for the given public key", "operationId": "GetPeer", "parameters": [ { "type": "string", "description": "Public Key (Base 64)", "name": "PublicKey", "in": "query", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/wireguard.Peer" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "put": { "security": [ { "ApiBasicAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Peers" ], "summary": "Updates the given peer based on the given peer model", "operationId": "PutPeer", "parameters": [ { "type": "string", "description": "Public Key", "name": "PublicKey", "in": "query", "required": true }, { "description": "Peer Model", "name": "Peer", "in": "body", "required": true, "schema": { "$ref": "#/definitions/wireguard.Peer" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/wireguard.Peer" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "delete": { "security": [ { "ApiBasicAuth": [] } ], "produces": [ "application/json" ], "tags": [ "Peers" ], "summary": "Updates the given peer based on the given partial peer model", "operationId": "DeletePeer", "parameters": [ { "type": "string", "description": "Public Key", "name": "PublicKey", "in": "query", "required": true } ], "responses": { "204": { "description": "No Content" }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "patch": { "security": [ { "ApiBasicAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Peers" ], "summary": "Updates the given peer based on the given partial peer model", "operationId": "PatchPeer", "parameters": [ { "type": "string", "description": "Public Key", "name": "PublicKey", "in": "query", "required": true }, { "description": "Peer Model", "name": "Peer", "in": "body", "required": true, "schema": { "$ref": "#/definitions/wireguard.Peer" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/wireguard.Peer" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } } }, "/backend/peers": { "get": { "security": [ { "ApiBasicAuth": [] } ], "produces": [ "application/json" ], "tags": [ "Peers" ], "summary": "Retrieves all peers for the given interface", "operationId": "GetPeers", "parameters": [ { "type": "string", "description": "Device Name", "name": "DeviceName", "in": "query", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "type": "array", "items": { "$ref": "#/definitions/wireguard.Peer" } } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "post": { "security": [ { "ApiBasicAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Peers" ], "summary": "Creates a new peer based on the given peer model", "operationId": "PostPeer", "parameters": [ { "type": "string", "description": "Device Name", "name": "DeviceName", "in": "query", "required": true }, { "description": "Peer Model", "name": "Peer", "in": "body", "required": true, "schema": { "$ref": "#/definitions/wireguard.Peer" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/wireguard.Peer" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } } }, "/backend/user": { "get": { "security": [ { "ApiBasicAuth": [] } ], "produces": [ "application/json" ], "tags": [ "Users" ], "summary": "Retrieves user based on given Email", "operationId": "GetUser", "parameters": [ { "type": "string", "description": "User Email", "name": "Email", "in": "query", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/users.User" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "put": { "security": [ { "ApiBasicAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Users" ], "summary": "Updates a user based on the given user model", "operationId": "PutUser", "parameters": [ { "type": "string", "description": "User Email", "name": "Email", "in": "query", "required": true }, { "description": "User Model", "name": "User", "in": "body", "required": true, "schema": { "$ref": "#/definitions/users.User" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/users.User" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "delete": { "security": [ { "ApiBasicAuth": [] } ], "produces": [ "application/json" ], "tags": [ "Users" ], "summary": "Deletes the specified user", "operationId": "DeleteUser", "parameters": [ { "type": "string", "description": "User Email", "name": "Email", "in": "query", "required": true } ], "responses": { "204": { "description": "No content" }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "patch": { "security": [ { "ApiBasicAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Users" ], "summary": "Updates a user based on the given partial user model", "operationId": "PatchUser", "parameters": [ { "type": "string", "description": "User Email", "name": "Email", "in": "query", "required": true }, { "description": "User Model", "name": "User", "in": "body", "required": true, "schema": { "$ref": "#/definitions/users.User" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/users.User" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } } }, "/backend/users": { "get": { "security": [ { "ApiBasicAuth": [] } ], "produces": [ "application/json" ], "tags": [ "Users" ], "summary": "Retrieves all users", "operationId": "GetUsers", "responses": { "200": { "description": "OK", "schema": { "type": "array", "items": { "$ref": "#/definitions/users.User" } } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "post": { "security": [ { "ApiBasicAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Users" ], "summary": "Creates a new user based on the given user model", "operationId": "PostUser", "parameters": [ { "description": "User Model", "name": "User", "in": "body", "required": true, "schema": { "$ref": "#/definitions/users.User" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/users.User" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/server.ApiError" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/server.ApiError" } } } } }, "/provisioning/peer": { "get": { "security": [ { "GeneralBasicAuth": [] } ], "produces": [ "text/plain" ], "tags": [ "Provisioning" ], "summary": "Retrieves the peer config for the given public key", "operationId": "GetPeerDeploymentConfig", "parameters": [ { "type": "string", "description": "Public Key (Base 64)", "name": "PublicKey", "in": "query", "required": true } ], "responses": { "200": { "description": "The WireGuard configuration file", "schema": { "type": "string" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } } } } }, "/provisioning/peers": { "get": { "security": [ { "GeneralBasicAuth": [] } ], "produces": [ "application/json" ], "tags": [ "Provisioning" ], "summary": "Retrieves all active peers for the given email address", "operationId": "GetPeerDeploymentInformation", "parameters": [ { "type": "string", "description": "Email Address", "name": "Email", "in": "query", "required": true } ], "responses": { "200": { "description": "All active WireGuard peers", "schema": { "type": "array", "items": { "$ref": "#/definitions/server.PeerDeploymentInformation" } } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } } } }, "post": { "security": [ { "GeneralBasicAuth": [] } ], "consumes": [ "application/json" ], "produces": [ "text/plain" ], "tags": [ "Provisioning" ], "summary": "Creates the requested peer config and returns the config file", "operationId": "PostPeerDeploymentConfig", "parameters": [ { "description": "Provisioning Request Model", "name": "ProvisioningRequest", "in": "body", "required": true, "schema": { "$ref": "#/definitions/server.ProvisioningRequest" } } ], "responses": { "200": { "description": "The WireGuard configuration file", "schema": { "type": "string" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/server.ApiError" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/server.ApiError" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/server.ApiError" } } } } } }, "definitions": { "server.ApiError": { "type": "object", "properties": { "Message": { "type": "string" } } }, "server.PeerDeploymentInformation": { "type": "object", "properties": { "Device": { "type": "string" }, "DeviceIdentifier": { "type": "string" }, "Identifier": { "type": "string" }, "PublicKey": { "type": "string" } } }, "server.ProvisioningRequest": { "type": "object", "required": [ "Email", "Identifier" ], "properties": { "AllowedIPsStr": { "type": "string" }, "DNSStr": { "type": "string" }, "DeviceName": { "description": "DeviceName is optional, if not specified, the configured default device will be used.", "type": "string" }, "Email": { "type": "string" }, "Identifier": { "type": "string" }, "Mtu": { "type": "integer" }, "PersistentKeepalive": { "type": "integer" } } }, "users.User": { "type": "object", "required": [ "Email", "Firstname", "Lastname" ], "properties": { "CreatedAt": { "description": "database internal fields", "type": "string" }, "DeletedAt": { "type": "string" }, "Email": { "description": "required fields", "type": "string" }, "Firstname": { "description": "optional fields", "type": "string" }, "IsAdmin": { "type": "boolean" }, "Lastname": { "type": "string" }, "Password": { "description": "optional, integrated password authentication", "type": "string" }, "Phone": { "type": "string" }, "Source": { "type": "string" }, "UpdatedAt": { "type": "string" } } }, "wireguard.Device": { "type": "object", "required": [ "DeviceName", "IPsStr", "PrivateKey", "PublicKey", "Type" ], "properties": { "CreatedAt": { "type": "string" }, "DNSStr": { "description": "comma separated list of the DNS servers of the client, wg-quick addition", "type": "string" }, "DefaultAllowedIPsStr": { "description": "comma separated list of IPs that are used in the client config file", "type": "string" }, "DefaultEndpoint": { "description": "Settings that are applied to all peer by default", "type": "string" }, "DefaultPersistentKeepalive": { "type": "integer" }, "DeviceName": { "type": "string" }, "DisplayName": { "type": "string" }, "FirewallMark": { "type": "integer" }, "IPsStr": { "description": "comma separated list of the IPs of the client, wg-quick addition", "type": "string" }, "ListenPort": { "type": "integer" }, "Mtu": { "description": "the interface MTU, wg-quick addition", "type": "integer" }, "PostDown": { "description": "post down script, wg-quick addition", "type": "string" }, "PostUp": { "description": "post up script, wg-quick addition", "type": "string" }, "PreDown": { "description": "pre down script, wg-quick addition", "type": "string" }, "PreUp": { "description": "pre up script, wg-quick addition", "type": "string" }, "PrivateKey": { "description": "Core WireGuard Settings (Interface section)", "type": "string" }, "PublicKey": { "description": "Misc. WireGuard Settings", "type": "string" }, "RoutingTable": { "description": "the routing table, wg-quick addition", "type": "string" }, "SaveConfig": { "description": "if set to ` + "`" + `true', the configuration is saved from the current state of the interface upon shutdown, wg-quick addition", "type": "boolean" }, "Type": { "type": "string" }, "UpdatedAt": { "type": "string" } } }, "wireguard.Peer": { "type": "object", "required": [ "DeviceName", "DeviceType", "Email", "Identifier", "PublicKey", "UID" ], "properties": { "AllowedIPsSrvStr": { "description": "a comma separated list of IPs that are used in the server config file", "type": "string" }, "AllowedIPsStr": { "description": "a comma separated list of IPs that are used in the client config file", "type": "string" }, "CreatedAt": { "type": "string" }, "CreatedBy": { "type": "string" }, "DNSStr": { "description": "comma separated list of the DNS servers for the client", "type": "string" }, "DeactivatedAt": { "type": "string" }, "DeviceName": { "type": "string" }, "DeviceType": { "type": "string" }, "Email": { "type": "string" }, "Endpoint": { "type": "string" }, "IPsStr": { "description": "a comma separated list of IPs of the client", "type": "string" }, "Identifier": { "description": "Identifier AND Email make a WireGuard peer unique", "type": "string" }, "IgnoreGlobalSettings": { "type": "boolean" }, "Mtu": { "description": "Global Device Settings (can be ignored, only make sense if device is in server mode)", "type": "integer" }, "PersistentKeepalive": { "type": "integer" }, "PresharedKey": { "type": "string" }, "PrivateKey": { "description": "Misc. WireGuard Settings", "type": "string" }, "PublicKey": { "description": "Core WireGuard Settings", "type": "string" }, "UID": { "description": "uid for html identification", "type": "string" }, "UpdatedAt": { "type": "string" }, "UpdatedBy": { "type": "string" } } } }, "securityDefinitions": { "ApiBasicAuth": { "type": "basic" }, "GeneralBasicAuth": { "type": "basic" } } }` type swaggerInfo struct { Version string Host string BasePath string Schemes []string Title string Description string } // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = swaggerInfo{ Version: "1.0", Host: "", BasePath: "/api/v1", Schemes: []string{}, Title: "WireGuard Portal API", Description: "WireGuard Portal API for managing users and peers.", } type s struct{} func (s *s) ReadDoc() string { sInfo := SwaggerInfo sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1) t, err := template.New("swagger_info").Funcs(template.FuncMap{ "marshal": func(v interface{}) string { a, _ := json.Marshal(v) return string(a) }, "escape": func(v interface{}) string { // escape tabs str := strings.Replace(v.(string), "\t", "\\t", -1) // replace " with \", and if that results in \\", replace that with \\\" str = strings.Replace(str, "\"", "\\\"", -1) return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1) }, }).Parse(doc) if err != nil { return doc } var tpl bytes.Buffer if err := t.Execute(&tpl, sInfo); err != nil { return doc } return tpl.String() } func init() { swag.Register(swag.Name, &s{}) }