mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
added apipath cli option to inspec compliance with default to /api
This commit is contained in:
parent
f6578baf26
commit
bd594f3608
2 changed files with 6 additions and 4 deletions
|
@ -10,10 +10,10 @@ module Compliance
|
|||
# everything will be stored in local Configuration store
|
||||
class API # rubocop:disable Metrics/ClassLength
|
||||
# logs into the server, retrieves a token and stores it locally
|
||||
def self.login(server, username, password, insecure)
|
||||
def self.login(server, username, password, insecure, apipath)
|
||||
config = Compliance::Configuration.new
|
||||
config['server'] = server
|
||||
url = "#{server}/oauth/token"
|
||||
config['server'] = "#{server}#{apipath}"
|
||||
url = "#{config['server']}/oauth/token"
|
||||
|
||||
success, data = Compliance::API.post(url, username, password, insecure)
|
||||
if !data.nil?
|
||||
|
|
|
@ -16,8 +16,10 @@ module Compliance
|
|||
desc: 'Chef Compliance Password'
|
||||
option :insecure, aliases: :k, type: :boolean,
|
||||
desc: 'Explicitly allows InSpec to perform "insecure" SSL connections and transfers'
|
||||
option :apipath, type: :string, default: '/api',
|
||||
desc: 'Set the path to the API, defaults to /api'
|
||||
def login(server)
|
||||
success, msg = Compliance::API.login(server, options['user'], options['password'], options['insecure'])
|
||||
success, msg = Compliance::API.login(server, options['user'], options['password'], options['insecure'], options['apipath'])
|
||||
if success
|
||||
puts 'Successfully authenticated'
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue