The generated tokens are intended to be service-specific, i.e. Plex, Radarr, etc, for generating SSL certificates by tools, such as Certbot or Lego.
You will need to own a domain name configured to use Cloudflare's nameservers.
Once that is setup, you will be able to specify the domain's zone (i.e. example.com
) that you want linked to the API token.
An API token needs to be manually created via the Cloudflare account dashboard to be used by goGenerateCFToken
.
- Select the
Create Additional Tokens
template - Update the
Token name
, as needed - Add the following permission:
Zone
-Zone
-Read
- Zone Resources:
Include
-Specific Zone
-example.com
- Client IP Address Filtering: This limits usage of the token to a specified IP address
- Save the newly-created API token to a safe location
go install github.com/nicholas-fedor/gogeneratecftoken@latest
Prebuilt binaries are also available here
For access to usage instructions:
goGenerateCFToken -h
There are several options for providing the api_token
and zone
to goGenerateCFToken
, as it uses Cobra and Viper to enable configuration functionality.
-
YAML Config File:
Setup a configuration file, as shown in the providedconfig.yaml.template
, in a location, such as the default$HOME/.goGenerateCFToken/config.yaml
.
If using a custom location, then use the--config [path]
flag. -
Environment Variables:
If no config file is found or specified, then the program falls back to environment variables.export CF_API_TOKEN="your-cloudflare-api-token-here" export CF_ZONE="example.com"
-
CLI Flags:
To see the available flags:
goGenerateCFToken generate -h
Example Usage:
goGenearteCFToken generate [service name] -z [example.com] -t [supersecretcftoken]
-
Copy the template to
$HOME/.goGenerateCFToken/config.yaml
:cp ./config.yaml.template $HOME/.goGenerateCFToken/config.yaml
-
Obtain your master Cloudflare API token for creating additional service-specific tokens
-
Save the master token and associated zone to the configuration file
-
Generate a test API token to confirm configuration is successful:
goGenerateCFToken generate test
-
If successful, you should see the following output:
Generating API token: test.example.com yoursuperlongandsecretserviceapitoken
Using GoReleaser to build the release files.
To run a new build, update the tag, as follows:
git tag -a v0.1.0 -m "First release"
git push origin v0.1.0