-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
work with token and direct compliance server API #20
Conversation
ad5662a
to
fd7a1f0
Compare
example recipe token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6InVQUExHVjFiVDg4YTNnZ0MtQ1hxUDdfTlgzTGZiblZSeHhYUTQwV2l0cXI0Z0pRTGw3T2........'
# iterate over all selected profiles
node['audit']['profiles'].each do |owner_profile, enabled|
next unless enabled
o, p = owner_profile.split('/')
compliance_profile p do
owner o
server URI.parse('http://192.168.33.1:8080/api/') # <---
token token # <---
action [:fetch, :execute]
end
end
# report the results
compliance_report 'chef-server' do
server URI.parse('http://192.168.33.1:8080/api/')
token token # <---
direct true # <---
owner 'admin' # <---
end if node['audit']['profiles'].values.any? |
0e79b9a
to
015c65c
Compare
tf.binmode | ||
Net::HTTP.start(url.host, url.port) do |http| | ||
http.use_ssl = url.scheme == 'https' | ||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # FIXME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we make it an attribute and set the default to false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't get it. It's not boolean but a string property that is nil
if unset and some string if it was provided.
So currently, it's a property of a resource. You can use attributes to set it in your recipe (see here) -- I haven't had a need to touch the default recipe here.
Having a resource break its interface and reach out into node attributes doesn't seem right to me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srenatus of course we should not use node attributes directly in a library. I was thinking about making it an option to compliance profile:
compliance_profile p do
owner o
server URI.parse(ENV['COMPLIANCE_API'])
insecure true
token token
action [:fetch, :execute]
end
Then we could use an attribute as input. I would like to make insecure to false by default. In insecure is true, we could set the proper openssl string as required.
@srenatus very good, I like the improvement. Just some minor questions |
Thanks @alexpop for finding the nasty bug resolved in bfeb004 👍 @chris-rock is this what you had in mind? |
bfeb004
to
fef1848
Compare
fef1848
to
7106b99
Compare
Rebased & refactored. |
@@ -17,16 +17,26 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
|
|||
token = node['audit']['api_token'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be token = node['audit']['token']
?
Awesome @srenatus, I just found some minor nitpicking things :-) |
I merge it, once its green |
b321200
to
8703b8f
Compare
Awesome @srenatus |
Hey, just learned that there has to be a slash at the end (URI object). Otherwise it will fail. |
This adds the ability to directly talk to a compliance server, without
passing through a chef-server. To ensure proper authentication, this
needs a user (access) token:
There're two big buts here, though:
ENV['ACCESS_TOKEN']
(or similar) to pass it into the recipe.