Skip to content

Instantly share code, notes, and snippets.

@kgilpin
kgilpin / basic-org.rb
Last active August 29, 2015 13:57
Conjur Policy - Basic Organization
test_layer = nil
group "security_admin" do
owns do
scope "v1" do
ops = group "ops" do
owns do
test_layer = layer "test"
layer "production"
end
@kgilpin
kgilpin / Notes
Created December 8, 2014 21:33
Conjur commands
Upgrade Conjur CLI
$ sudo /opt/conjur/embedded/bin/gem install conjur-cli --no-rdoc --no-ri
@kgilpin
kgilpin / blue-green.rb
Created June 13, 2015 20:14
Simple blue/green model
# Simple script which creates two groups, blue and green. Each
# group contains a couple of users. The groups have different permissions
# on 'webservice' resources. In an SDF gatekeeper scenario, the 'blue'
# team will be able to 'read' service a, and the 'green' team will be
# able to 'read' service b. Neither team can perform any action besides 'read'.
# The owner of the 'webservice' resources (which is the user that runs this script)
# has all permissions on all records, via Conjur ownership.
# Create the blue team
blue = group "blue" do
@kgilpin
kgilpin / executor.rb
Created May 24, 2012 13:34
Command execution with realtime feedback
exit_code = Open3.popen3(env, cmd, opts) do |stdin, stdout, stderr, thread|
stdin.close
# Create a thread to read from each stream
threads = [[:stdout, stdout], [:stderr, stderr]].collect do |method, stream|
Thread.new do
until (line = stream.gets).nil?
callback.send(method, line)
end
end
end
@kgilpin
kgilpin / gist:3537559
Created August 30, 2012 18:55
Archive a Jenkins Ruby Gem artifact to a Conjur Dataset
cd pkg && INSCITIV_ENV=stage rvm 1.9.2@myproject do bundle exec ../bin/conjur datafile:upload "Jenkins artifacts: myproject" *.gem
@kgilpin
kgilpin / gist:3873480
Created October 11, 2012 16:08
Find a free drive letter
# Need to find the next available device to let AWS know where to attach
# the volume
drive = (Array('c'..'z').map{|c| "/dev/xvd#{c}"} - Dir.glob("/dev/xvd*"))[0]
device_id = drive[-1..-1]
@kgilpin
kgilpin / bastion-policy.rb
Last active October 28, 2015 14:45
DSL Tutorial
# Defines a Bastion server layer.
#
# Usage:
# conjur policy load --as-group ops bastion-policy.rb
policy "bastion" do
# Members of this group will be able to adminsiter the bastion.
admins = group "admins"
# Members of this group will be able to login to the bastion
# with a regular, non-privileged account.
users = group "users"
@kgilpin
kgilpin / create_bacon.sh
Last active December 26, 2015 13:29
Create Conjur "bacon" resource
$ conjur resource:create food:$ns/bacon
{
"id": "sandbox:food:1eqwg0/bacon",
"owner": "sandbox:user:kgilpin",
"permissions": []
}
@kgilpin
kgilpin / README.md
Last active February 11, 2016 22:23
Conjur Traffic Auth for the Truly Paranoid

Approach

Create distinct roles with specific permissions to call untrusted web services.

Client services authenticate as one of these roles when calling an untrusted web service.

Discussion

When using an externalized (Nginx) forwarder and gatekeeper, a webservice client can send a Conjur access token for its own identity. The client doesn't have to worry about the gatekeeper misusing the access token,