Configuration

By default, this project uses a JSON configuration file. The project will look at three places in this order:

  1. The raw contents of the CONFIG_JSON environment variable.
  2. If the CONFIG_PATH environment variable is populated it will attempt to read a file at that path.
  3. If neither of the above are populated it will attempt to read a file at ./config.json.

This configuration file contains secrets. Do not commit the file to your version control system or build it into Docker images.


Configuration string types

Failing to start the server due to a configuration error may be the result of formatting a JSON string value incorrectly. Here is a list of the string types that are used in the configuration file and links on how they are parsed:

TypeDescriptionExample attributeExample value
Go Time DurationA string representing a time duration.requestTimeout1h5m2s
Go URLA Uniform Resource Locator (URL).baseURLhttps://localhost:8080/
UUID128 bits encoded as a specially formatted string.apiKey840b785c-d844-41b6-9fd0-18bef93231a6

Default configuration

The structure of the configuration file is shown below, defaults are populated. However, some required attributes are not populated by default.

This configuration file is for a server that uses every email provider the project supports natively. If you only want to use one email provider, you can locate the appropriate Docker image or Go main package for the provider you want and omit the configuration for unused providers.

{
  "ses": {
    "awsRegion": "",
    "accessKeyID": "",
    "fromEmail": "",
    "secretKey": ""
  },
  "sendgrid": {
    "apiKey": "",
    "fromEmail": ""
  },
  "rateLimiter": {
    "burst": 5,
    "refillRate": 0
  },
  "server": {
    "adminCreateParams": [
      {
        "apiKey": "",
        "aud": "",
        "uuid": "",
        "serviceAccountCreateParams": {
          "serviceLogo": "",
          "serviceName": "",
          "serviceURL": ""
        }
      }
    ],
    "baseURL": "",
    "iss": "",
    "jwks": {
      "ignoreDefault": false
    },
    "logJSON": false,
    "logLevel": "info",
    "preventRobots": {
      "method": "",
      "recaptchav3": {
        "apkPackageName": [],
        "action": [],
        "hostname": [],
        "minScore": 0.5,
        "secretKey": "",
        "templateData": {
          "buttonBypass": false,
          "buttonText": "",
          "css": "",
          "code": "",
          "htmlTitle": "",
          "instruction": "",
          "siteKey": "",
          "title": ""
        }
      }
    },
    "relativeRedirectURL": "redirect",
    "requestTimeout": "5s",
    "requestMaxBodyBytes": 1048576,
    "secretQueryKey": "secret",
    "shutdownTimeout": "1s",
    "validation": {
      "linkLifespanDefault": "1h",
      "maxLinkLifespan": "720h",
      "maxJWTClaimsBytes": 4096,
      "jwtLifespanDefault": "5m",
      "maxJWTLifespan": "720h",
      "serviceNameMinUTF8": 5,
      "serviceNameMaxUTF8": 256,
      "urlMaxLength": 2048
    }
  },
  "storage": {
    "aes256KeyBase64": "",
    "autoMigrate": false,
    "dsn": "",
    "health": "5s",
    "initialTimeout": "10s",
    "maxIdle": "4m",
    "minConns": 2,
    "plaintextClaims": false,
    "plaintextJWK": false
  }
}

SES attributes

{
  "awsRegion": "",
  "accessKeyID": "",
  "fromEmail": "",
  "secretKey": ""
}
AttributeDescriptionDefaultRequired
awsRegionThe AWS region.Yes
accessKeyIDThe AWS access key ID.Yes
fromEmailThe email address. Then name can optionally be included. See RFC 5322. Examples: john@example.com, John Doe <john@example.com>Yes
secretKeyThe AWS secret key.Yes

SendGrid attributes

{
  "apiKey": "",
  "fromEmail": ""
}
AttributeDescriptionDefaultRequired
apiKeyThe SendGrid API key.Yes
fromEmailThe email address. Then name can optionally be included. See RFC 5322. Examples: john@example.com, John Doe <john@example.com>Yes

Rate limit attributes

{
  "burst": 5,
  "refillRate": 0
}
AttributeDescriptionDefaultRequired
burstThe token bucket burst setting. Each service has a separate token bucket rate limiter.5No
refillRateThe token bucket refill rate per second. Each service has a separate token bucket rate limiter. Use a value of 0 to disable rate limiting.0No

Server attributes

{
  "adminCreateParams": [
    {
      "apiKey": "",
      "aud": "",
      "uuid": "",
      "serviceAccountCreateParams": {
        "serviceLogo": "",
        "serviceName": "",
        "serviceURL": ""
      }
    }
  ],
  "baseURL": "",
  "iss": "",
  "jwks": {
    "ignoreDefault": false
  },
  "logJSON": false,
  "logLevel": "info",
  "preventRobots": {
    "method": "",
    "recaptchav3": {
      "apkPackageName": [],
      "action": [],
      "hostname": [],
      "minScore": 0.5,
      "secretKey": "",
      "templateData": {
        "buttonBypass": false,
        "buttonText": "",
        "css": "",
        "code": "",
        "htmlTitle": "",
        "instruction": "",
        "siteKey": "",
        "title": ""
      }
    }
  },
  "relativeURLRedirect": "redirect",
  "requestTimeout": "5s",
  "requestMaxBodyBytes": 1048576,
  "secretQueryKey": "secret",
  "shutdownTimeout": "1s",
  "validation": {
    "linkLifespanDefault": "1h",
    "maxLinkLifespan": "720h",
    "maxJWTClaimsBytes": 4096,
    "jwtLifespanDefault": "5m",
    "maxJWTLifespan": "720h",
    "serviceNameMinUTF8": "5",
    "serviceNameMaxUTF8": "256",
    "urlMaxLength": 2048
  }
}
AttributeDescriptionDefaultRequired
adminCreateParamsParameters for creating admin users to create on startup.No
baseURLThe base URL of the server the internet. Used to create URLs for API paths and magic link redirects. If you need a base path, be sure to include a trailing slash like: /api/v2/.Yes
issThe iss value to use when signing JWTs.Yes
jwksInformation about what JWK Set should exist.No
logJSONFormat logs using JSON.falseNo
logLevelThe level of log messages to print. debug, info, warn, or errorinfoNo
preventRobotsInformation about how to prevent robots from following magic links.No
relativeURLRedirectThe relative URL for magic link redirection.redirectNo
requestTimeoutThe timeout for incoming requests.5sNo
requestMaxBodyBytesThe maximum number of bytes to read from a request body.1048576No
secretQueryKeyThe URL query parameter that contains the secret for the magic link.secretNo
shutdownTimeoutThe amount of time to wait for connections to close before completely shutting down the server.1sNo
validationThe validation configuration.No

Admin config attributes

{
  "apiKey": "",
  "aud": "",
  "uuid": "",
  "serviceAccountCreateParams": {
    "serviceLogo": "",
    "serviceName": "",
    "serviceURL": ""
  }
}
AttributeDescriptionDefaultRequired
apiKeyThe API key to use for the admin user. Must be a UUIDNo
audThe aud value to use when signing JWTs. Must be a UUID.No
uuidThe UUID of the admin user.No
serviceAccountCreateParamsThe parameters for creating an admin service account.No

Service account create arguments attributes

{
  "serviceLogo": "",
  "serviceName": "",
  "serviceURL": ""
}
AttributeDescriptionDefaultRequired
serviceLogoA URL to the logo to use for the service account in magic link emails. Fits into <img src="X">. This logo should be visible against a light or dark background as the email template adapts to the system theme.No
serviceNameThe name to use in email metadata like the HTML title. "You've been sent a magic link from X".Yes
serviceURLThe URL to redirect to when the logo is clicked in an email.No

JWK Set attributes

{
  "ignoreDefault": false
}
AttributeDescriptionDefaultRequired
ignoreDefaultWhether to ignore the default JWK Set configuration. A value of true this will skip a check/creation of keys on startup.falseNo

Prevent Robots attributes

{
  "method": "",
  "recaptchav3": {
    "apkPackageName": [],
    "action": [],
    "hostname": [],
    "minScore": 0.5,
    "secretKey": "",
    "templateData": {
      "buttonBypass": false,
      "buttonText": "",
      "css": "",
      "code": "",
      "htmlTitle": "",
      "instruction": "",
      "siteKey": "",
      "title": ""
    }
  }
}
AttributeDescriptionDefaultRequired
methodThe method to use to prevent robots. Valid strings: ["", "recaptchav3"]No
recaptchav3The reCAPTCHA v3 configuration.No

reCAPTCHA v3 attributes

{
  "apkPackageName": [],
  "action": [],
  "hostname": [],
  "minScore": 0.5,
  "secretKey": "",
  "templateData": {
    "buttonBypass": false,
    "buttonText": "",
    "css": "",
    "code": "",
    "htmlTitle": "",
    "instruction": "",
    "siteKey": "",
    "title": ""
  }
}
AttributeDescriptionDefaultRequired
apkPackageNameA set of acceptable APK package names for reCAPTCHA v3 request verification.No
actionA set of acceptable actions for reCAPTCHA v3 request verification.No
hostnameA set of acceptable hostnames for reCAPTCHA v3 request verification.No
minScoreThe minimum score needed for reCAPTCHA v3 request verification.0.5No
secretKeyThe reCAPTCHA v3 secret key. Find this in the reCAPTCHA console.Yes
templateDataThe HTML template data to use for web page where reCAPTCHA v3 verification takes place.Yes

reCAPTCHA v3 HTML template data attributes

{
  "buttonBypass": false,
  "buttonText": "",
  "css": "",
  "code": "",
  "htmlTitle": "",
  "instruction": "",
  "siteKey": "",
  "title": ""
}
AttributeDescriptionDefaultRequired
buttonBypassRecommended to be set to true. Whether to show a button to bypass the reCAPTCHA v3 verification. This allows a user to manually click for a redirect in the event their browser won't run JavaScript or reCAPTCHA v3 failure. There is a small, unlikely chance a security product peforming link scanning would click the button.falseNo
buttonTextThe text to use for the bypass button.ContinueNo
cssThe CSS to use for the reCAPTCHA v3 verification page.Generated using Tailwind CSSNo
codeA smaller, shorter title to display above the main title.BROWSER CHECKNo
htmlTitleThe HTML title to use for the reCAPTCHA v3 verification page. Not rendered on the web page itself, but visible in the browser tab.Magic Link - Browser CheckNo
instructionSmaller text below the title displayed to the user.This page helps prevent robots from using magic links.No
siteKeyThe reCAPTCHA v3 site key. Find this in your reCAPTCHA v3 admin console.Yes
titleThe title is the largest text rendered on the page visible to the user.Checking your browser...No

Validation attributes

{
  "linkLifespanDefault": "1h",
  "maxLinkLifespan": "720h",
  "maxJWTClaimsBytes": 4096,
  "jwtLifespanDefault": "5m",
  "maxJWTLifespan": "720h",
  "serviceNameMinUTF8": "5",
  "serviceNameMaxUTF8": "256",
  "urlMaxLength": 2048
}
AttributeDescriptionDefaultRequired
linkLifespanDefaultThe default lifespan of a magic link.1hNo
maxLinkLifespanThe maximum lifespan of a magic link.720hNo
maxJWTClaimsBytesThe maximum number of bytes for JWT claims.4096No
jwtLifespanDefaultThe default lifespan of a JWT.5mNo
maxJWTLifespanThe maximum lifespan of a JWT.720hNo
serviceNameMinUTF8The minimum number of UTF-8 characters for a service name.5No
serviceNameMaxUTF8The maximum number of UTF-8 characters for a service name.256No
urlMaxLengthThe maximum length of a URL.2048No

Storage attributes

{
  "aes256KeyBase64": "",
  "autoMigrate": false,
  "dsn": "",
  "health": "5s",
  "initialTimeout": "10s",
  "maxIdle": "4m",
  "minConns": 2,
  "plaintextClaims": false,
  "plaintextJWK": false
}
AttributeDescriptionDefaultRequired
aes256KeyBase64The base64 encoded 256 bit AES-GCM key to use for encrypting data like JWT claims and JWK Set assets.Yes, unless all plaintext attributes are set to true
autoMigrateWhether or not to perform database migrations automatically. (Recommended: true)falseNo, but strongly recommended
dsnThe DSN to use for connecting to the database.Yes
healthThe interval to check the database connection.5sNo
initialTimeoutThe timeout for the initial database connection.10sNo
maxIdleThe maximum amount of time to keep a database connection idle.4mNo
minConnsThe minimum number of database connections to keep open.2No
plaintextClaimsWhether to store JWT claims in plaintext.falseNo
plaintextJWKWhether to store the JWK Set assets in plaintext.falseNo