Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.register = (server, options, next) => {
// Add the status route
server.route({
method: 'GET',
path: '/status',
handler: (request, reply) => reply('OK'),
config: {
description: 'API status',
notes: 'Should respond with 200: ok',
tags: ['api'],
response: {
schema: schema.api.status
}
}
});
next();
};
config.aggregateInterval = aggregateInterval;
}
return pipeline.getMetrics(config);
})
.then(metrics => reply(metrics))
.catch(err => reply(boom.boomify(err)));
},
response: {
schema: pipelineMetricListSchema
},
validate: {
params: {
id: pipelineIdSchema
},
query: schema.api.pagination.concat(joi.object({
startTime: joi.string().isoDate(),
endTime: joi.string().isoDate(),
aggregateInterval: joi.string().valid('none', 'day', 'week', 'month', 'year')
}))
}
}
});
return getMaxLines({ baseUrl, authToken })
.then(maxLines => loadLines({
baseUrl,
linesFrom,
authToken,
pagesToLoad,
sort,
maxLines
}))
.then(([lines, morePages]) => reply(lines)
.header('X-More-Data', (morePages || !isDone).toString()));
})
.catch(err => reply(boom.boomify(err)));
},
response: {
schema: schema.api.loglines.output
},
validate: {
params: schema.api.loglines.params,
query: schema.api.loglines.query
}
}
});
authToken,
pagesToLoad,
sort,
maxLines
}))
.then(([lines, morePages]) => reply(lines)
.header('X-More-Data', (morePages || !isDone).toString()));
})
.catch(err => reply(boom.boomify(err)));
},
response: {
schema: schema.api.loglines.output
},
validate: {
params: schema.api.loglines.params,
query: schema.api.loglines.query
}
}
});
return factory
.list(config)
.then((templates) => {
if (config.raw) {
return reply(templates);
}
return reply(templates.map(p => p.toJson()));
})
.catch(err => reply(boom.boomify(err)));
},
response: {
schema: joi.alternatives().try(listSchema, namespacesSchema)
},
validate: {
query: schema.api.pagination.concat(
joi.object({
namespace: namespaceSchema,
distinct: distinctSchema,
compact: compactSchema
})
)
}
}
});
pipeline.scmContext,
['build', 'impersonated']
);
profile.token = request.server.plugins.auth.generateToken(profile);
request.cookieAuth.set(profile);
return reply({ token: profile.token });
})
.catch(err => reply(boom.boomify(err)));
}
return reply({ token });
},
response: {
schema: schema.api.auth.token
}
}
});
step.lines = request.payload.lines;
} else {
step.startTime = request.payload.startTime || now;
}
return step.update();
});
})
.then(updatedStep => reply(updatedStep).code(200))
.catch(err => reply(boom.boomify(err)));
},
response: {
schema: schema.models.build.getStep
},
validate: {
params: schema.api.loglines.params,
payload: schema.models.build.updateStep
}
}
});
};
}
return factory.list(config)
.then(tags => reply(tags.map(p => p.toJson())))
.catch(err => reply(boom.boomify(err)));
},
response: {
schema: listSchema
},
validate: {
params: {
namespace: namespaceSchema,
name: nameSchema
},
query: schema.api.pagination
}
}
});
'use strict';
const boom = require('boom');
const joi = require('joi');
const schema = require('screwdriver-data-schema');
const authTokenSchema = schema.api.auth.token;
const buildIdSchema = joi.reach(schema.models.build.base, 'id');
module.exports = () => ({
method: 'POST',
path: '/builds/{id}/token',
config: {
description: 'Generate a JWT for use throughout a given build',
notes: 'Generate a JWT for build using temporal JWT which passed in',
tags: ['api', 'builds', 'build_token'],
auth: {
strategies: ['token'],
scope: ['temporal']
},
plugins: {
'hapi-swagger': {
security: [{ token: [] }]
module.exports = options => ({
method: ['GET'],
path: '/auth/key',
config: {
description: 'Get jwt public key',
notes: 'Public Key for verifying JSON Web Tokens',
tags: ['api', 'auth', 'key'],
handler: (request, reply) => reply({
key: options.jwtPublicKey
}),
response: {
schema: schema.api.auth.key
}
}
});