mirror of
				https://github.com/h44z/wg-portal.git
				synced 2025-11-04 08:06:18 +00:00 
			
		
		
		
	peer expiry feature: update api docs and readme
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							@@ -52,7 +52,7 @@ docker-push:
 | 
				
			|||||||
	docker push $(IMAGE)
 | 
						docker push $(IMAGE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
api-docs:
 | 
					api-docs:
 | 
				
			||||||
	cd internal/server; swag init --propertyStrategy pascalcase --parseDependency --parseInternal --generalInfo api.go
 | 
						cd internal; swag init --propertyStrategy pascalcase --parseInternal --generalInfo server/api.go --output server/docs/
 | 
				
			||||||
	$(GOCMD) fmt internal/server/docs/docs.go
 | 
						$(GOCMD) fmt internal/server/docs/docs.go
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(BUILDDIR)/%-amd64: cmd/%/main.go dep phony
 | 
					$(BUILDDIR)/%-amd64: cmd/%/main.go dep phony
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,6 +31,7 @@ It also supports LDAP (Active Directory or OpenLDAP) as authentication provider.
 | 
				
			|||||||
 * Can be used with existing WireGuard setups
 | 
					 * Can be used with existing WireGuard setups
 | 
				
			||||||
 * Support for multiple WireGuard interfaces
 | 
					 * Support for multiple WireGuard interfaces
 | 
				
			||||||
 * REST API for management and client deployment
 | 
					 * REST API for management and client deployment
 | 
				
			||||||
 | 
					 * Peer Expiry Feature
 | 
				
			||||||
 | 
					
 | 
				
			||||||

 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -109,7 +110,7 @@ For example: `CONFIG_FILE=/home/test/config.yml ./wg-portal-amd64`.
 | 
				
			|||||||
The following configuration options are available:
 | 
					The following configuration options are available:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| environment                | yaml                    | yaml_parent | default_value                                                                                                   | description                                                                                                                                       |
 | 
					| environment                | yaml                    | yaml_parent | default_value                                                                                                   | description                                                                                                                                       |
 | 
				
			||||||
|----------------------------|-------------------------|-------------|-------------------------------------------------|-------------------------------------------------------------------------------------------|
 | 
					|----------------------------|-------------------------|-------------|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
 | 
				
			||||||
| LISTENING_ADDRESS          | listeningAddress        | core        | :8123                                                                                                           | The address on which the web server is listening. Optional IP address and port, e.g.: 127.0.0.1:8080.                                             |
 | 
					| LISTENING_ADDRESS          | listeningAddress        | core        | :8123                                                                                                           | The address on which the web server is listening. Optional IP address and port, e.g.: 127.0.0.1:8080.                                             |
 | 
				
			||||||
| EXTERNAL_URL               | externalUrl             | core        | http://localhost:8123                                                                                           | The external URL where the web server is reachable. This link is used in emails that are created by the WireGuard Portal.                         |
 | 
					| EXTERNAL_URL               | externalUrl             | core        | http://localhost:8123                                                                                           | The external URL where the web server is reachable. This link is used in emails that are created by the WireGuard Portal.                         |
 | 
				
			||||||
| WEBSITE_TITLE              | title                   | core        | WireGuard VPN                                                                                                   | The website title.                                                                                                                                |
 | 
					| WEBSITE_TITLE              | title                   | core        | WireGuard VPN                                                                                                   | The website title.                                                                                                                                |
 | 
				
			||||||
@@ -124,6 +125,7 @@ The following configuration options are available:
 | 
				
			|||||||
| WG_EXPORTER_FRIENDLY_NAMES | wgExporterFriendlyNames | core        | false                                                                                                           | Enable integration with [prometheus_wireguard_exporter friendly name](https://github.com/MindFlavor/prometheus_wireguard_exporter#friendly-tags). |
 | 
					| WG_EXPORTER_FRIENDLY_NAMES | wgExporterFriendlyNames | core        | false                                                                                                           | Enable integration with [prometheus_wireguard_exporter friendly name](https://github.com/MindFlavor/prometheus_wireguard_exporter#friendly-tags). |
 | 
				
			||||||
| LDAP_ENABLED               | ldapEnabled             | core        | false                                                                                                           | Enable or disable the LDAP backend.                                                                                                               |
 | 
					| LDAP_ENABLED               | ldapEnabled             | core        | false                                                                                                           | Enable or disable the LDAP backend.                                                                                                               |
 | 
				
			||||||
| SESSION_SECRET             | sessionSecret           | core        | secret                                                                                                          | Use a custom secret to encrypt session data.                                                                                                      |
 | 
					| SESSION_SECRET             | sessionSecret           | core        | secret                                                                                                          | Use a custom secret to encrypt session data.                                                                                                      |
 | 
				
			||||||
 | 
					| BACKGROUND_TASK_INTERVAL   | backgroundTaskInterval  | core        | 900                                                                                                             | The interval (in seconds) for the background tasks (like peer expiry check).                                                                      |
 | 
				
			||||||
| DATABASE_TYPE              | typ                     | database    | sqlite                                                                                                          | Either mysql or sqlite.                                                                                                                           |
 | 
					| DATABASE_TYPE              | typ                     | database    | sqlite                                                                                                          | Either mysql or sqlite.                                                                                                                           |
 | 
				
			||||||
| DATABASE_HOST              | host                    | database    |                                                                                                                 | The mysql server address.                                                                                                                         |
 | 
					| DATABASE_HOST              | host                    | database    |                                                                                                                 | The mysql server address.                                                                                                                         |
 | 
				
			||||||
| DATABASE_PORT              | port                    | database    |                                                                                                                 | The mysql server port.                                                                                                                            |
 | 
					| DATABASE_PORT              | port                    | database    |                                                                                                                 | The mysql server port.                                                                                                                            |
 | 
				
			||||||
@@ -142,6 +144,7 @@ The following configuration options are available:
 | 
				
			|||||||
| WG_DEFAULT_DEVICE          | defaultDevice           | wg          | wg0                                                                                                             | This device is used for auto-created peers (if CREATE_DEFAULT_PEER is enabled).                                                                   |
 | 
					| WG_DEFAULT_DEVICE          | defaultDevice           | wg          | wg0                                                                                                             | This device is used for auto-created peers (if CREATE_DEFAULT_PEER is enabled).                                                                   |
 | 
				
			||||||
| WG_CONFIG_PATH             | configDirectory         | wg          | /etc/wireguard                                                                                                  | If set, interface configuration updates will be written to this path, filename: <devicename>.conf.                                                |
 | 
					| WG_CONFIG_PATH             | configDirectory         | wg          | /etc/wireguard                                                                                                  | If set, interface configuration updates will be written to this path, filename: <devicename>.conf.                                                |
 | 
				
			||||||
| MANAGE_IPS                 | manageIPAddresses       | wg          | true                                                                                                            | Handle IP address setup of interface, only available on linux.                                                                                    |
 | 
					| MANAGE_IPS                 | manageIPAddresses       | wg          | true                                                                                                            | Handle IP address setup of interface, only available on linux.                                                                                    |
 | 
				
			||||||
 | 
					| USER_MANAGE_PEERS          | userManagePeers         | wg          | false                                                                                                           | Logged in user can create or update peers (partially).                                                                                            |
 | 
				
			||||||
| LDAP_URL                   | url                     | ldap        | ldap://srv-ad01.company.local:389                                                                               | The LDAP server url.                                                                                                                              |
 | 
					| LDAP_URL                   | url                     | ldap        | ldap://srv-ad01.company.local:389                                                                               | The LDAP server url.                                                                                                                              |
 | 
				
			||||||
| LDAP_STARTTLS              | startTLS                | ldap        | true                                                                                                            | Use STARTTLS.                                                                                                                                     |
 | 
					| LDAP_STARTTLS              | startTLS                | ldap        | true                                                                                                            | Use STARTTLS.                                                                                                                                     |
 | 
				
			||||||
| LDAP_CERT_VALIDATION       | certcheck               | ldap        | false                                                                                                           | Validate the LDAP server certificate.                                                                                                             |
 | 
					| LDAP_CERT_VALIDATION       | certcheck               | ldap        | false                                                                                                           | Validate the LDAP server certificate.                                                                                                             |
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,17 +1,10 @@
 | 
				
			|||||||
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
 | 
					// Package docs GENERATED BY SWAG; DO NOT EDIT
 | 
				
			||||||
// This file was generated by swaggo/swag
 | 
					// This file was generated by swaggo/swag
 | 
				
			||||||
package docs
 | 
					package docs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import "github.com/swaggo/swag"
 | 
				
			||||||
	"bytes"
 | 
					 | 
				
			||||||
	"encoding/json"
 | 
					 | 
				
			||||||
	"strings"
 | 
					 | 
				
			||||||
	"text/template"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/swaggo/swag"
 | 
					const docTemplate = `{
 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
var doc = `{
 | 
					 | 
				
			||||||
    "schemes": {{ marshal .Schemes }},
 | 
					    "schemes": {{ marshal .Schemes }},
 | 
				
			||||||
    "swagger": "2.0",
 | 
					    "swagger": "2.0",
 | 
				
			||||||
    "info": {
 | 
					    "info": {
 | 
				
			||||||
@@ -1267,10 +1260,13 @@ var doc = `{
 | 
				
			|||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "Mtu": {
 | 
					                "Mtu": {
 | 
				
			||||||
                    "type": "integer"
 | 
					                    "type": "integer",
 | 
				
			||||||
 | 
					                    "maximum": 1500,
 | 
				
			||||||
 | 
					                    "minimum": 0
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "PersistentKeepalive": {
 | 
					                "PersistentKeepalive": {
 | 
				
			||||||
                    "type": "integer"
 | 
					                    "type": "integer",
 | 
				
			||||||
 | 
					                    "minimum": 0
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
@@ -1344,16 +1340,19 @@ var doc = `{
 | 
				
			|||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "DefaultPersistentKeepalive": {
 | 
					                "DefaultPersistentKeepalive": {
 | 
				
			||||||
                    "type": "integer"
 | 
					                    "type": "integer",
 | 
				
			||||||
 | 
					                    "minimum": 0
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "DeviceName": {
 | 
					                "DeviceName": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "DisplayName": {
 | 
					                "DisplayName": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string",
 | 
				
			||||||
 | 
					                    "maxLength": 200
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "FirewallMark": {
 | 
					                "FirewallMark": {
 | 
				
			||||||
                    "type": "integer"
 | 
					                    "type": "integer",
 | 
				
			||||||
 | 
					                    "minimum": 0
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "IPsStr": {
 | 
					                "IPsStr": {
 | 
				
			||||||
                    "description": "comma separated list of the IPs of the client, wg-quick addition",
 | 
					                    "description": "comma separated list of the IPs of the client, wg-quick addition",
 | 
				
			||||||
@@ -1364,7 +1363,9 @@ var doc = `{
 | 
				
			|||||||
                },
 | 
					                },
 | 
				
			||||||
                "Mtu": {
 | 
					                "Mtu": {
 | 
				
			||||||
                    "description": "the interface MTU, wg-quick addition",
 | 
					                    "description": "the interface MTU, wg-quick addition",
 | 
				
			||||||
                    "type": "integer"
 | 
					                    "type": "integer",
 | 
				
			||||||
 | 
					                    "maximum": 1500,
 | 
				
			||||||
 | 
					                    "minimum": 0
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "PostDown": {
 | 
					                "PostDown": {
 | 
				
			||||||
                    "description": "post down script, wg-quick addition",
 | 
					                    "description": "post down script, wg-quick addition",
 | 
				
			||||||
@@ -1399,7 +1400,11 @@ var doc = `{
 | 
				
			|||||||
                    "type": "boolean"
 | 
					                    "type": "boolean"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "Type": {
 | 
					                "Type": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string",
 | 
				
			||||||
 | 
					                    "enum": [
 | 
				
			||||||
 | 
					                        "client",
 | 
				
			||||||
 | 
					                        "server"
 | 
				
			||||||
 | 
					                    ]
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "UpdatedAt": {
 | 
					                "UpdatedAt": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
@@ -1438,11 +1443,18 @@ var doc = `{
 | 
				
			|||||||
                "DeactivatedAt": {
 | 
					                "DeactivatedAt": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
 | 
					                "DeactivatedReason": {
 | 
				
			||||||
 | 
					                    "type": "string"
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
                "DeviceName": {
 | 
					                "DeviceName": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "DeviceType": {
 | 
					                "DeviceType": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string",
 | 
				
			||||||
 | 
					                    "enum": [
 | 
				
			||||||
 | 
					                        "client",
 | 
				
			||||||
 | 
					                        "server"
 | 
				
			||||||
 | 
					                    ]
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "Email": {
 | 
					                "Email": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
@@ -1450,23 +1462,30 @@ var doc = `{
 | 
				
			|||||||
                "Endpoint": {
 | 
					                "Endpoint": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
 | 
					                "ExpiresAt": {
 | 
				
			||||||
 | 
					                    "type": "string"
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
                "IPsStr": {
 | 
					                "IPsStr": {
 | 
				
			||||||
                    "description": "a comma separated list of IPs of the client",
 | 
					                    "description": "a comma separated list of IPs of the client",
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "Identifier": {
 | 
					                "Identifier": {
 | 
				
			||||||
                    "description": "Identifier AND Email make a WireGuard peer unique",
 | 
					                    "description": "Identifier AND Email make a WireGuard peer unique",
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string",
 | 
				
			||||||
 | 
					                    "maxLength": 64
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "IgnoreGlobalSettings": {
 | 
					                "IgnoreGlobalSettings": {
 | 
				
			||||||
                    "type": "boolean"
 | 
					                    "type": "boolean"
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "Mtu": {
 | 
					                "Mtu": {
 | 
				
			||||||
                    "description": "Global Device Settings (can be ignored, only make sense if device is in server mode)",
 | 
					                    "description": "Global Device Settings (can be ignored, only make sense if device is in server mode)",
 | 
				
			||||||
                    "type": "integer"
 | 
					                    "type": "integer",
 | 
				
			||||||
 | 
					                    "maximum": 1500,
 | 
				
			||||||
 | 
					                    "minimum": 0
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "PersistentKeepalive": {
 | 
					                "PersistentKeepalive": {
 | 
				
			||||||
                    "type": "integer"
 | 
					                    "type": "integer",
 | 
				
			||||||
 | 
					                    "minimum": 0
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                "PresharedKey": {
 | 
					                "PresharedKey": {
 | 
				
			||||||
                    "type": "string"
 | 
					                    "type": "string"
 | 
				
			||||||
@@ -1502,56 +1521,18 @@ var doc = `{
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}`
 | 
					}`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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
 | 
					// SwaggerInfo holds exported Swagger Info so clients can modify it
 | 
				
			||||||
var SwaggerInfo = swaggerInfo{
 | 
					var SwaggerInfo = &swag.Spec{
 | 
				
			||||||
	Version:          "1.0",
 | 
						Version:          "1.0",
 | 
				
			||||||
	Host:             "",
 | 
						Host:             "",
 | 
				
			||||||
	BasePath:         "/api/v1",
 | 
						BasePath:         "/api/v1",
 | 
				
			||||||
	Schemes:          []string{},
 | 
						Schemes:          []string{},
 | 
				
			||||||
	Title:            "WireGuard Portal API",
 | 
						Title:            "WireGuard Portal API",
 | 
				
			||||||
	Description:      "WireGuard Portal API for managing users and peers.",
 | 
						Description:      "WireGuard Portal API for managing users and peers.",
 | 
				
			||||||
}
 | 
						InfoInstanceName: "swagger",
 | 
				
			||||||
 | 
						SwaggerTemplate:  docTemplate,
 | 
				
			||||||
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() {
 | 
					func init() {
 | 
				
			||||||
	swag.Register(swag.Name, &s{})
 | 
						swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user