Skip to content
This repository has been archived by the owner on Feb 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #35 from auth0-extensions/tenant-support
Browse files Browse the repository at this point in the history
Tenant support
  • Loading branch information
zxan1285 authored Jul 9, 2019
2 parents 85af07e + 47995aa commit 312d5cd
Show file tree
Hide file tree
Showing 20 changed files with 762 additions and 50 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.5.0] - 2019-07-09

### auth0-bitbucket-deploy v2.10.0
### auth0-github-deploy v2.10.0
### auth0-gitlab-deploy v2.11.0
### auth0-visualstudio-deploy v2.9.0

- #### Added
- Tenant settings support (`tenant.json` file).
- Guardian settings support (`guardian/factors/*.json`, `guardian/providers/*.json`, `guardian/templates/*.json` files).

## [1.4.2] - 2019-06-14

### auth0-gitlab-deploy v2.10.2
Expand Down
146 changes: 142 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth0-deploy-extensions",
"version": "1.4.2",
"version": "1.5.0",
"description": "Auth0 Deployment Extensions",
"engines": {
"node": "5.9.0"
Expand Down Expand Up @@ -181,6 +181,7 @@
"redux-simple-router": "^2.0.4",
"redux-static": "^1.0.0",
"rimraf": "^2.5.2",
"sinon": "^7.3.2",
"style-loader": "0.16.0",
"url-loader": "^0.5.7",
"webpack": "1.13.3",
Expand Down
21 changes: 21 additions & 0 deletions server/lib/providers/bitbucket.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import path from 'path';
import Promise from 'bluebird';
import { constants } from 'auth0-source-control-extension-tools';

Expand Down Expand Up @@ -104,10 +105,14 @@ const getTree = (parsedRepo, branch, sha) => {
};
const promises = {
databases: getDBConnectionsTree(params),
tenant: getTreeByDir(params, ''),
rules: getTreeByDir(params, constants.RULES_DIRECTORY),
pages: getTreeByDir(params, constants.PAGES_DIRECTORY),
roles: getTreeByDir(params, constants.ROLES_DIRECTORY),
emails: getTreeByDir(params, constants.EMAIL_TEMPLATES_DIRECTORY),
guardianFactors: getTreeByDir(params, path.join(constants.GUARDIAN_DIRECTORY, constants.GUARDIAN_FACTORS_DIRECTORY)),
guardianFactorTemplates: getTreeByDir(params, path.join(constants.GUARDIAN_DIRECTORY, constants.GUARDIAN_TEMPLATES_DIRECTORY)),
guardianFactorProviders: getTreeByDir(params, path.join(constants.GUARDIAN_DIRECTORY, constants.GUARDIAN_PROVIDERS_DIRECTORY)),
clientGrants: getTreeByDir(params, constants.CLIENTS_GRANTS_DIRECTORY),
connections: getTreeByDir(params, constants.CONNECTIONS_DIRECTORY),
clients: getTreeByDir(params, constants.CLIENTS_DIRECTORY),
Expand All @@ -118,7 +123,11 @@ const getTree = (parsedRepo, branch, sha) => {
.then((result) => (_.union(
result.rules,
result.databases,
result.tenant,
result.emails,
result.guardianFactors,
result.guardianFactorTemplates,
result.guardianFactorProviders,
result.pages,
result.roles,
result.clients,
Expand Down Expand Up @@ -222,6 +231,14 @@ const getRules = (parsedRepo, branch, files, shaToken) => {
downloadRule(parsedRepo, branch, ruleName, rules[ruleName], shaToken), { concurrency: 2 });
};

/*
* Try to download tenant settings.
*/
const getTenant = (parsedRepo, branch, files, shaToken) => {
const tenantFile = { configFile: _.find(files, f => utils.isTenantFile(f.path)) };
return downloadConfigurable(parsedRepo, branch, 'tenant', tenantFile, shaToken);
};

/*
* Get email provider.
*/
Expand Down Expand Up @@ -332,10 +349,14 @@ export function getChanges({ repository, branch, sha }) {
})), null, 2)}`);

const promises = {
tenant: getTenant(parsedRepo, branch, files, sha),
rules: getRules(parsedRepo, branch, files, sha),
databases: getDatabaseData(parsedRepo, branch, files, sha),
emailProvider: getEmailProvider(parsedRepo, branch, files, sha),
emailTemplates: getHtmlTemplates(parsedRepo, branch, files, sha, constants.EMAIL_TEMPLATES_DIRECTORY, constants.EMAIL_TEMPLATES_NAMES),
guardianFactors: getConfigurables(parsedRepo, branch, files, sha, path.join(constants.GUARDIAN_DIRECTORY, constants.GUARDIAN_FACTORS_DIRECTORY)),
guardianFactorTemplates: getConfigurables(parsedRepo, branch, files, sha, path.join(constants.GUARDIAN_DIRECTORY, constants.GUARDIAN_TEMPLATES_DIRECTORY)),
guardianFactorProviders: getConfigurables(parsedRepo, branch, files, sha, path.join(constants.GUARDIAN_DIRECTORY, constants.GUARDIAN_PROVIDERS_DIRECTORY)),
pages: getHtmlTemplates(parsedRepo, branch, files, sha, constants.PAGES_DIRECTORY, constants.PAGE_NAMES),
roles: getConfigurables(parsedRepo, branch, files, sha, constants.ROLES_DIRECTORY),
clients: getConfigurables(parsedRepo, branch, files, sha, constants.CLIENTS_DIRECTORY),
Expand Down
16 changes: 16 additions & 0 deletions server/lib/providers/github.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import path from 'path';
import axios from 'axios';
import Promise from 'bluebird';
import GitHubApi from 'github';
Expand Down Expand Up @@ -254,6 +255,17 @@ const getEmailProvider = (repository, branch, files) =>
{ configFile: _.find(files, f => utils.isEmailProvider(f.path)) }
);

/*
* Get tenant settings.
*/
const getTenant = (repository, branch, files) =>
downloadConfigurable(
repository,
branch,
'tenant',
{ configFile: _.find(files, f => utils.isTenantFile(f.path)) }
);

/*
* Get all configurables (resource servers / clients).
*/
Expand All @@ -277,9 +289,13 @@ export const getChanges = ({ repository, branch, sha }) =>

const promises = {
rules: getRules(repository, branch, files),
tenant: getTenant(repository, branch, files),
databases: getDatabaseData(repository, branch, files),
emailProvider: getEmailProvider(repository, branch, files),
emailTemplates: getHtmlTemplates(repository, branch, files, constants.EMAIL_TEMPLATES_DIRECTORY, constants.EMAIL_TEMPLATES_NAMES),
guardianFactors: getConfigurables(repository, branch, files, path.join(constants.GUARDIAN_DIRECTORY, constants.GUARDIAN_FACTORS_DIRECTORY)),
guardianFactorTemplates: getConfigurables(repository, branch, files, path.join(constants.GUARDIAN_DIRECTORY, constants.GUARDIAN_TEMPLATES_DIRECTORY)),
guardianFactorProviders: getConfigurables(repository, branch, files, path.join(constants.GUARDIAN_DIRECTORY, constants.GUARDIAN_PROVIDERS_DIRECTORY)),
pages: getHtmlTemplates(repository, branch, files, constants.PAGES_DIRECTORY, constants.PAGE_NAMES),
roles: getConfigurables(repository, branch, files, constants.ROLES_DIRECTORY),
clients: getConfigurables(repository, branch, files, constants.CLIENTS_DIRECTORY),
Expand Down
Loading

0 comments on commit 312d5cd

Please sign in to comment.