Skip to content

Commit

Permalink
feat(pub): protect X-Debug with key
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquiseRosier committed Sep 14, 2019
1 parent 4835250 commit 518060d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

const yargsOpenwhisk = require('./yargs-openwhisk.js');
const yargsFastly = require('./yargs-fastly.js');
const yargsDebug = require('./yargs-debug.js');
const yargsGithub = require('./yargs-github.js');
const { makeLogger } = require('./log-common.js');

Expand All @@ -29,6 +30,7 @@ module.exports = function strain() {
builder: (yargs) => {
yargsOpenwhisk(yargs);
yargsFastly(yargs);
yargsDebug(yargs);
yargsGithub(yargs);
yargs
.option('dry-run', {
Expand Down Expand Up @@ -116,6 +118,7 @@ module.exports = function strain() {
.withWskHost(argv.wskHost)
.withWskNamespace(argv.wskNamespace)
.withFastlyNamespace(argv.fastlyNamespace)
.withDebugKey(argv.debugKey)
.withFastlyAuth(argv.fastlyAuth)
.withDryRun(argv.dryRun)
.withPublishAPI(argv.apiPublish)
Expand Down
7 changes: 7 additions & 0 deletions src/remotepublish.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class RemotePublishCommand extends AbstractCommand {
this._wsk_namespace = null;
this._wsk_host = null;
this._fastly_namespace = null;
this._debug_key = null;
this._fastly_auth = null;
this._dryRun = false;
this._publishAPI = 'https://adobeioruntime.net/api/v1/web/helix/helix-services/publish@v2';
Expand Down Expand Up @@ -127,6 +128,11 @@ class RemotePublishCommand extends AbstractCommand {
return this;
}

withDebugKey(value) {
this._debug_key = value;
return this;
}

withFilter(only, exclude) {
if (!(only || exclude)) {
return this;
Expand Down Expand Up @@ -293,6 +299,7 @@ ${e}`);
configuration: this.config.toJSON(),
service: this._fastly_namespace,
token: this._fastly_auth,
debugKey: this._debug_key || this._fastly_namespace,
version: this._version,
};

Expand Down
20 changes: 20 additions & 0 deletions src/yargs-debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2019 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

module.exports = function commonArgs(yargs) {
return yargs
.option('debug-key', {
alias: 'debugKey',
describe: 'The key to enable the X-Debug header (default is the fastly service id)',
type: 'string',
});
};

0 comments on commit 518060d

Please sign in to comment.