Skip to content

Commit 3fb10cd

Browse files
committed
First releasable version. This includes an update to the README as well for docs
1 parent 1fae4e9 commit 3fb10cd

16 files changed

+1226
-676
lines changed

.editorconfig

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# http://editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
# Change these settings to your own preference
10+
indent_style = space
11+
indent_size = 2
12+
13+
# We recommend you to keep these unchanged
14+
end_of_line = lf
15+
charset = utf-8
16+
trim_trailing_whitespace = true
17+
insert_final_newline = true
18+
19+
# Unsupported options
20+
quote_type = single
21+
spaces_around_brackets = inside
22+
23+
[*.md]
24+
trim_trailing_whitespace = false

.eslintrc

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"extends": [
3+
"airbnb/base",
4+
"plugin:import/errors",
5+
"plugin:import/warnings"
6+
],
7+
"ecmaFeatures": {
8+
"modules": true
9+
},
10+
"parserOptions": {
11+
"ecmaVersion": 4,
12+
"sourceType": "module"
13+
},
14+
"env": {
15+
"node": true,
16+
"mocha": true
17+
},
18+
"rules": {
19+
"max-len": 0,
20+
"react/display-name": 0,
21+
"array-bracket-spacing": [2, "always"],
22+
"comma-dangle": [2, "never"],
23+
"eol-last": 2,
24+
"indent": [2, 2, {
25+
"SwitchCase": 1
26+
}],
27+
"import/no-extraneous-dependencies": [error, { devDependencies: true }],
28+
"prefer-arrow-callback": 0,
29+
"object-shorthand": 0,
30+
"prefer-template": 0,
31+
"func-names": 0,
32+
"new-cap": 0,
33+
"no-param-reassign": 0,
34+
"no-multiple-empty-lines": 2,
35+
"no-unused-vars": 2,
36+
"no-var": 0,
37+
"object-curly-spacing": [2, "always"],
38+
"quotes": [2, "single", "avoid-escape"],
39+
"semi": [2, "always"],
40+
"strict": 0,
41+
"space-before-blocks": [2, "always"],
42+
"space-before-function-paren": [2, {
43+
"anonymous": "never",
44+
"named": "never"
45+
}]
46+
}
47+
}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.nyc_output/
12
local/
23
node_modules/
34
lib/
5+
/npm-debug.log

.npmignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
src/
2+
test/
3+
local/
4+
/npm-debug.log

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Auth0
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+190-26
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,216 @@ There are a few good extensions that you can use to deploy updates automatically
1111
npm i -g auth0-deploy-cli
1212
```
1313

14-
### To test locally
15-
16-
Clone the github repo and install globally
17-
```
18-
git clone [email protected]:auth0/auth0-deploy-cli
19-
cd auth0-deploy-cli
20-
npm install -g
21-
```
22-
2314
## Usage
2415

25-
```
26-
You must create a client in your service account that has access to the management API with the following scopes:
16+
### Create a client in your Auth0 Account
17+
You must create a client in your service account that has access to the management API with the following scopes before you can configure the a0deploy CLI.
18+
19+
#### Scopes
2720
* read:tenant_settings
2821
* update:tenant_settings
22+
* create:client_grants
23+
* read:client_grants
24+
* update:client_grants
25+
* delete:client_grants
26+
* create:clients
2927
* read:clients
3028
* update:clients
3129
* delete:clients
3230
* read:connections
3331
* update:connections
32+
* create:resource_servers
33+
* read:resource_servers
34+
* update:resource_servers
35+
* delete:resource_servers
3436
* read:rules
3537
* create:rules
3638
* update:rules
3739
* delete:rules
40+
41+
#### Client Creation Steps
42+
Coming soon there will be an Auth0 extension you can use to initialize your environment. In the meantime, you can do it manually by following these steps:
43+
44+
1. log into your dashboard
45+
1. click the clients tab
46+
1. click the "New Client" button
47+
1. Name it something like "Deploy Client"
48+
1. Select Non-Interactive as the client type
49+
1. Click Create
50+
1. If you haven't already enabled API's, you may have to toggle the switch to enable API's
51+
1. Use the "Select an API" dropdown to choose: "Auth0 Management API"
52+
1. Click the Settings tab
53+
1. Copy the client ID, you'll need it for a couple steps down
54+
1. Click the "Documentation->Management API" link from the top menu
55+
1. Using the left navigation click "Client Grants" then "Create a client grant"
56+
1. Click the "create:client_grants" scope to create the token
57+
1. In the Body section put the following:
58+
59+
{
60+
"client_id": "<your client ID copied above>",
61+
"audience": "https://<your domain: (e.g. fabrikam-dev.auth0.com)>/api/v2/",
62+
"scope": [
63+
"read:client_grants",
64+
"create:client_grants",
65+
"delete:client_grants",
66+
"update:client_grants",
67+
"read:clients",
68+
"update:clients",
69+
"delete:clients",
70+
"create:clients",
71+
"read:connections",
72+
"update:connections",
73+
"read:resource_servers",
74+
"update:resource_servers",
75+
"delete:resource_servers",
76+
"create:resource_servers",
77+
"read:rules",
78+
"update:rules",
79+
"delete:rules",
80+
"create:rules",
81+
"read:tenant_settings",
82+
"update:tenant_settings"
83+
]
84+
}
85+
86+
1. Click the "Try" button
87+
88+
#### Create Your Config File
89+
The config file will use the client ID and secret from your newly created client. You can place this anywhere on the filesystem. Here is the example:
90+
91+
```json
92+
{
93+
"SLACK_INCOMING_WEBHOOK_URL": "<your webhook URL from slack, just leave this out if you are not using slack>",
94+
"AUTH0_DOMAIN": "<your auth0 domain (e.g. fabrikam-dev.auth0.com) >",
95+
"AUTH0_CLIENT_SECRET": "<your deploy client secret>",
96+
"AUTH0_CLIENT_ID": "<your deploy client ID>",
97+
"AUTH0_KEYWORD_REPLACE_MAPPINGS": {
98+
"YOUR_ARRAY_KEY": [
99+
"http://localhost:8080",
100+
"https://somedomain.com"
101+
],
102+
"YOUR_STRING_KEY": "some environment specific string"
103+
}
104+
}
105+
```
106+
107+
##### AUTH0_KEYWORD_REPLACE_MAPPINGS
108+
The mappings are there so that you can use the same configuration file for all of your environments (e.g. dev, uat, staging, and prod) without having to have different versions of the files for each environment. The mappings allow you to replace certain values in your configuration repo with envrionment specic values. For example, you could specify a different JWT timeout in your dev environment then prod for testing:
109+
110+
Client .json:
111+
```
112+
{
113+
...
114+
"jwt_configuration": {
115+
"lifetime_in_seconds": @@JWT_TIMEOUT@@,
116+
"secret_encoded": true
117+
}
118+
...
119+
}
120+
```
121+
122+
Dev Config .json:
123+
```
124+
"AUTH0_KEYWORD_REPLACE_MAPPINGS": {
125+
"JWT_TIMEOUT": 120,
126+
...
127+
}
128+
```
129+
130+
Prod Config .json:
131+
```
132+
"AUTH0_KEYWORD_REPLACE_MAPPINGS": {
133+
"JWT_TIMEOUT": 3600,
134+
...
135+
}
136+
```
137+
138+
#### Organize your repository
139+
There is more extensive documentation online for how the files are expected to be laid out to work with the source control configuration utilities [here](https://auth0.com/docs/extensions/github-deploy)
140+
141+
Here is a simple overview:
38142

39-
a0deploy [ options ]
40-
-i,--input_file The updates to deploy. See JSON Format for more information.
41-
-c,--config_file The JSON configuration file. See JSON Format for more information.
42-
43-
Config JSON Format
44-
{
45-
Leave this? "SLACK_INCOMING_WEBHOOK_URL": "https://hooks.slack.com/services/...",
46-
"AUTH0_DOMAIN": "YOUR_DOMAIN",
47-
"AUTH0_CLIENT_SECRET": "YOUR_CLIENT_SECRET",
48-
"AUTH0_CLIENT_ID": "YOUR_CLIENT_ID"
49-
}
50143
```
144+
repository =>
145+
clients
146+
client1-name.json
147+
client1-name.meta.json # if specifying client grants
148+
my-other-client-name.json
149+
resource-servers
150+
resource server 1.json
151+
some other resource server.json
152+
database-connections
153+
my-connection-name
154+
get_user.js
155+
login.js
156+
rules
157+
rule1.js
158+
rule1.json
159+
rule2.js
160+
pages
161+
login.html
162+
login.json
163+
password_reset.html
164+
password_reset.json
165+
```
166+
167+
##### Clients
168+
The name of the file is the name of the client that is created or updated.
169+
170+
In the .json file you can put the same json you would put when using the Management API for creating clients. It will only try to keep the fields specified inline with what is configured already. If a client doesn't exist yet, it will create it.
171+
172+
To specify client grants, you must specify the following in the metadata file. (e.g. client1-name.meta.json)
173+
174+
```
175+
{
176+
"grants": {
177+
"Resource server audience": [
178+
"scope1",
179+
"scope2"
180+
]
181+
}
182+
}
183+
```
184+
185+
##### Resource servers
186+
The name of the file is the name of the resource server that is created or updated.
187+
188+
In the .json file you can put the same json you would put when using the Management API for creating resource servers. It will only try to keep the fields specified inline with what is configured already. If a resource server doesn't exist yet, it will create it.
189+
190+
##### Database Connections
191+
See Database Connection configuration [here](https://auth0.com/docs/extensions/github-deploy#deploy-database-connection-scripts)
192+
193+
##### Rules
194+
See Rules configuration [here](https://auth0.com/docs/extensions/github-deploy#deploy-rules)
51195

52-
## JSON Formats
196+
NOTE: There is not currently a way to mark rules as manual yet, that will become part of the configuration file in the future.
53197

54-
### Input File
198+
##### Custom Pages
199+
See Custom Pages configuration [here](https://auth0.com/docs/extensions/github-deploy#deploy-pages)
55200

56-
### Config File
201+
#### Command Line Options
202+
203+
```
204+
a0deploy [ options ]
205+
-h, --help output usage information
206+
-v,--verbose Dump extra debug information.
207+
-i,--input_file <input file> The updates to deploy. See JSON Format for more information.
208+
-c,--config_file <config file> The JSON configuration file. See JSON Format for more information.
209+
-s,--state_file <state file> A file for persisting state between runs. Default: ./local/state
210+
```
211+
212+
### To test locally
213+
214+
Clone the github repo and install globally
215+
```
216+
git clone [email protected]:auth0/auth0-deploy-cli
217+
cd auth0-deploy-cli
218+
npm install
219+
npm run test
220+
```
57221

58222
##Known issues
59223
See https://github.com/auth0/auth0-deploy-cli/issues
60224

61225
##License
62-
MIT
226+
MIT

index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
* Created by mostekcm on 11/2/16.
55
*/
66

7-
require('./lib/index');
7+
var path = require('path');
8+
9+
require(path.join(path.join(__dirname,'lib'),'index'));

0 commit comments

Comments
 (0)