forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1584321 - Handle static client scopes internally
With this change, each service declares its scopes in `services/<service>/scopes.yml`, and that data is gathered during generation and placed in a convenient place for the auth service. The Auth service then interpolates those scopes into the configured STATIC_CLIENTS, preserving the supplied accessToken and applying the service's configured azure accountId.
- Loading branch information
Showing
38 changed files
with
477 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
level: major | ||
reference: bug 1584321 | ||
--- | ||
Scopes for the Taskcluster services themselves are now handled internally to the platform, although access tokens must still be managed as part of the deployment process. | ||
When deploying this version, remove all `scopes` and `description` properties from `static/taskcluster/..` clients in the array in the Auth service's `STATIC_CLIENTS` configuration. | ||
See [the new docs on static clients](https://docs.taskcluster.net/docs/manual/deploying/static-clients) for more background on this setting. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
infrastructure/tooling/src/generate/generators/metadata.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const _ = require('lodash'); | ||
const path = require('path'); | ||
const config = require('taskcluster-lib-config'); | ||
const {listServices, readRepoYAML, REPO_ROOT} = require('../../utils'); | ||
|
||
// We're not going to deploy login into k8s | ||
const SERVICES = listServices().filter(s => !['login'].includes(s)); | ||
|
||
exports.tasks = []; | ||
|
||
SERVICES.forEach(name => { | ||
exports.tasks.push({ | ||
title: `Fetch service metadata for ${name}`, | ||
requires: [], | ||
provides: [`configs-${name}`, `procslist-${name}`, `scopes-${name}`], | ||
run: async (requirements, utils) => { | ||
const envVars = config({ | ||
files: [{ | ||
path: path.join(REPO_ROOT, 'services', name, 'config.yml'), | ||
required: true, | ||
}], | ||
getEnvVars: true, | ||
}); | ||
|
||
const procs = await readRepoYAML(path.join('services', name, 'procs.yml')); | ||
|
||
const scopesPath = path.join('services', name, 'scopes.yml'); | ||
let scopes = null; | ||
try { | ||
scopes = await readRepoYAML(scopesPath); | ||
} catch (err) { | ||
if (err.code !== 'ENOENT') { | ||
throw err; | ||
} | ||
} | ||
return { | ||
[`configs-${name}`]: envVars, | ||
[`procslist-${name}`]: procs, | ||
[`scopes-${name}`]: scopes, | ||
}; | ||
}, | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
infrastructure/tooling/src/generate/generators/static-clients.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const _ = require('lodash'); | ||
const {listServices, writeRepoJSON} = require('../../utils'); | ||
|
||
// We're not going to deploy login into k8s | ||
const SERVICES = listServices().filter(s => !['login'].includes(s)); | ||
|
||
exports.tasks = []; | ||
|
||
exports.tasks.push({ | ||
title: 'Assemble static clients', | ||
requires: [ | ||
...SERVICES.map(name => `scopes-${name}`), | ||
], | ||
provides: ['static-clients'], | ||
run: async (requirements, utils) => { | ||
const staticClients = []; | ||
SERVICES.forEach(name => { | ||
const scopes = requirements[`scopes-${name}`]; | ||
if (scopes) { | ||
staticClients.push({ | ||
clientId: `static/taskcluster/${name}`, | ||
scopes: scopes, | ||
}); | ||
} | ||
}); | ||
|
||
staticClients.push({ | ||
clientId: 'static/taskcluster/root', | ||
scopes: ['*'], | ||
}); | ||
|
||
return {'static-clients': staticClients}; | ||
}, | ||
}); | ||
|
||
exports.tasks.push({ | ||
title: 'Configure static client scopes', | ||
requires: ['static-clients'], | ||
provides: [], | ||
run: async (requirements, utils) => { | ||
const staticClients = requirements['static-clients']; | ||
const staticScopes = staticClients.map(({clientId, scopes}) => ({clientId, scopes})); | ||
|
||
writeRepoJSON('services/auth/src/static-scopes.json', staticScopes); | ||
}, | ||
}); |
Oops, something went wrong.