Refactor acme.sh dns providers

- updated chakra and typescript
- added locales for dns provider configs
This commit is contained in:
Jamie Curnow 2023-01-12 16:25:43 +10:00
parent 1d5d3ecd7a
commit 5d3bc0fabd
57 changed files with 2204 additions and 2161 deletions

View File

@ -133,8 +133,7 @@ func DeleteDNSProvider() func(http.ResponseWriter, *http.Request) {
// Route: GET /dns-providers/acmesh
func GetAcmeshProviders() func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
items := dnsproviders.List()
h.ResultResponseJSON(w, r, http.StatusOK, items)
h.ResultResponseJSON(w, r, http.StatusOK, dnsproviders.List())
}
}

View File

@ -5,6 +5,7 @@ import (
"strings"
"npm/internal/dnsproviders"
"npm/internal/logger"
"npm/internal/util"
)
@ -15,7 +16,12 @@ func CreateDNSProvider() string {
allSchemasWrapped := make([]string, 0)
for providerName, provider := range allProviders {
allSchemasWrapped = append(allSchemasWrapped, createDNSProviderType(providerName, provider.Schema))
schema, err := provider.GetJsonSchema()
if err != nil {
logger.Error("ProviderSchemaError", fmt.Errorf("Invalid Provider Schema for %s: %v", provider.Title, err))
} else {
allSchemasWrapped = append(allSchemasWrapped, createDNSProviderType(providerName, schema))
}
}
return fmt.Sprintf(fmtStr, util.ConvertStringSliceToInterface(allSchemasWrapped)...)

View File

@ -1,36 +1,47 @@
package dnsproviders
import (
"encoding/json"
"errors"
"npm/internal/util"
)
// providerField should mimick jsonschema, so that
// the ui can render a field and validate it
// before we do.
// See: https://json-schema.org/draft/2020-12/json-schema-validation.html
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
Title string `json:"title"`
Type string `json:"type"`
AdditionalProperties bool `json:"additionalProperties"`
Minimum int `json:"minimum,omitempty"`
Maximum int `json:"maximum,omitempty"`
MinLength int `json:"minLength,omitempty"`
MaxLength int `json:"maxLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
IsSecret bool `json:"isSecret"` // Not valid jsonschema
}
// Provider is a simple struct
type Provider struct {
AcmeshName string `json:"acmesh_name"`
Schema string `json:"-"`
Fields []providerField `json:"fields"`
Title string `json:"title"`
Type string `json:"type"` // Should always be "object"
AdditionalProperties bool `json:"additionalProperties"`
MinProperties int `json:"minProperties,omitempty"`
Required []string `json:"required,omitempty"`
Properties map[string]providerField `json:"properties"`
}
// 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
// GetJsonSchema encodes this object as JSON string
func (p *Provider) GetJsonSchema() (string, error) {
b, err := json.Marshal(p)
return string(b), err
}
// ConvertToUpdatable will manipulate this object so that it returns
// an updatable json schema
func (p *Provider) ConvertToUpdatable() {
p.MinProperties = 1
p.Required = nil
}
// List returns an array of providers
@ -89,7 +100,7 @@ func GetAll() map[string]Provider {
mp := make(map[string]Provider)
items := List()
for _, item := range items {
mp[item.AcmeshName] = item
mp[item.Title] = item
}
return mp
}
@ -102,51 +113,3 @@ func Get(provider string) (Provider, error) {
}
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

@ -1,68 +1,33 @@
package dnsproviders
const acmeDNSchema = `
{
"type": "object",
"required": [
"api_url",
"user",
"password"
],
"additionalProperties": false,
"properties": {
"api_url": {
"type": "string",
"minLength": 4
},
"subdomain": {
"type": "string",
"minLength": 1
},
"user": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSAcmeDNS() Provider {
return Provider{
AcmeshName: "dns_acmedns",
Schema: acmeDNSchema,
Fields: []providerField{
{
Name: "Base URL",
Type: "text",
MetaKey: "api_url",
EnvKey: "ACMEDNS_BASE_URL",
IsRequired: true,
Title: "dns_acmedns",
Type: "object",
AdditionalProperties: false,
Required: []string{
"ACMEDNS_BASE_URL",
"ACMEDNS_SUBDOMAIN",
"ACMEDNS_USERNAME",
"ACMEDNS_PASSWORD",
},
Properties: map[string]providerField{
"ACMEDNS_BASE_URL": {
Title: "base-url",
Type: "string",
},
{
Name: "Subdomain",
Type: "text",
MetaKey: "subdomain",
EnvKey: "ACMEDNS_SUBDOMAIN",
IsRequired: true,
"ACMEDNS_SUBDOMAIN": {
Title: "subdomain",
Type: "string",
},
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "ACMEDNS_USERNAME",
IsRequired: true,
"ACMEDNS_USERNAME": {
Title: "username",
Type: "string",
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "ACMEDNS_PASSWORD",
IsRequired: true,
IsSecret: true,
"ACMEDNS_PASSWORD": {
Title: "password",
Type: "string",
IsSecret: true,
},
},
}

View File

@ -2,15 +2,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,
Title: "dns_ad",
Type: "object",
AdditionalProperties: false,
Required: []string{
"AD_API_KEY",
},
Properties: map[string]providerField{
"AD_API_KEY": {
Title: "api-key",
Type: "string",
MinLength: 1,
},
},
}

View File

@ -2,23 +2,24 @@ 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,
Title: "dns_ali",
Type: "object",
AdditionalProperties: false,
Required: []string{
"Ali_Key",
"Ali_Secret",
},
Properties: map[string]providerField{
"Ali_Key": {
Title: "api-key",
Type: "string",
MinLength: 1,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "Ali_Secret",
IsRequired: true,
IsSecret: true,
"Ali_Secret": {
Title: "secret",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,57 +1,31 @@
package dnsproviders
const autoDNSSchema = `
{
"type": "object",
"required": [
"user",
"password",
"context"
],
"additionalProperties": false,
"properties": {
"user": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
},
"context": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSAutoDNS() Provider {
return Provider{
AcmeshName: "dns_autodns",
Schema: autoDNSSchema,
Fields: []providerField{
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "AUTODNS_USER",
IsRequired: true,
Title: "dns_autodns",
Type: "object",
AdditionalProperties: false,
Required: []string{
"AUTODNS_USER",
"AUTODNS_PASSWORD",
"AUTODNS_CONTEXT",
},
Properties: map[string]providerField{
"AUTODNS_USER": {
Title: "user",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "AUTODNS_PASSWORD",
IsRequired: true,
IsSecret: true,
"AUTODNS_PASSWORD": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
{
Name: "Context",
Type: "text",
MetaKey: "context",
EnvKey: "AUTODNS_CONTEXT",
IsRequired: true,
"AUTODNS_CONTEXT": {
Title: "context",
Type: "string",
MinLength: 1,
},
},
}

View File

@ -1,55 +1,29 @@
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,
Title: "dns_aws",
Type: "object",
AdditionalProperties: false,
Required: []string{
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
},
Properties: map[string]providerField{
"AWS_ACCESS_KEY_ID": {
Title: "access-key-id",
Type: "string",
MinLength: 10,
},
{
Name: "Secret Access Key",
Type: "password",
MetaKey: "access_key",
EnvKey: "AWS_SECRET_ACCESS_KEY",
IsRequired: true,
IsSecret: true,
"AWS_SECRET_ACCESS_KEY": {
Title: "secret-access-key",
Type: "string",
MinLength: 10,
IsSecret: true,
},
{
Name: "Slow Rate",
Type: "number",
MetaKey: "slow_rate",
EnvKey: "AWS_DNS_SLOWRATE",
"AWS_DNS_SLOWRATE": {
Title: "slow-rate",
Type: "integer",
},
},
}

View File

@ -1,69 +1,37 @@
package dnsproviders
const azureSchema = `
{
"type": "object",
"required": [
"subscription_id",
"tenant_id",
"app_id",
"client_secret"
],
"additionalProperties": false,
"properties": {
"subscription_id": {
"type": "string",
"minLength": 1
},
"tenant_id": {
"type": "string",
"minLength": 1
},
"app_id": {
"type": "string",
"minLength": 1
},
"client_secret": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSAzure() Provider {
return Provider{
AcmeshName: "dns_azure",
Schema: azureSchema,
Fields: []providerField{
{
Name: "Subscription ID",
Type: "text",
MetaKey: "subscription_id",
EnvKey: "AZUREDNS_SUBSCRIPTIONID",
IsRequired: true,
Title: "dns_azure",
Type: "object",
AdditionalProperties: false,
Required: []string{
"AZUREDNS_SUBSCRIPTIONID",
"AZUREDNS_TENANTID",
"AZUREDNS_APPID",
"AZUREDNS_CLIENTSECRET",
},
Properties: map[string]providerField{
"AZUREDNS_SUBSCRIPTIONID": {
Title: "subscription-id",
Type: "string",
MinLength: 1,
},
{
Name: "Tenant ID",
Type: "text",
MetaKey: "tenant_id",
EnvKey: "AZUREDNS_TENANTID",
IsRequired: true,
"AZUREDNS_TENANTID": {
Title: "tenant-id",
Type: "string",
MinLength: 1,
},
{
Name: "APP ID",
Type: "text",
MetaKey: "app_id",
EnvKey: "AZUREDNS_APPID",
IsRequired: true,
"AZUREDNS_APPID": {
Title: "app-id",
Type: "string",
MinLength: 1,
},
{
Name: "Client Secret",
Type: "password",
MetaKey: "client_secret",
EnvKey: "AZUREDNS_CLIENTSECRET",
IsRequired: true,
IsSecret: true,
"AZUREDNS_CLIENTSECRET": {
Title: "client-secret",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,79 +1,42 @@
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,
Title: "dns_cf",
Type: "object",
AdditionalProperties: false,
Required: []string{
"CF_Key",
"CF_Email",
"CF_Token",
"CF_Account_ID",
},
Properties: map[string]providerField{
"CF_Key": {
Title: "api-key",
Type: "string",
MinLength: 1,
},
{
Name: "Email",
Type: "text",
MetaKey: "email",
EnvKey: "CF_Email",
IsRequired: true,
"CF_Email": {
Title: "email",
Type: "string",
MinLength: 5,
},
{
Name: "Token",
Type: "text",
MetaKey: "token",
EnvKey: "CF_Token",
IsRequired: true,
IsSecret: true,
"CF_Token": {
Title: "token",
Type: "string",
MinLength: 5,
IsSecret: true,
},
{
Name: "Account ID",
Type: "text",
MetaKey: "account_id",
EnvKey: "CF_Account_ID",
IsRequired: true,
"CF_Account_ID": {
Title: "account-id",
Type: "string",
MinLength: 1,
},
{
Name: "Zone ID",
Type: "string",
MetaKey: "zone_id",
EnvKey: "CF_Zone_ID",
"CF_Zone_ID": {
Title: "zone-id",
Type: "string",
MinLength: 1,
},
},
}

View File

@ -1,53 +1,31 @@
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",
Title: "dns_cloudns",
Type: "object",
AdditionalProperties: false,
Required: []string{
"CLOUDNS_AUTH_ID",
"CLOUDNS_SUB_AUTH_ID",
"CLOUDNS_AUTH_PASSWORD",
},
Properties: map[string]providerField{
"CLOUDNS_AUTH_ID": {
Title: "auth-id",
Type: "string",
MinLength: 1,
},
{
Name: "Sub Auth ID",
Type: "text",
MetaKey: "sub_auth_id",
EnvKey: "CLOUDNS_SUB_AUTH_ID",
"CLOUDNS_SUB_AUTH_ID": {
Title: "sub-auth-id",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "CLOUDNS_AUTH_PASSWORD",
IsRequired: true,
IsSecret: true,
"CLOUDNS_AUTH_PASSWORD": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,69 +1,37 @@
package dnsproviders
const conohaSchema = `
{
"type": "object",
"required": [
"subscription_id",
"tenant_id",
"app_id",
"client_secret"
],
"additionalProperties": false,
"properties": {
"api_url": {
"type": "string",
"minLength": 4
},
"user": {
"type": "string",
"minLength": 1
},
"pass": {
"type": "string",
"minLength": 1
},
"tenant_id": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSConoha() Provider {
return Provider{
AcmeshName: "dns_conoha",
Schema: conohaSchema,
Fields: []providerField{
{
Name: "API URL",
Type: "text",
MetaKey: "api_url",
EnvKey: "CONOHA_IdentityServiceApi",
IsRequired: true,
Title: "dns_conoha",
Type: "object",
AdditionalProperties: false,
Required: []string{
"CONOHA_IdentityServiceApi",
"CONOHA_Username",
"CONOHA_Password",
"CONOHA_TenantId",
},
Properties: map[string]providerField{
"CONOHA_IdentityServiceApi": {
Title: "api-url",
Type: "string",
MinLength: 4,
},
{
Name: "Username",
Type: "text",
MetaKey: "user",
EnvKey: "CONOHA_Username",
IsRequired: true,
"CONOHA_Username": {
Title: "username",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "CONOHA_Password",
IsRequired: true,
IsSecret: true,
"CONOHA_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
{
Name: "Tenant ID",
Type: "text",
MetaKey: "tenant_id",
EnvKey: "CONOHA_TenantId",
IsRequired: true,
"CONOHA_TenantId": {
Title: "tenant-id",
Type: "string",
MinLength: 1,
},
},
}

View File

@ -2,23 +2,22 @@ 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,
Title: "dns_cx",
Type: "object",
AdditionalProperties: false,
Required: []string{
"CX_Key",
"CX_Secret",
},
Properties: map[string]providerField{
"CX_Key": {
Title: "key",
Type: "string",
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "CX_Secret",
IsRequired: true,
IsSecret: true,
"CX_Secret": {
Title: "secret",
Type: "string",
IsSecret: true,
},
},
}

View File

@ -1,56 +1,32 @@
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,
Title: "dns_cyon",
Type: "object",
AdditionalProperties: false,
Required: []string{
"CY_Username",
"CY_Password",
"CY_OTP_Secret",
},
Properties: map[string]providerField{
"CY_Username": {
Title: "user",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "CY_Password",
IsRequired: true,
IsSecret: true,
"CY_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
{
Name: "OTP Secret",
Type: "password",
MetaKey: "otp_secret",
EnvKey: "CY_OTP_Secret",
IsSecret: true,
"CY_OTP_Secret": {
Title: "otp-secret",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,41 +1,22 @@
package dnsproviders
const daSchema = `
{
"type": "object",
"required": [
"api_url"
],
"additionalProperties": false,
"properties": {
"api_url": {
"type": "string",
"minLength": 4
},
"insecure": {
"type": "boolean"
}
}
}
`
func getDNSDa() Provider {
return Provider{
AcmeshName: "dns_da",
Schema: daSchema,
Fields: []providerField{
{
Name: "API URL",
Type: "text",
MetaKey: "api_url",
EnvKey: "DA_Api",
IsRequired: true,
Title: "dns_da",
Type: "object",
AdditionalProperties: false,
Required: []string{
"DA_Api",
},
Properties: map[string]providerField{
"DA_Api": {
Title: "api-url",
Type: "string",
MinLength: 4,
},
{
Name: "Insecure",
Type: "bool",
MetaKey: "insecure",
EnvKey: "DA_Api_Insecure",
"DA_Api_Insecure": {
Title: "insecure",
Type: "boolean",
},
},
}

View File

@ -2,16 +2,17 @@ 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,
Title: "dns_dgon",
Type: "object",
AdditionalProperties: false,
Required: []string{
"DO_API_KEY",
},
Properties: map[string]providerField{
"DO_API_KEY": {
Title: "api-key",
Type: "string",
IsSecret: true,
},
},
}

View File

@ -2,16 +2,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,
Title: "dns_dnsimple",
Type: "object",
AdditionalProperties: false,
Required: []string{
"DNSimple_OAUTH_TOKEN",
},
Properties: map[string]providerField{
"DNSimple_OAUTH_TOKEN": {
Title: "oauth-token",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,45 +1,25 @@
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,
Title: "dns_dp",
Type: "object",
AdditionalProperties: false,
Required: []string{
"DP_Id",
"DP_Key",
},
Properties: map[string]providerField{
"DP_Id": {
Title: "id",
Type: "string",
MinLength: 1,
},
{
Name: "Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "DP_Key",
IsRequired: true,
IsSecret: true,
"DP_Key": {
Title: "key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,45 +1,25 @@
package dnsproviders
const dnsPodComSchema = `
{
"type": "object",
"required": [
"id",
"api_key"
],
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"api_key": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSDpi() Provider {
return Provider{
AcmeshName: "dns_dpi",
Schema: dnsPodComSchema,
Fields: []providerField{
{
Name: "ID",
Type: "text",
MetaKey: "id",
EnvKey: "DPI_Id",
IsRequired: true,
Title: "dns_dpi",
Type: "object",
AdditionalProperties: false,
Required: []string{
"DPI_Id",
"DPI_Key",
},
Properties: map[string]providerField{
"DPI_Id": {
Title: "id",
Type: "string",
MinLength: 1,
},
{
Name: "Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "DPI_Key",
IsRequired: true,
IsSecret: true,
"DPI_Key": {
Title: "key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,16 +2,18 @@ package dnsproviders
func getDNSDreamhost() Provider {
return Provider{
AcmeshName: "dns_dreamhost",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "API Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "DH_API_KEY",
IsRequired: true,
IsSecret: true,
Title: "dns_dreamhost",
Type: "object",
AdditionalProperties: false,
Required: []string{
"DH_API_KEY",
},
Properties: map[string]providerField{
"DH_API_KEY": {
Title: "api-key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,16 +2,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,
Title: "dns_duckdns",
Type: "object",
AdditionalProperties: false,
Required: []string{
"DuckDNS_Token",
},
Properties: map[string]providerField{
"DuckDNS_Token": {
Title: "token",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,57 +1,31 @@
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,
Title: "dns_dyn",
Type: "object",
AdditionalProperties: false,
Required: []string{
"DYN_Customer",
"DYN_Username",
"DYN_Password",
},
Properties: map[string]providerField{
"DYN_Customer": {
Title: "customer",
Type: "string",
MinLength: 1,
},
{
Name: "Username",
Type: "text",
MetaKey: "username",
EnvKey: "DYN_Username",
IsRequired: true,
"DYN_Username": {
Title: "username",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "DYN_Password",
IsRequired: true,
IsSecret: true,
"DYN_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,23 +2,23 @@ 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,
Title: "dns_dynu",
Type: "object",
AdditionalProperties: false,
Required: []string{
"Dynu_ClientId",
},
Properties: map[string]providerField{
"Dynu_ClientId": {
Title: "client-id",
Type: "string",
MinLength: 1,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "Dynu_Secret",
IsRequired: true,
IsSecret: true,
"Dynu_Secret": {
Title: "secret",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,49 +1,25 @@
package dnsproviders
const euservSchema = `
{
"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 getDNSEuserv() Provider {
return Provider{
AcmeshName: "dns_euserv",
Schema: euservSchema,
Fields: []providerField{
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "EUSERV_Username",
IsRequired: true,
Title: "dns_euserv",
Type: "object",
AdditionalProperties: false,
Required: []string{
"EUSERV_Username",
"EUSERV_Password",
},
Properties: map[string]providerField{
"EUSERV_Username": {
Title: "user",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "EUSERV_Password",
IsRequired: true,
IsSecret: true,
"EUSERV_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,45 +1,25 @@
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,
Title: "dns_freedns",
Type: "object",
AdditionalProperties: false,
Required: []string{
"FREEDNS_User",
"FREEDNS_Password",
},
Properties: map[string]providerField{
"FREEDNS_User": {
Title: "user",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "FREEDNS_Password",
IsRequired: true,
IsSecret: true,
"FREEDNS_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,15 +2,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,
Title: "dns_gandi_livedns",
Type: "object",
AdditionalProperties: false,
Required: []string{
"GANDI_LIVEDNS_KEY",
},
Properties: map[string]providerField{
"GANDI_LIVEDNS_KEY": {
Title: "key",
Type: "string",
MinLength: 1,
},
},
}

View File

@ -2,23 +2,24 @@ 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,
Title: "dns_gd",
Type: "object",
AdditionalProperties: false,
Required: []string{
"GD_Key",
"GD_Secret",
},
Properties: map[string]providerField{
"GD_Key": {
Title: "key",
Type: "string",
MinLength: 1,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "GD_Secret",
IsRequired: true,
IsSecret: true,
"GD_Secret": {
Title: "secret",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,46 +1,25 @@
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,
Title: "dns_he",
Type: "object",
AdditionalProperties: false,
Required: []string{
"HE_Username",
"HE_Password",
},
Properties: map[string]providerField{
"HE_Username": {
Title: "username",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "HE_Password",
IsRequired: true,
IsSecret: true,
"HE_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,45 +1,25 @@
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,
Title: "dns_infoblox",
Type: "object",
AdditionalProperties: false,
Required: []string{
"Infoblox_Creds",
"Infoblox_Server",
},
Properties: map[string]providerField{
"Infoblox_Creds": {
Title: "credentials",
Type: "string",
MinLength: 1,
IsSecret: true,
},
{
Name: "Server",
Type: "text",
MetaKey: "server",
EnvKey: "Infoblox_Server",
IsRequired: true,
"Infoblox_Server": {
Title: "server",
Type: "string",
MinLength: 1,
},
},
}

View File

@ -1,45 +1,25 @@
package dnsproviders
const inwxSchema = `
{
"type": "object",
"required": [
"user",
"password"
],
"additionalProperties": false,
"properties": {
"user": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSInwx() Provider {
return Provider{
AcmeshName: "dns_inwx",
Schema: inwxSchema,
Fields: []providerField{
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "INWX_User",
IsRequired: true,
Title: "dns_inwx",
Type: "object",
AdditionalProperties: false,
Required: []string{
"INWX_User",
"INWX_Password",
},
Properties: map[string]providerField{
"INWX_User": {
Title: "user",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "INWX_Password",
IsRequired: true,
IsSecret: true,
"INWX_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,66 +1,35 @@
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,
Title: "dns_ispconfig",
Type: "object",
AdditionalProperties: false,
Required: []string{
"ISPC_User",
"ISPC_Password",
"ISPC_Api",
},
Properties: map[string]providerField{
"ISPC_User": {
Title: "user",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "ISPC_Password",
IsRequired: true,
IsSecret: true,
"ISPC_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
{
Name: "API URL",
Type: "text",
MetaKey: "api_url",
EnvKey: "ISPC_Api",
IsRequired: true,
"ISPC_Api": {
Title: "api-url",
Type: "string",
MinLength: 1,
},
{
Name: "Insecure",
Type: "bool",
MetaKey: "insecure",
EnvKey: "ISPC_Api_Insecure",
"ISPC_Api_Insecure": {
Title: "insecure",
Type: "boolean",
},
},
}

View File

@ -1,45 +1,25 @@
package dnsproviders
const kinghostSchema = `
{
"type": "object",
"required": [
"user",
"password"
],
"additionalProperties": false,
"properties": {
"user": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSKinghost() Provider {
return Provider{
AcmeshName: "dns_kinghost",
Schema: kinghostSchema,
Fields: []providerField{
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "KINGHOST_Username",
IsRequired: true,
Title: "dns_kinghost",
Type: "object",
AdditionalProperties: false,
Required: []string{
"KINGHOST_Username",
"KINGHOST_Password",
},
Properties: map[string]providerField{
"KINGHOST_Username": {
Title: "user",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "KINGHOST_Password",
IsRequired: true,
IsSecret: true,
"KINGHOST_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -4,16 +4,18 @@ package dnsproviders
// 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,
Title: "dns_linode_v4",
Type: "object",
AdditionalProperties: false,
Required: []string{
"LINODE_V4_API_KEY",
},
Properties: map[string]providerField{
"LINODE_V4_API_KEY": {
Title: "api-key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,57 +1,31 @@
package dnsproviders
const loopiaSchema = `
{
"type": "object",
"required": [
"api_url",
"user",
"password"
],
"additionalProperties": false,
"properties": {
"api_url": {
"type": "string",
"minLength": 4
},
"user": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSLoopia() Provider {
return Provider{
AcmeshName: "dns_loopia",
Schema: loopiaSchema,
Fields: []providerField{
{
Name: "API URL",
Type: "text",
MetaKey: "api_url",
EnvKey: "LOOPIA_Api",
IsRequired: true,
Title: "dns_loopia",
Type: "object",
AdditionalProperties: false,
Required: []string{
"LOOPIA_Api",
"LOOPIA_User",
"LOOPIA_Password",
},
Properties: map[string]providerField{
"LOOPIA_Api": {
Title: "api-url",
Type: "string",
MinLength: 4,
},
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "LOOPIA_User",
IsRequired: true,
"LOOPIA_User": {
Title: "user",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "LOOPIA_Password",
IsRequired: true,
IsSecret: true,
"LOOPIA_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,45 +1,25 @@
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,
Title: "dns_lua",
Type: "object",
AdditionalProperties: false,
Required: []string{
"LUA_Key",
"LUA_Email",
},
Properties: map[string]providerField{
"LUA_Key": {
Title: "key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
{
Name: "Email",
Type: "text",
MetaKey: "email",
EnvKey: "LUA_Email",
IsRequired: true,
"LUA_Email": {
Title: "email",
Type: "string",
MinLength: 5,
},
},
}

View File

@ -2,23 +2,24 @@ 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,
Title: "dns_me",
Type: "object",
AdditionalProperties: false,
Required: []string{
"ME_Key",
"ME_Secret",
},
Properties: map[string]providerField{
"ME_Key": {
Title: "key",
Type: "string",
MinLength: 1,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "ME_Secret",
IsRequired: true,
IsSecret: true,
"ME_Secret": {
Title: "secret",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,45 +1,25 @@
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,
Title: "dns_namecom",
Type: "object",
AdditionalProperties: false,
Required: []string{
"Namecom_Username",
"Namecom_Token",
},
Properties: map[string]providerField{
"Namecom_Username": {
Title: "username",
Type: "string",
MinLength: 1,
},
{
Name: "Token",
Type: "text",
MetaKey: "token",
EnvKey: "Namecom_Token",
IsRequired: true,
IsSecret: true,
"Namecom_Token": {
Title: "token",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,16 +2,17 @@ package dnsproviders
func getDNSNamesilo() Provider {
return Provider{
AcmeshName: "dns_namesilo",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "API Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "Namesilo_Key",
IsRequired: true,
IsSecret: true,
Title: "dns_namesilo",
AdditionalProperties: false,
Required: []string{
"Namesilo_Key",
},
Properties: map[string]providerField{
"Namesilo_Key": {
Title: "api-key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,16 +2,17 @@ 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,
Title: "dns_nsone",
AdditionalProperties: false,
Required: []string{
"NS1_Key",
},
Properties: map[string]providerField{
"NS1_Key": {
Title: "key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,68 +1,35 @@
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,
Title: "dns_pdns",
AdditionalProperties: false,
Required: []string{
"PDNS_Url",
"PDNS_ServerId",
"PDNS_Token",
"PDNS_Ttl",
},
Properties: map[string]providerField{
"PDNS_Url": {
Title: "url",
Type: "string",
MinLength: 1,
},
{
Name: "Server ID",
Type: "text",
MetaKey: "server_id",
EnvKey: "PDNS_ServerId",
IsRequired: true,
"PDNS_ServerId": {
Title: "server-id",
Type: "string",
MinLength: 1,
},
{
Name: "Token",
Type: "text",
MetaKey: "token",
EnvKey: "PDNS_Token",
IsRequired: true,
"PDNS_Token": {
Title: "token",
Type: "string",
MinLength: 1,
},
{
Name: "TTL",
Type: "number",
MetaKey: "ttl",
EnvKey: "PDNS_Ttl",
IsRequired: true,
"PDNS_Ttl": {
Title: "ttl",
Type: "integer",
Minimum: 1,
},
},
}

View File

@ -2,16 +2,17 @@ package dnsproviders
func getDNSSelectel() Provider {
return Provider{
AcmeshName: "dns_selectel",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "API Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "SL_Key",
IsRequired: true,
IsSecret: true,
Title: "dns_selectel",
AdditionalProperties: false,
Required: []string{
"SL_Key",
},
Properties: map[string]providerField{
"SL_Key": {
Title: "api-key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,45 +1,24 @@
package dnsproviders
const servercowSchema = `
{
"type": "object",
"required": [
"user",
"password"
],
"additionalProperties": false,
"properties": {
"user": {
"type": "string",
"minLength": 1
},
"password": {
"type": "string",
"minLength": 1
}
}
}
`
func getDNSServercow() Provider {
return Provider{
AcmeshName: "dns_servercow",
Schema: servercowSchema,
Fields: []providerField{
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "SERVERCOW_API_Username",
IsRequired: true,
Title: "dns_servercow",
AdditionalProperties: false,
Required: []string{
"SERVERCOW_API_Username",
"SERVERCOW_API_Password",
},
Properties: map[string]providerField{
"SERVERCOW_API_Username": {
Title: "user",
Type: "string",
MinLength: 1,
},
{
Name: "Password",
Type: "password",
MetaKey: "password",
EnvKey: "SERVERCOW_API_Password",
IsRequired: true,
IsSecret: true,
"SERVERCOW_API_Password": {
Title: "password",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,23 +2,23 @@ package dnsproviders
func getDNSTele3() Provider {
return Provider{
AcmeshName: "dns_tele3",
Schema: commonKeySecretSchema,
Fields: []providerField{
{
Name: "Key",
Type: "text",
MetaKey: "api_key",
EnvKey: "TELE3_Key",
IsRequired: true,
Title: "dns_tele3",
AdditionalProperties: false,
Required: []string{
"TELE3_Key",
"TELE3_Secret",
},
Properties: map[string]providerField{
"TELE3_Key": {
Title: "key",
Type: "string",
MinLength: 1,
},
{
Name: "Secret",
Type: "password",
MetaKey: "secret",
EnvKey: "TELE3_Secret",
IsRequired: true,
IsSecret: true,
"TELE3_Secret": {
Title: "secret",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -1,46 +1,25 @@
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,
Title: "dns_unoeuro",
AdditionalProperties: false,
Required: []string{
"UNO_Key",
"UNO_User",
},
Properties: map[string]providerField{
"UNO_Key": {
Title: "key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
{
Name: "User",
Type: "text",
MetaKey: "user",
EnvKey: "UNO_User",
IsRequired: true,
IsSecret: true,
"UNO_User": {
Title: "user",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,15 +2,16 @@ 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,
Title: "dns_vscale",
AdditionalProperties: false,
Required: []string{
"VSCALE_API_KEY",
},
Properties: map[string]providerField{
"VSCALE_API_KEY": {
Title: "api-key",
Type: "string",
MinLength: 1,
},
},
}

View File

@ -2,16 +2,17 @@ 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,
Title: "dns_yandex",
AdditionalProperties: false,
Required: []string{
"PDD_Token",
},
Properties: map[string]providerField{
"PDD_Token": {
Title: "token",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,16 +2,17 @@ package dnsproviders
func getDNSDNZilore() Provider {
return Provider{
AcmeshName: "dns_zilore",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "API Key",
Type: "text",
MetaKey: "api_key",
EnvKey: "Zilore_Key",
IsRequired: true,
IsSecret: true,
Title: "dns_zilore",
AdditionalProperties: false,
Required: []string{
"Zilore_Key",
},
Properties: map[string]providerField{
"Zilore_Key": {
Title: "api-key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -2,16 +2,17 @@ package dnsproviders
func getDNSZonomi() Provider {
return Provider{
AcmeshName: "dns_zonomi",
Schema: commonKeySchema,
Fields: []providerField{
{
Name: "API Key",
Type: "password",
MetaKey: "api_key",
EnvKey: "ZM_Key",
IsRequired: true,
IsSecret: true,
Title: "dns_zonomi",
AdditionalProperties: false,
Required: []string{
"ZM_Key",
},
Properties: map[string]providerField{
"ZM_Key": {
Title: "api-key",
Type: "string",
MinLength: 1,
IsSecret: true,
},
},
}

View File

@ -87,15 +87,24 @@ func (m *Model) GetAcmeShEnvVars() ([]string, error) {
return nil, err
}
envs := make([]string, 0)
// Then, using the meta, convert to env vars
envPairs := acmeDNSProvider.GetAcmeEnvVars(m.Meta.Decoded)
logger.Debug("meta: %+v", m.Meta)
logger.Debug("envPairs: %+v", envPairs)
for envName, envValue := range envPairs {
envs = append(envs, fmt.Sprintf(`%s=%v`, envName, envValue))
}
// Convert the meta interface to envs slice for use by acme.sh
envs := getEnvsFromMeta(m.Meta.Decoded)
return envs, nil
}
func getEnvsFromMeta(meta interface{}) []string {
if rec, ok := meta.(map[string]interface{}); ok {
envs := make([]string, 0)
for key, val := range rec {
if f, ok := val.(string); ok {
envs = append(envs, fmt.Sprintf(`%s=%v`, key, f))
} else if f, ok := val.(int); ok {
envs = append(envs, fmt.Sprintf(`%s=%d`, key, f))
}
}
return envs
} else {
logger.Debug("getEnvsFromMeta: meta is not an map of strings")
return nil
}
}

View File

@ -3,9 +3,9 @@
"version": "3.0.0",
"private": true,
"dependencies": {
"@chakra-ui/react": "^2.2.4",
"@emotion/react": "^11",
"@emotion/styled": "^11.9.3",
"@chakra-ui/react": "^2.4.7",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "13.3.0",
"@types/humps": "^2.0.2",
@ -34,7 +34,7 @@
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"formik": "^2.2.9",
"framer-motion": "^6",
"framer-motion": "^8.4.2",
"humps": "^2.0.1",
"jest-date-mock": "1.0.8",
"jest-fetch-mock": "3.0.3",
@ -59,7 +59,7 @@
"react-table": "7.8.0",
"rooks": "5.11.8",
"tmp": "^0.2.1",
"typescript": "^4.7.4"
"typescript": "^4.9.4"
},
"scripts": {
"start": "react-scripts start",

View File

@ -28,21 +28,22 @@ function buildBody(data?: Record<string, any>) {
}
}
async function processResponse(response: Response) {
async function processResponse(response: Response, skipCamelize = false) {
const payload = await response.json();
if (!response.ok) {
throw new Error(payload.error.message);
}
return camelizeKeys(payload) as any;
return (skipCamelize ? payload : camelizeKeys(payload)) as any;
}
interface GetArgs {
url: string;
params?: queryString.StringifiableRecord;
skipCamelize?: boolean;
}
export async function get(
{ url, params }: GetArgs,
{ url, params, skipCamelize }: GetArgs,
abortController?: AbortController,
) {
const apiUrl = buildUrl({ url, params });
@ -50,7 +51,7 @@ export async function get(
const signal = abortController?.signal;
const headers = buildAuthHeader();
const response = await fetch(apiUrl, { method, headers, signal });
return processResponse(response);
return processResponse(response, skipCamelize);
}
interface PostArgs {

View File

@ -7,6 +7,8 @@ export async function getDNSProvidersAcmesh(
const { result } = await api.get(
{
url: "dns-providers/acmesh",
// Important for this endpoint:
skipCamelize: true,
},
abortController,
);

View File

@ -74,18 +74,25 @@ export interface DNSProvider {
meta: any;
}
export interface DNSProvidersAcmeshField {
name: string;
export interface DNSProvidersAcmeshProperty {
title: string;
type: string;
metaKey: string;
isRequired: boolean;
additionalProperties: boolean;
minimum: number;
maximum: number;
minLength: number;
maxLength: number;
pattern: string;
isSecret: boolean;
}
export interface DNSProvidersAcmesh {
name: string;
acmeshName: string;
fields: DNSProvidersAcmeshField[];
title: string;
type: string;
additionalProperties: boolean;
minProperties: number;
required: string[];
properties: any;
}
export interface Host {

View File

@ -137,6 +137,108 @@
"acmesh.dns_zonomi": {
"defaultMessage": "Zonomi"
},
"acmesh-property.access-key-id": {
"defaultMessage": "Access Key ID"
},
"acmesh-property.account-id": {
"defaultMessage": "Account ID"
},
"acmesh-property.api-key": {
"defaultMessage": "API Key"
},
"acmesh-property.api-url": {
"defaultMessage": "API URL"
},
"acmesh-property.app-id": {
"defaultMessage": "APP ID"
},
"acmesh-property.auth-id": {
"defaultMessage": "Auth ID"
},
"acmesh-property.base-url": {
"defaultMessage": "Base URL"
},
"acmesh-property.client-id": {
"defaultMessage": "Client ID"
},
"acmesh-property.client-secret": {
"defaultMessage": "Client Secret"
},
"acmesh-property.credentials": {
"defaultMessage": "Credentials"
},
"acmesh-property.context": {
"defaultMessage": "Context"
},
"acmesh-property.customer": {
"defaultMessage": "Customer"
},
"acmesh-property.email": {
"defaultMessage": "Email"
},
"acmesh-property.id": {
"defaultMessage": "ID"
},
"acmesh-property.insecure": {
"defaultMessage": "Insecure"
},
"acmesh-property.key": {
"defaultMessage": "Key"
},
"acmesh-property.oauth-token": {
"defaultMessage": "OAuth Token"
},
"acmesh-property.otp-secret": {
"defaultMessage": "OTP Secret"
},
"acmesh-property.password": {
"defaultMessage": "Password"
},
"acmesh-property.secret": {
"defaultMessage": "Secret"
},
"acmesh-property.secret-access-key": {
"defaultMessage": "Secret Access Key"
},
"acmesh-property.server": {
"defaultMessage": "Server"
},
"acmesh-property.server-id": {
"defaultMessage": "Server ID"
},
"acmesh-property.slow-rate": {
"defaultMessage": "Slow Rate"
},
"acmesh-property.subdomain": {
"defaultMessage": "Subdomain"
},
"acmesh-property.subscription-id": {
"defaultMessage": "Subscription ID"
},
"acmesh-property.sub-auth-id": {
"defaultMessage": "Sub-Auth ID"
},
"acmesh-property.tenant-id": {
"defaultMessage": "Tenant ID"
},
"acmesh-property.token": {
"defaultMessage": "Token"
},
"acmesh-property.ttl": {
"defaultMessage": "TTL"
},
"acmesh-property.user": {
"defaultMessage": "User"
},
"acmesh-property.username": {
"defaultMessage": "Username"
},
"acmesh-property.url": {
"defaultMessage": "URL"
},
"acmesh-property.zone-id": {
"defaultMessage": "Zone ID"
},
"action.edit": {
"defaultMessage": "Edit"
},

View File

@ -0,0 +1,284 @@
import { useEffect, useState } from "react";
import {
Button,
Checkbox,
FormControl,
FormErrorMessage,
FormLabel,
Input,
Modal,
ModalOverlay,
ModalContent,
ModalHeader,
ModalCloseButton,
ModalBody,
ModalFooter,
Select,
Stack,
useToast,
} from "@chakra-ui/react";
import {
DNSProvider,
DNSProvidersAcmesh,
DNSProvidersAcmeshProperty,
} from "api/npm";
import { PrettyButton } from "components";
import { Formik, Form, Field } from "formik";
import { useSetDNSProvider, useDNSProvidersAcmesh } from "hooks";
import { intl } from "locale";
import { validateString } from "modules/Validations";
interface DNSProviderCreateModalProps {
isOpen: boolean;
onClose: () => void;
}
function DNSProviderCreateModal({
isOpen,
onClose,
}: DNSProviderCreateModalProps) {
const toast = useToast();
const { mutate: setDNSProvider } = useSetDNSProvider();
const {
isLoading: acmeshIsLoading,
// isError: acmeshIsError,
// error: acmeshError,
data: acmeshDataResp,
} = useDNSProvidersAcmesh();
const [acmeshData, setAcmeshData] = useState([] as DNSProvidersAcmesh[]);
const [acmeshItem, setAcmeshItem] = useState("");
useEffect(() => {
setAcmeshData(acmeshDataResp || []);
}, [acmeshDataResp]);
const onSubmit = async (
payload: DNSProvider,
{ setErrors, setSubmitting }: any,
) => {
// TODO: filter out the meta object and only include items that apply to the acmesh provider selected
const showErr = (msg: string) => {
toast({
description: intl.formatMessage({
id: `error.${msg}`,
}),
status: "error",
position: "top",
duration: 3000,
isClosable: true,
});
};
setDNSProvider(payload, {
onError: (err: any) => {
if (err.message === "ca-bundle-does-not-exist") {
setErrors({
caBundle: intl.formatMessage({
id: `error.${err.message}`,
}),
});
} else {
showErr(err.message);
}
},
onSuccess: () => onClose(),
onSettled: () => setSubmitting(false),
});
};
const getAcmeshItem = (name: string): DNSProvidersAcmesh | undefined => {
return acmeshData.find((item) => item.title === name);
};
const fullItem = getAcmeshItem(acmeshItem);
const itemProperties = fullItem?.properties;
const renderInputType = (
field: any,
fieldName: string,
f: DNSProvidersAcmeshProperty,
value: any,
) => {
if (f.type === "bool") {
return (
<Checkbox {...field} size="md" colorScheme="orange" isChecked={value}>
{f.title}
</Checkbox>
);
}
let type = "text";
let props: any = {};
if (fullItem?.required.indexOf(fieldName) !== -1) {
// This is required
props.required = true;
}
if (f.type === "string") {
props.minLength = f.minLength || null;
props.maxLength = f.maxLength || null;
props.pattern = f.pattern || null;
}
if (f.type === "integer") {
type = "number";
props.min = f.minimum || null;
props.max = f.maximum || null;
}
if (f.isSecret) {
type = "password";
}
return (
<Input
{...field}
id={fieldName}
type={type}
defaultValue={value}
{...props}
/>
);
};
return (
<Modal isOpen={isOpen} onClose={onClose} closeOnOverlayClick={false}>
<ModalOverlay />
<ModalContent>
{acmeshIsLoading ? (
"loading"
) : (
<Formik
initialValues={
{
acmeshName: "",
name: "",
dnsSleep: 0,
meta: {},
} as DNSProvider
}
onSubmit={onSubmit}>
{({ isSubmitting, handleChange, values, setValues }) => (
<Form>
<ModalHeader>
{intl.formatMessage({ id: "dns-provider.create" })}
</ModalHeader>
<ModalCloseButton />
<ModalBody>
<Stack spacing={4}>
<Field name="name" validate={validateString(1, 100)}>
{({ field, form }: any) => (
<FormControl
isRequired
isInvalid={form.errors.name && form.touched.name}>
<FormLabel htmlFor="name">
{intl.formatMessage({
id: "dns-provider.name",
})}
</FormLabel>
<Input
{...field}
id="name"
placeholder={intl.formatMessage({
id: "dns-provider.name",
})}
/>
<FormErrorMessage>
{form.errors.name}
</FormErrorMessage>
</FormControl>
)}
</Field>
<Field name="acmeshName">
{({ field, form }: any) => (
<FormControl
isRequired
isInvalid={
form.errors.acmeshName && form.touched.acmeshName
}>
<FormLabel htmlFor="acmeshName">
{intl.formatMessage({
id: "dns-provider.acmesh-name",
})}
</FormLabel>
<Select
{...field}
id="acmeshName"
onChange={(e: any) => {
handleChange(e);
setAcmeshItem(e.target.value);
}}>
<option value="" />
{acmeshData.map((item: DNSProvidersAcmesh) => {
return (
<option key={item.title} value={item.title}>
{intl.formatMessage({
id: `acmesh.${item.title}`,
})}
</option>
);
})}
</Select>
<FormErrorMessage>
{form.errors.acmeshName}
</FormErrorMessage>
</FormControl>
)}
</Field>
{acmeshItem !== "" ? <hr /> : null}
{itemProperties
? Object.keys(itemProperties).map((fieldName, _) => {
const f = itemProperties[fieldName];
const name = `meta[${fieldName}]`;
return (
<Field
name={fieldName}
type={
f.type === "boolean" ? "checkbox" : undefined
}>
{({ field, form }: any) => (
<FormControl
isRequired={f.isRequired}
isInvalid={
form.errors[name] && form.touched[name]
}>
{f.type !== "bool" ? (
<FormLabel htmlFor={name}>
{f.title}
{/* todo: locale for this*/}
</FormLabel>
) : null}
{renderInputType(
field,
fieldName,
f,
values.meta[f.title],
)}
<FormErrorMessage>
{form.errors[name]}
</FormErrorMessage>
</FormControl>
)}
</Field>
);
})
: null}
</Stack>
</ModalBody>
<ModalFooter>
<PrettyButton mr={3} isLoading={isSubmitting}>
{intl.formatMessage({ id: "form.save" })}
</PrettyButton>
<Button onClick={onClose} isLoading={isSubmitting}>
{intl.formatMessage({ id: "form.cancel" })}
</Button>
</ModalFooter>
</Form>
)}
</Formik>
)}
</ModalContent>
</Modal>
);
}
export { DNSProviderCreateModal };

View File

@ -21,7 +21,7 @@ import {
import {
DNSProvider,
DNSProvidersAcmesh,
DNSProvidersAcmeshField,
DNSProvidersAcmeshProperty,
} from "api/npm";
import { PrettyButton } from "components";
import { Formik, Form, Field } from "formik";
@ -53,11 +53,17 @@ function DNSProviderCreateModal({
setAcmeshData(acmeshDataResp || []);
}, [acmeshDataResp]);
const onModalClose = () => {
setAcmeshItem("");
onClose();
};
const onSubmit = async (
payload: DNSProvider,
{ setErrors, setSubmitting }: any,
) => {
// TODO: filter out the meta object and only include items that apply to the acmesh provider selected
console.log("PAYLOAD:", payload);
const showErr = (msg: string) => {
toast({
@ -83,35 +89,63 @@ function DNSProviderCreateModal({
showErr(err.message);
}
},
onSuccess: () => onClose(),
onSuccess: () => onModalClose(),
onSettled: () => setSubmitting(false),
});
};
const getAcmeshItem = (name: string): DNSProvidersAcmesh | undefined => {
return acmeshData.find((item) => item.acmeshName === name);
return acmeshData.find((item) => item.title === name);
};
const fullItem = getAcmeshItem(acmeshItem);
const itemProperties = fullItem?.properties;
const renderInputType = (
field: any,
f: DNSProvidersAcmeshField,
fieldName: string,
f: DNSProvidersAcmeshProperty,
value: any,
) => {
if (f.type === "bool") {
if (["bool", "boolean"].indexOf(f.type) !== -1) {
return (
<Checkbox {...field} size="md" colorScheme="orange" isChecked={value}>
{f.name}
<Checkbox size="md" colorScheme="orange" isChecked={value} {...field}>
{f.title}
</Checkbox>
);
}
let type = "text";
let props: any = {};
if (f.type === "string") {
props.minLength = f.minLength || null;
props.maxLength = f.maxLength || null;
props.pattern = f.pattern || null;
}
if (f.type === "integer") {
type = "number";
props.min = f.minimum || null;
props.max = f.maximum || null;
}
if (f.isSecret) {
type = "password";
}
return (
<Input {...field} id={f.metaKey} type={f.type} defaultValue={value} />
<Input
{...field}
id={fieldName}
type={type}
defaultValue={value}
placeholder={fieldName}
{...props}
/>
);
};
return (
<Modal isOpen={isOpen} onClose={onClose} closeOnOverlayClick={false}>
<Modal isOpen={isOpen} onClose={onModalClose} closeOnOverlayClick={false}>
<ModalOverlay />
<ModalContent>
{acmeshIsLoading ? (
@ -135,29 +169,6 @@ function DNSProviderCreateModal({
<ModalCloseButton />
<ModalBody>
<Stack spacing={4}>
<Field name="name" validate={validateString(1, 100)}>
{({ field, form }: any) => (
<FormControl
isRequired
isInvalid={form.errors.name && form.touched.name}>
<FormLabel htmlFor="name">
{intl.formatMessage({
id: "dns-provider.name",
})}
</FormLabel>
<Input
{...field}
id="name"
placeholder={intl.formatMessage({
id: "dns-provider.name",
})}
/>
<FormErrorMessage>
{form.errors.name}
</FormErrorMessage>
</FormControl>
)}
</Field>
<Field name="acmeshName">
{({ field, form }: any) => (
<FormControl
@ -180,11 +191,9 @@ function DNSProviderCreateModal({
<option value="" />
{acmeshData.map((item: DNSProvidersAcmesh) => {
return (
<option
key={item.acmeshName}
value={item.acmeshName}>
<option key={item.title} value={item.title}>
{intl.formatMessage({
id: `acmesh.${item.acmeshName}`,
id: `acmesh.${item.title}`,
})}
</option>
);
@ -196,42 +205,84 @@ function DNSProviderCreateModal({
</FormControl>
)}
</Field>
{acmeshItem !== "" ? <hr /> : null}
{getAcmeshItem(acmeshItem)?.fields.map((f) => {
const name = `meta[${f.metaKey}]`;
return (
<Field
name={name}
type={f.type === "bool" ? "checkbox" : undefined}>
{acmeshItem !== "" ? (
<>
<Field name="name" validate={validateString(1, 100)}>
{({ field, form }: any) => (
<FormControl
isRequired={f.isRequired}
isInvalid={
form.errors[name] && form.touched[name]
}>
{f.type !== "bool" ? (
<FormLabel htmlFor={name}>{f.name}</FormLabel>
) : null}
{renderInputType(
field,
f,
values.meta[f.metaKey],
)}
isRequired
isInvalid={form.errors.name && form.touched.name}>
<FormLabel htmlFor="name">
{intl.formatMessage({
id: "dns-provider.name",
})}
</FormLabel>
<Input
{...field}
id="name"
placeholder={intl.formatMessage({
id: "dns-provider.name",
})}
/>
<FormErrorMessage>
{form.errors[name]}
{form.errors.name}
</FormErrorMessage>
</FormControl>
)}
</Field>
);
})}
{itemProperties
? Object.keys(itemProperties).map((fieldName, _) => {
const f = itemProperties[fieldName];
const name = `meta[${fieldName}]`;
return (
<Field
name={`meta[${fieldName}]`}
type={
f.type === "boolean"
? "checkbox"
: undefined
}>
{({ field, form }: any) => (
<FormControl
isRequired={
fullItem?.required.indexOf(
fieldName,
) !== -1
}
isInvalid={
form.errors[name] && form.touched[name]
}>
{f.type !== "bool" ? (
<FormLabel htmlFor={name}>
{intl.formatMessage({
id: `acmesh-property.${f.title}`,
})}
</FormLabel>
) : null}
{renderInputType(
field,
fieldName,
f,
values.meta[f.title],
)}
<FormErrorMessage>
{form.errors[name]}
</FormErrorMessage>
</FormControl>
)}
</Field>
);
})
: null}
</>
) : null}
</Stack>
</ModalBody>
<ModalFooter>
<PrettyButton mr={3} isLoading={isSubmitting}>
{intl.formatMessage({ id: "form.save" })}
</PrettyButton>
<Button onClick={onClose} isLoading={isSubmitting}>
<Button onClick={onModalClose} isLoading={isSubmitting}>
{intl.formatMessage({ id: "form.cancel" })}
</Button>
</ModalFooter>

File diff suppressed because it is too large Load Diff