acme-dns-01-cloudflare
Advanced tools
Comparing version
@@ -9,2 +9,9 @@ # Changelog | ||
## [1.1.0] - 2020-01 | ||
- Bump `cloudflare` to 2.7.0 | ||
- Enable using an API token for Cloudflare instead of email + API Key | ||
- Bump `acme-dns-01-test` to 3.3.2 | ||
- `init` function returns a Promise | ||
- Add Greenlock v3 example to docs | ||
## [1.0.2] - 2019-07-15 | ||
@@ -11,0 +18,0 @@ - Bump dependencies |
@@ -15,3 +15,4 @@ 'use strict'; | ||
email: options.email, | ||
key: options.key | ||
key: options.key, | ||
token: options.token | ||
}); | ||
@@ -24,4 +25,4 @@ } | ||
init(){ | ||
return null; | ||
async init(){ | ||
return Promise.resolve(null); | ||
} | ||
@@ -28,0 +29,0 @@ |
{ | ||
"name": "acme-dns-01-cloudflare", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Cloudflare DNS for Let's Encrypt / ACME dns-01 challenges with Greenlock.js and ACME.js", | ||
@@ -32,10 +32,10 @@ "keywords": [ | ||
"dependencies": { | ||
"cloudflare": "^2.4.1" | ||
"cloudflare": "^2.7.0" | ||
}, | ||
"devDependencies": { | ||
"acme-dns-01-test": "3.3.1", | ||
"eslint": "^6.0.1", | ||
"eslint-config-nodecraft": "^1.7.1", | ||
"eslint-plugin-json": "^1.4.0", | ||
"eslint-plugin-node": "^9.1.0" | ||
"acme-dns-01-test": "3.3.2", | ||
"eslint": "^6.8.0", | ||
"eslint-config-nodecraft": "^1.8.0", | ||
"eslint-plugin-json": "^2.0.1", | ||
"eslint-plugin-node": "^11.0.0" | ||
}, | ||
@@ -42,0 +42,0 @@ "engines": { |
@@ -13,6 +13,23 @@ acme-dns-01-cloudflare | ||
## Cloudflare API Token | ||
Whilst you can use a global API key and email to generate certs, we heavily encourage that you use a new Cloudflare API token for increased security. | ||
From your [Cloudflare Profile page](https://dash.cloudflare.com/profile), create an API Token with the following permissions: | ||
- Account -> Account Settings: Read | ||
- Zone -> Zone: Read | ||
- Zone -> DNS: Edit | ||
For the Account Resources, make sure you select the appropriate account if you have multiple Cloudflare accounts. This permission is needed to list zones, as the `com.cloudflare.api.account.zone.list` permission seemingly can't be applied yet - account resources seems to grant this implicitly. | ||
Then, for each Zone that you want to be able to generate certs for, add each of under the "Zone Resources", or include all zones if you're comfortable doing so. The resulting API token should look something like this: | ||
 | ||
## Usage | ||
First, create an instance of the library with your Cloudflare API credentials. These can be generated/retrieved from your [account profile](https://dash.cloudflare.com/profile). | ||
First, create an instance of the library with your Cloudflare API credentials or an API token. See the instructions above for more information. | ||
```js | ||
@@ -22,4 +39,3 @@ const acmeDnsCloudflare = require('acme-dns-01-cloudflare'); | ||
const cloudflareDns01 = new acmeDnsCloudflare({ | ||
email: 'example@example.com', | ||
key: 'xxxxxxx', | ||
token: 'xxxxxx', | ||
verifyPropagation: true | ||
@@ -32,7 +48,44 @@ }); | ||
### Greenlock.js | ||
See the [Greenlock.js documentation](https://www.npmjs.com/package/greenlock) for more information. The example below uses the `greenlock-store-fs` module to write these certs to disk for demonstration. | ||
#### Greenlock.js v4 | ||
See the [Greenlock.js documentation](https://www.npmjs.com/package/greenlock) for more information. | ||
```js | ||
const Greenlock = require('greenlock'); | ||
const greenlock = Greenlock.create({ | ||
configDir: "./store", | ||
maintainerEmail: "example@example.com" | ||
}); | ||
greenlock.manager.defaults({ | ||
agreeToTerms: true, | ||
subscriberEmail: "example@example.com", | ||
store: { | ||
module: "greenlock-store-fs", | ||
basePath: "./store/certs" | ||
}, | ||
challenges: { | ||
"dns-01": { | ||
module: "acme-dns-01-cloudflare", | ||
token: "xxxxxx", | ||
verifyPropagation: true | ||
} | ||
} | ||
}); | ||
greenlock.add({ | ||
subject: "example.com", | ||
altnames: ["example.com", "www.example.com"] | ||
}).then(function(){ | ||
console.log("SUCCESS"); | ||
}).catch(console.error); | ||
``` | ||
### Greenlock.js v2 | ||
The example below uses the `greenlock-store-fs` module to write these certs to disk for demonstration. | ||
```js | ||
const Greenlock = require('greenlock'), | ||
@@ -69,2 +122,4 @@ greenlockStore = require('greenlock-store-fs'); | ||
### ACME.js | ||
@@ -79,4 +134,4 @@ | ||
```bash | ||
# CLOUDFLARE_EMAIL, CLOUDFLARE_APIKEY and DOMAIN env vars must be set | ||
# CLOUDFLARE_TOKEN or both CLOUDFLARE_EMAIL and CLOUDFLARE_APIKEY env vars must be set, as well as DOMAIN | ||
node ./test.js | ||
``` |
13384
16.77%205
0.49%133
70.51%161
-11.54%Updated