Moved v3 code from NginxProxyManager/nginx-proxy-manager-3 to NginxProxyManager/nginx-proxy-manager

This commit is contained in:
Jamie Curnow
2022-05-12 08:47:31 +10:00
parent 4db34f5894
commit 2110ecc382
830 changed files with 38168 additions and 36635 deletions

View File

@ -0,0 +1,135 @@
package dnsproviders
import (
"errors"
"npm/internal/util"
)
type providerField struct {
Name string `json:"name"`
Type string `json:"type"`
IsRequired bool `json:"is_required"`
IsSecret bool `json:"is_secret"`
MetaKey string `json:"meta_key"`
EnvKey string `json:"-"` // not exposed in api
}
// Provider is a simple struct
type Provider struct {
AcmeshName string `json:"acmesh_name"`
Schema string `json:"-"`
Fields []providerField `json:"fields"`
}
// GetAcmeEnvVars will map the meta given to the env var required for
// acme.sh to use this dns provider
func (p *Provider) GetAcmeEnvVars(meta interface{}) map[string]string {
res := make(map[string]string)
for _, field := range p.Fields {
if acmeShEnvValue, found := util.FindItemInInterface(field.MetaKey, meta); found {
res[field.EnvKey] = acmeShEnvValue.(string)
}
}
return res
}
// List returns an array of providers
func List() []Provider {
return []Provider{
getDNSAd(),
getDNSAli(),
getDNSAws(),
getDNSCf(),
getDNSCloudns(),
getDNSCx(),
getDNSCyon(),
getDNSDgon(),
getDNSDNSimple(),
getDNSDp(),
getDNSDuckDNS(),
getDNSDyn(),
getDNSDynu(),
getDNSFreeDNS(),
getDNSGandiLiveDNS(),
getDNSGd(),
getDNSHe(),
getDNSInfoblox(),
getDNSIspconfig(),
getDNSLinodeV4(),
getDNSLua(),
getDNSMe(),
getDNSNamecom(),
getDNSOne(),
getDNSPDNS(),
getDNSUnoeuro(),
getDNSVscale(),
getDNSYandex(),
}
}
// GetAll returns all the configured providers
func GetAll() map[string]Provider {
mp := make(map[string]Provider)
items := List()
for _, item := range items {
mp[item.AcmeshName] = item
}
return mp
}
// Get returns a single provider by name
func Get(provider string) (Provider, error) {
all := GetAll()
if item, found := all[provider]; found {
return item, nil
}
return Provider{}, errors.New("provider_not_found")
}
// GetAllSchemas returns a flat array with just the schemas
func GetAllSchemas() []string {
items := List()
mp := make([]string, 0)
for _, item := range items {
mp = append(mp, item.Schema)
}
return mp
}
const commonKeySchema = `
{
"type": "object",
"required": [
"api_key"
],
"additionalProperties": false,
"properties": {
"api_key": {
"type": "string",
"minLength": 1
}
}
}
`
// nolint: gosec
const commonKeySecretSchema = `
{
"type": "object",
"required": [
"api_key",
"secret"
],
"additionalProperties": false,
"properties": {
"api_key": {
"type": "string",
"minLength": 1
},
"secret": {
"type": "string",
"minLength": 1
}
}
}
`

View File

@ -0,0 +1,17 @@
package dnsproviders
func getDNSAd() Provider {
return Provider{
AcmeshName: "dns_ad",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "API Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "AD_API_KEY",
IsRequired: true,
},
},
}
}

View File

@ -0,0 +1,25 @@
package dnsproviders
func getDNSAli() Provider {
return Provider{
AcmeshName: "dns_ali",
Schema: commonKeySecretSchema,
Fields: []providerField{
{
Name: "Key",
Type: "text",
MetaKey: "api_key",
EnvKey: "Ali_Key",
IsRequired: true,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "Ali_Secret",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,56 @@
package dnsproviders
const route53Schema = `
{
"type": "object",
"required": [
"access_key_id",
"access_key"
],
"additionalProperties": false,
"properties": {
"access_key_id": {
"type": "string",
"minLength": 10
},
"access_key": {
"type": "string",
"minLength": 10
},
"slow_rate": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSAws() Provider {
return Provider{
AcmeshName: "dns_aws",
Schema: route53Schema,
Fields: []providerField{
{
Name: "Access Key ID",
Type: "text",
MetaKey: "access_key_id",
EnvKey: "AWS_ACCESS_KEY_ID",
IsRequired: true,
},
{
Name: "Secret Access Key",
Type: "password",
MetaKey: "access_key",
EnvKey: "AWS_SECRET_ACCESS_KEY",
IsRequired: true,
IsSecret: true,
},
{
Name: "Slow Rate",
Type: "number",
MetaKey: "slow_rate",
EnvKey: "AWS_DNS_SLOWRATE",
},
},
}
}

View File

@ -0,0 +1,80 @@
package dnsproviders
const cloudflareSchema = `
{
"type": "object",
"required": [
"api_key",
"email",
"token",
"account_id"
],
"additionalProperties": false,
"properties": {
"api_key": {
"type": "string",
"minLength": 1
},
"email": {
"type": "string",
"minLength": 5
},
"token": {
"type": "string",
"minLength": 5
},
"account_id": {
"type": "string",
"minLength": 1
},
"zone_id": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSCf() Provider {
return Provider{
AcmeshName: "dns_cf",
Schema: cloudflareSchema,
Fields: []providerField{
{
Name: "API Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "CF_Key",
IsRequired: true,
},
{
Name: "Email",
Type: "text",
MetaKey: "email",
EnvKey: "CF_Email",
IsRequired: true,
},
{
Name: "Token",
Type: "text",
MetaKey: "token",
EnvKey: "CF_Token",
IsRequired: true,
IsSecret: true,
},
{
Name: "Account ID",
Type: "text",
MetaKey: "account_id",
EnvKey: "CF_Account_ID",
IsRequired: true,
},
{
Name: "Zone ID",
Type: "string",
MetaKey: "zone_id",
EnvKey: "CF_Zone_ID",
},
},
}
}

View File

@ -0,0 +1,54 @@
package dnsproviders
const clouDNSNetSchema = `
{
"type": "object",
"required": [
"password"
],
"additionalProperties": false,
"properties": {
"auth_id": {
"type": "string",
"minLength": 1
},
"sub_auth_id": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSCloudns() Provider {
return Provider{
AcmeshName: "dns_cloudns",
Schema: clouDNSNetSchema,
Fields: []providerField{
{
Name: "Auth ID",
Type: "text",
MetaKey: "auth_id",
EnvKey: "CLOUDNS_AUTH_ID",
},
{
Name: "Sub Auth ID",
Type: "text",
MetaKey: "sub_auth_id",
EnvKey: "CLOUDNS_SUB_AUTH_ID",
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "CLOUDNS_AUTH_PASSWORD",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,25 @@
package dnsproviders
func getDNSCx() Provider {
return Provider{
AcmeshName: "dns_cx",
Schema: commonKeySecretSchema,
Fields: []providerField{
{
Name: "Key",
Type: "text",
MetaKey: "api_key",
EnvKey: "CX_Key",
IsRequired: true,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "CX_Secret",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,57 @@
package dnsproviders
const cyonChSchema = `
{
"type": "object",
"required": [
"user",
"password"
],
"additionalProperties": false,
"properties": {
"user": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
},
"otp_secret": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSCyon() Provider {
return Provider{
AcmeshName: "dns_cyon",
Schema: cyonChSchema,
Fields: []providerField{
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "CY_Username",
IsRequired: true,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "CY_Password",
IsRequired: true,
IsSecret: true,
},
{
Name: "OTP Secret",
Type: "password",
MetaKey: "otp_secret",
EnvKey: "CY_OTP_Secret",
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,18 @@
package dnsproviders
func getDNSDgon() Provider {
return Provider{
AcmeshName: "dns_dgon",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "API Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "DO_API_KEY",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,18 @@
package dnsproviders
func getDNSDNSimple() Provider {
return Provider{
AcmeshName: "dns_dnsimple",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "OAuth Token",
Type: "text",
MetaKey: "api_key",
EnvKey: "DNSimple_OAUTH_TOKEN",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,46 @@
package dnsproviders
const dnsPodCnSchema = `
{
"type": "object",
"required": [
"id",
"api_key"
],
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"api_key": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSDp() Provider {
return Provider{
AcmeshName: "dns_dp",
Schema: dnsPodCnSchema,
Fields: []providerField{
{
Name: "ID",
Type: "text",
MetaKey: "id",
EnvKey: "DP_Id",
IsRequired: true,
},
{
Name: "Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "DP_Key",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,18 @@
package dnsproviders
func getDNSDuckDNS() Provider {
return Provider{
AcmeshName: "dns_duckdns",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "Token",
Type: "password",
MetaKey: "api_key",
EnvKey: "DuckDNS_Token",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,58 @@
package dnsproviders
const dynSchema = `
{
"type": "object",
"required": [
"customer",
"username",
"password"
],
"additionalProperties": false,
"properties": {
"customer": {
"type": "string",
"minLength": 1
},
"username": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSDyn() Provider {
return Provider{
AcmeshName: "dns_dyn",
Schema: dynSchema,
Fields: []providerField{
{
Name: "Customer",
Type: "text",
MetaKey: "customer",
EnvKey: "DYN_Customer",
IsRequired: true,
},
{
Name: "Username",
Type: "text",
MetaKey: "username",
EnvKey: "DYN_Username",
IsRequired: true,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "DYN_Password",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,25 @@
package dnsproviders
func getDNSDynu() Provider {
return Provider{
AcmeshName: "dns_dynu",
Schema: commonKeySecretSchema,
Fields: []providerField{
{
Name: "Client ID",
Type: "text",
MetaKey: "api_key",
EnvKey: "Dynu_ClientId",
IsRequired: true,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "Dynu_Secret",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,46 @@
package dnsproviders
const freeDNSSchema = `
{
"type": "object",
"required": [
"user",
"password"
],
"additionalProperties": false,
"properties": {
"user": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSFreeDNS() Provider {
return Provider{
AcmeshName: "dns_freedns",
Schema: freeDNSSchema,
Fields: []providerField{
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "FREEDNS_User",
IsRequired: true,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "FREEDNS_Password",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,17 @@
package dnsproviders
func getDNSGandiLiveDNS() Provider {
return Provider{
AcmeshName: "dns_gandi_livedns",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "GANDI_LIVEDNS_KEY",
IsRequired: true,
},
},
}
}

View File

@ -0,0 +1,25 @@
package dnsproviders
func getDNSGd() Provider {
return Provider{
AcmeshName: "dns_gd",
Schema: commonKeySecretSchema,
Fields: []providerField{
{
Name: "Key",
Type: "text",
MetaKey: "api_key",
EnvKey: "GD_Key",
IsRequired: true,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "GD_Secret",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,47 @@
package dnsproviders
// nolint: gosec
const commonUserPassSchema = `
{
"type": "object",
"required": [
"username",
"password"
],
"additionalProperties": false,
"properties": {
"username": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSHe() Provider {
return Provider{
AcmeshName: "dns_he",
Schema: commonUserPassSchema,
Fields: []providerField{
{
Name: "Username",
Type: "text",
MetaKey: "username",
EnvKey: "HE_Username",
IsRequired: true,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "HE_Password",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,46 @@
package dnsproviders
const infobloxSchema = `
{
"type": "object",
"required": [
"credentials",
"server"
],
"additionalProperties": false,
"properties": {
"credentials": {
"type": "string",
"minLength": 1
},
"server": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSInfoblox() Provider {
return Provider{
AcmeshName: "dns_infoblox",
Schema: infobloxSchema,
Fields: []providerField{
{
Name: "Credentials",
Type: "text",
MetaKey: "credentials",
EnvKey: "Infoblox_Creds",
IsRequired: true,
IsSecret: true,
},
{
Name: "Server",
Type: "text",
MetaKey: "server",
EnvKey: "Infoblox_Server",
IsRequired: true,
},
},
}
}

View File

@ -0,0 +1,67 @@
package dnsproviders
const ispConfigSchema = `
{
"type": "object",
"required": [
"user",
"password",
"api_url"
],
"additionalProperties": false,
"properties": {
"user": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
},
"api_url": {
"type": "string",
"minLength": 1
},
"insecure": {
"type": "string"
}
}
}
`
func getDNSIspconfig() Provider {
return Provider{
AcmeshName: "dns_ispconfig",
Schema: ispConfigSchema,
Fields: []providerField{
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "ISPC_User",
IsRequired: true,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "ISPC_Password",
IsRequired: true,
IsSecret: true,
},
{
Name: "API URL",
Type: "text",
MetaKey: "api_url",
EnvKey: "ISPC_Api",
IsRequired: true,
},
{
Name: "Insecure",
Type: "bool",
MetaKey: "insecure",
EnvKey: "ISPC_Api_Insecure",
},
},
}
}

View File

@ -0,0 +1,20 @@
package dnsproviders
// Note: https://github.com/acmesh-official/acme.sh/wiki/dnsapi#14-use-linode-domain-api
// needs 15 minute sleep, not currently implemented
func getDNSLinodeV4() Provider {
return Provider{
AcmeshName: "dns_linode_v4",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "API Key",
Type: "text",
MetaKey: "api_key",
EnvKey: "LINODE_V4_API_KEY",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,46 @@
package dnsproviders
const luaDNSSchema = `
{
"type": "object",
"required": [
"api_key",
"email"
],
"additionalProperties": false,
"properties": {
"api_key": {
"type": "string",
"minLength": 1
},
"email": {
"type": "string",
"minLength": 5
}
}
}
`
func getDNSLua() Provider {
return Provider{
AcmeshName: "dns_lua",
Schema: luaDNSSchema,
Fields: []providerField{
{
Name: "Key",
Type: "text",
MetaKey: "api_key",
EnvKey: "LUA_Key",
IsRequired: true,
IsSecret: true,
},
{
Name: "Email",
Type: "text",
MetaKey: "email",
EnvKey: "LUA_Email",
IsRequired: true,
},
},
}
}

View File

@ -0,0 +1,25 @@
package dnsproviders
func getDNSMe() Provider {
return Provider{
AcmeshName: "dns_me",
Schema: commonKeySecretSchema,
Fields: []providerField{
{
Name: "Key",
Type: "text",
MetaKey: "api_key",
EnvKey: "ME_Key",
IsRequired: true,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "ME_Secret",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,46 @@
package dnsproviders
const nameComSchema = `
{
"type": "object",
"required": [
"username",
"token"
],
"additionalProperties": false,
"properties": {
"username": {
"type": "string",
"minLength": 1
},
"token": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSNamecom() Provider {
return Provider{
AcmeshName: "dns_namecom",
Schema: nameComSchema,
Fields: []providerField{
{
Name: "Username",
Type: "text",
MetaKey: "username",
EnvKey: "Namecom_Username",
IsRequired: true,
},
{
Name: "Token",
Type: "text",
MetaKey: "token",
EnvKey: "Namecom_Token",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,18 @@
package dnsproviders
func getDNSOne() Provider {
return Provider{
AcmeshName: "dns_nsone",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "NS1_Key",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,69 @@
package dnsproviders
const powerDNSSchema = `
{
"type": "object",
"required": [
"url",
"server_id",
"token",
"ttl"
],
"additionalProperties": false,
"properties": {
"url": {
"type": "string",
"minLength": 1
},
"server_id": {
"type": "string",
"minLength": 1
},
"token": {
"type": "string",
"minLength": 1
},
"ttl": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSPDNS() Provider {
return Provider{
AcmeshName: "dns_pdns",
Schema: powerDNSSchema,
Fields: []providerField{
{
Name: "URL",
Type: "text",
MetaKey: "url",
EnvKey: "PDNS_Url",
IsRequired: true,
},
{
Name: "Server ID",
Type: "text",
MetaKey: "server_id",
EnvKey: "PDNS_ServerId",
IsRequired: true,
},
{
Name: "Token",
Type: "text",
MetaKey: "token",
EnvKey: "PDNS_Token",
IsRequired: true,
},
{
Name: "TTL",
Type: "number",
MetaKey: "ttl",
EnvKey: "PDNS_Ttl",
IsRequired: true,
},
},
}
}

View File

@ -0,0 +1,47 @@
package dnsproviders
const unoEuroSchema = `
{
"type": "object",
"required": [
"api_key",
"user"
],
"additionalProperties": false,
"properties": {
"api_key": {
"type": "string",
"minLength": 1
},
"user": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSUnoeuro() Provider {
return Provider{
AcmeshName: "dns_unoeuro",
Schema: unoEuroSchema,
Fields: []providerField{
{
Name: "Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "UNO_Key",
IsRequired: true,
IsSecret: true,
},
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "UNO_User",
IsRequired: true,
IsSecret: true,
},
},
}
}

View File

@ -0,0 +1,17 @@
package dnsproviders
func getDNSVscale() Provider {
return Provider{
AcmeshName: "dns_vscale",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "API Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "VSCALE_API_KEY",
IsRequired: true,
},
},
}
}

View File

@ -0,0 +1,18 @@
package dnsproviders
func getDNSYandex() Provider {
return Provider{
AcmeshName: "dns_yandex",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "Token",
Type: "password",
MetaKey: "api_key",
EnvKey: "PDD_Token",
IsRequired: true,
IsSecret: true,
},
},
}
}