From 8d7aa5e4cec66512ed7dd13781f8b6fafe0c19b7 Mon Sep 17 00:00:00 2001 From: Jinping Han Date: Thu, 27 Jun 2019 08:47:36 -0700 Subject: [PATCH] Remove undocumented ST2_AUTH_TOKEN from st2chatops `ST2_AUTH_TOKEN` is not documented in `st2chatops.env` and because the token either has a long expiry time or the expiry time is so short the ChatOps service is restarted all the time to pick up the config changes. It is no point to keep it, therefore remove this auth method from hubot-stackstorm entirely. --- scripts/stackstorm.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/scripts/stackstorm.js b/scripts/stackstorm.js index 263a8eb..2d3e019 100644 --- a/scripts/stackstorm.js +++ b/scripts/stackstorm.js @@ -52,9 +52,6 @@ env.ST2_WEBUI_URL = env.ST2_WEBUI_URL || null; env.ST2_AUTH_USERNAME = env.ST2_AUTH_USERNAME || null; env.ST2_AUTH_PASSWORD = env.ST2_AUTH_PASSWORD || null; -// Optional authentication token -env.ST2_AUTH_TOKEN = env.ST2_AUTH_TOKEN || null; - // Optional API key env.ST2_API_KEY = env.ST2_API_KEY || null; @@ -153,8 +150,6 @@ module.exports = function(robot) { if (env.ST2_API_KEY) { api.setKey({ key: env.ST2_API_KEY }); - } else if (env.ST2_AUTH_TOKEN) { - api.setToken({ token: env.ST2_AUTH_TOKEN }); } function authenticate() { @@ -165,11 +160,6 @@ module.exports = function(robot) { robot.logger.info('Using ST2_API_KEY as authentication. Expiry will lead to bot exit.'); return Promise.resolve(); } - // Auth token gets precedence 2 - if (env.ST2_AUTH_TOKEN) { - robot.logger.info('Using ST2_AUTH_TOKEN as authentication. Expiry will lead to bot exit.'); - return Promise.resolve(); - } robot.logger.info('Requesting a token...'); @@ -197,7 +187,7 @@ module.exports = function(robot) { }); } - if (env.ST2_API_KEY || env.ST2_AUTH_TOKEN || env.ST2_AUTH_USERNAME || env.ST2_AUTH_PASSWORD) { + if (env.ST2_API_KEY || env.ST2_AUTH_USERNAME || env.ST2_AUTH_PASSWORD) { // If using username and password then all are required. if ((env.ST2_AUTH_USERNAME || env.ST2_AUTH_PASSWORD) && !(env.ST2_AUTH_USERNAME && env.ST2_AUTH_PASSWORD && env.ST2_AUTH_URL)) {