mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
Ported CLI from commander to yargs because yargs suits our large CLI better and is easier to develop with. Split commands into separate files since the file was getting annoyingly long.
This commit is contained in:
parent
72a16ed2ff
commit
cc736ba0ac
35 changed files with 2006 additions and 1538 deletions
59
lib/cli/auth-openid/index.js
Normal file
59
lib/cli/auth-openid/index.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
module.exports.command = 'auth-openid'
|
||||
|
||||
module.exports.describe = 'Start an OpenID auth unit.'
|
||||
|
||||
module.exports.builder = function(yargs) {
|
||||
return yargs
|
||||
.env('STF_AUTH_OPENID')
|
||||
.strict()
|
||||
.option('app-url', {
|
||||
alias: 'a'
|
||||
, describe: 'URL to the app unit.'
|
||||
, type: 'string'
|
||||
, demand: true
|
||||
})
|
||||
.option('openid-identifier-url', {
|
||||
describe: 'OpenID identifier URL.'
|
||||
, type: 'string'
|
||||
, default: process.env.OPENID_IDENTIFIER_URL
|
||||
, demand: true
|
||||
})
|
||||
.option('port', {
|
||||
alias: 'p'
|
||||
, describe: 'The port to bind to.'
|
||||
, type: 'number'
|
||||
, default: process.env.PORT || 7120
|
||||
})
|
||||
.option('secret', {
|
||||
alias: 's'
|
||||
, describe: 'The secret to use for auth JSON Web Tokens. Anyone who ' +
|
||||
'knows this token can freely enter the system if they want, so keep ' +
|
||||
'it safe.'
|
||||
, type: 'string'
|
||||
, default: process.env.SECRET
|
||||
, demand: true
|
||||
})
|
||||
.option('ssid', {
|
||||
alias: 'i'
|
||||
, describe: 'The name of the session ID cookie.'
|
||||
, type: 'string'
|
||||
, default: process.env.SSID || 'ssid'
|
||||
})
|
||||
.epilog('Each option can be be overwritten with an environment variable ' +
|
||||
'by converting the option to uppercase, replacing dashes with ' +
|
||||
'underscores and prefixing it with `STF_AUTH_OPENID_` (e.g. ' +
|
||||
'`STF_AUTH_OPENID_SECRET`). Legacy environment variables like ' +
|
||||
'OPENID_IDENTIFIER_URL are still accepted, too, but consider them ' +
|
||||
'deprecated.')
|
||||
}
|
||||
|
||||
module.exports.handler = function(argv) {
|
||||
return require('../../units/auth/openid')({
|
||||
port: argv.port
|
||||
, secret: argv.secret
|
||||
, appUrl: argv.appUrl
|
||||
, openid: {
|
||||
identifierUrl: argv.openidIdentifierUrl
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue