-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from chef-cookbooks/chris-rock/compliance_refr…
…esh_token improve compliance refresh token handling
- Loading branch information
Showing
12 changed files
with
358 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# encoding: utf-8 | ||
|
||
# exchanges a refresh token into an access token | ||
def retrieve_access_token(server_url, refresh_token, insecure) | ||
require 'inspec' | ||
require 'bundles/inspec-compliance/api' | ||
require 'bundles/inspec-compliance/http' | ||
_success, _msg, access_token = Compliance::API.post_refresh_token(server_url, refresh_token, insecure) | ||
# TODO: we return always the access token, without proper error handling | ||
access_token | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# encoding: utf-8 | ||
class Audit | ||
class Resource | ||
class ChefInspec < Chef::Resource | ||
resource_name :inspec | ||
|
||
property :version, String, default: 'latest' | ||
|
||
default_action :install | ||
|
||
# installs inspec if required | ||
action :install do | ||
converge_by 'install/update inspec' do | ||
chef_gem 'inspec' do | ||
version new_resource.version if new_resource.version != 'latest' | ||
compile_time true | ||
action :install | ||
end | ||
end | ||
|
||
converge_by 'verifies the inspec version' do | ||
verify_inspec_version version | ||
end | ||
end | ||
|
||
def verify_inspec_version(inspec_version) | ||
require 'inspec' | ||
# check we have the right inspec version | ||
if Inspec::VERSION != inspec_version && inspec_version !='latest' | ||
Chef::Log.warn "Wrong version of inspec (#{Inspec::VERSION}), please "\ | ||
'remove old versions (/opt/chef/embedded/bin/gem uninstall inspec).' | ||
else | ||
Chef::Log.warn "Using inspec version: (#{Inspec::VERSION})" | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.