screwdriver-api 5.0.2 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server.js +20 -17
- package/package.json +1 -1
package/lib/server.js
CHANGED
|
@@ -164,24 +164,27 @@ module.exports = async config => {
|
|
|
164
164
|
if (config.log && config.log.audit.enabled) {
|
|
165
165
|
server.ext('onCredentials', (request, h) => {
|
|
166
166
|
const { username, scope, pipelineId } = request.auth.credentials;
|
|
167
|
-
const validScope = config.log.audit.scope.filter(s => scope.includes(s));
|
|
168
|
-
|
|
169
|
-
if (Array.isArray(validScope) && validScope.length > 0) {
|
|
170
|
-
let context;
|
|
171
|
-
|
|
172
|
-
if (validScope.includes('admin')) {
|
|
173
|
-
context = `Admin ${username}`;
|
|
174
|
-
} else if (validScope.includes('user')) {
|
|
175
|
-
context = `User ${username}`;
|
|
176
|
-
} else if (validScope.includes('build') || validScope.includes('temporal')) {
|
|
177
|
-
context = `Build ${username}`;
|
|
178
|
-
} else if (validScope.includes('pipeline')) {
|
|
179
|
-
context = `Pipeline ${pipelineId}`;
|
|
180
|
-
} else {
|
|
181
|
-
context = `Guest ${username}`;
|
|
182
|
-
}
|
|
183
167
|
|
|
184
|
-
|
|
168
|
+
if (scope) {
|
|
169
|
+
const validScope = config.log.audit.scope.filter(s => scope.includes(s));
|
|
170
|
+
|
|
171
|
+
if (Array.isArray(validScope) && validScope.length > 0) {
|
|
172
|
+
let context;
|
|
173
|
+
|
|
174
|
+
if (validScope.includes('admin')) {
|
|
175
|
+
context = `Admin ${username}`;
|
|
176
|
+
} else if (validScope.includes('user')) {
|
|
177
|
+
context = `User ${username}`;
|
|
178
|
+
} else if (validScope.includes('build') || validScope.includes('temporal')) {
|
|
179
|
+
context = `Build ${username}`;
|
|
180
|
+
} else if (validScope.includes('pipeline')) {
|
|
181
|
+
context = `Pipeline ${pipelineId}`;
|
|
182
|
+
} else {
|
|
183
|
+
context = `Guest ${username}`;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
logger.info(`[Login] ${context} ${request.method} ${request.path}`);
|
|
187
|
+
}
|
|
185
188
|
}
|
|
186
189
|
|
|
187
190
|
return h.continue;
|