shibboleths_lil_helper 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/Gemfile +16 -0
  2. data/Gemfile.lock +36 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.markdown +199 -0
  5. data/Rakefile +54 -0
  6. data/TODOS.txt +15 -0
  7. data/VERSION +1 -0
  8. data/bin/slh +9 -0
  9. data/doc/debugging_shibboleth.markdown +8 -0
  10. data/doc/deprecated_code_that_could_be_useful.rb +32 -0
  11. data/doc/for_slh_developers.markdown +38 -0
  12. data/doc/nuances.markdown +13 -0
  13. data/doc/technical_question_and_answer.markdown +85 -0
  14. data/lib/shibboleths_lil_helper.rb +9 -0
  15. data/lib/slh.rb +17 -0
  16. data/lib/slh/class_methods.rb +83 -0
  17. data/lib/slh/cli.rb +140 -0
  18. data/lib/slh/cli/command_base.rb +32 -0
  19. data/lib/slh/cli/compare_metadata.rb +53 -0
  20. data/lib/slh/cli/copy_templates_to_override.rb +12 -0
  21. data/lib/slh/cli/describe_config.rb +75 -0
  22. data/lib/slh/cli/fetch_metadata.rb +27 -0
  23. data/lib/slh/cli/generate.rb +20 -0
  24. data/lib/slh/cli/generate_capistrano_deploy.rb +35 -0
  25. data/lib/slh/cli/generate_metadata.rb +53 -0
  26. data/lib/slh/cli/host_filterable_base.rb +16 -0
  27. data/lib/slh/cli/initialize.rb +30 -0
  28. data/lib/slh/cli/verify_metadata_encryption.rb +25 -0
  29. data/lib/slh/models/base.rb +23 -0
  30. data/lib/slh/models/host.rb +55 -0
  31. data/lib/slh/models/site.rb +139 -0
  32. data/lib/slh/models/site_path.rb +17 -0
  33. data/lib/slh/models/strategy.rb +131 -0
  34. data/lib/slh/models/version.rb +4 -0
  35. data/lib/slh/templates/_application_details.erb +33 -0
  36. data/lib/slh/templates/config.rb.erb +33 -0
  37. data/lib/slh/templates/deploy.rb.erb +42 -0
  38. data/lib/slh/templates/shib_apache.conf.erb +24 -0
  39. data/lib/slh/templates/shibboleth2.xml.erb +44 -0
  40. data/lib/slh/templates/sp_metadata_for_entity_id_to_give_to_idp.xml.erb +40 -0
  41. data/lib/slh/templates/sp_metadata_for_host_to_give_to_idp.xml.erb +33 -0
  42. data/shibboleths_lil_helper.gemspec +111 -0
  43. data/test/fixtures/dummy1.rb +15 -0
  44. data/test/fixtures/dummy1_output/attribute-map.xml +5 -0
  45. data/test/fixtures/dummy1_output/shib_for_vhost.conf +15 -0
  46. data/test/fixtures/dummy1_output/shibboleth2.xml +27 -0
  47. data/test/helper.rb +18 -0
  48. data/test/test_shibboleths_lil_helper.rb +105 -0
  49. metadata +211 -0
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ gem "activesupport", "~> 3.0.9"
5
+ gem "nokogiri"
6
+ gem 'i18n' # Required to make require 'active_support/all' work...
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "shoulda", ">= 0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.4"
14
+ gem "rcov", ">= 0"
15
+ gem 'ruby-debug'
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,36 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.0.9)
5
+ columnize (0.3.4)
6
+ git (1.2.5)
7
+ i18n (0.6.0)
8
+ jeweler (1.6.4)
9
+ bundler (~> 1.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ linecache (0.46)
13
+ rbx-require-relative (> 0.0.4)
14
+ nokogiri (1.5.0)
15
+ rake (0.9.2)
16
+ rbx-require-relative (0.0.5)
17
+ rcov (0.9.10)
18
+ ruby-debug (0.10.4)
19
+ columnize (>= 0.1)
20
+ ruby-debug-base (~> 0.10.4.0)
21
+ ruby-debug-base (0.10.4)
22
+ linecache (>= 0.3)
23
+ shoulda (2.11.3)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ activesupport (~> 3.0.9)
30
+ bundler (~> 1.0.0)
31
+ i18n
32
+ jeweler (~> 1.6.4)
33
+ nokogiri
34
+ rcov
35
+ ruby-debug
36
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 University of Minnesota
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,199 @@
1
+ About
2
+ =====
3
+ Shibboleth's Lil Helper is a tool that automates the generation of Apache/IIS Shibboleth Native Service Provider configuration & metadata files. It provides several benefits over manually configuring each NativeSp instance/server by:
4
+
5
+ * __Providing a consistent configuration approach__ you can apply uniformly across all of the servers managed by your organization.
6
+ * Makes deployment automation possible, errors less frequent, and troubleshooting easier.
7
+
8
+ * __Dividing high level auth specs from actual NativeSp configuration__
9
+ * Programmers can focus on high level goals like "protect files underneath the '/secure' directory on 'somewebsite.com'" rather than grappeling with the bewildering complexity of the NativeSp's interrelated XML files, the Shibboleth protocal, SAML, etc.
10
+
11
+ * __Providing conceptually simple linear process__ that distills the main steps associated with Shibboleth integration.
12
+
13
+ IMPORTANT NOTE/DISCLAIMER
14
+ -------------------------
15
+ All you see here on Github is the readme, no code yet.
16
+ For that to happen two things need to occur:
17
+
18
+ * We need to battle-test the (working) code across our entire
19
+ infrastructure and fix bugs before releasing.
20
+
21
+ * Someone from the IDM team within OIT needs approve that our approach
22
+ is solid and endorse its usage for the U of M.
23
+
24
+ **The current status as of October 6th, 2011**
25
+
26
+ * We have it working in PHP, .NET, and Rails on 2 servers and 4 vhosts for Apache and IIS.
27
+
28
+ * Assuming no snags (cause that never happens in software, :)), we
29
+ anticipate 90% of our infrastructure migrated by Nov 1st. At which
30
+ point we hope to release this code into the wild. And perhaps do a demo
31
+ session at a Code-People meeting.
32
+
33
+ Why another tool?
34
+ -----------------
35
+ We needed something that could help manage shibboleth SP
36
+ configuration consistently with minimal manual work for:
37
+
38
+ * Many web servers
39
+ * each running iis6, iis7, or Apache 2.2
40
+ * each hosting many vhosts (aka sites)
41
+ * each running PHP, Rails 2 + 3, classic ASP, or .NET
42
+ * each running the Apache/IIS Native Service Provider
43
+
44
+ Installation
45
+ ============
46
+ * Pre-requisites:
47
+ * Rubygems: http://rubygems.org/pages/download
48
+ * Bundler: gem install bundler
49
+
50
+ * From github:
51
+
52
+ git clone git://github.com/joegoggins/shibboleths_lil_helper.git
53
+ cd shibboleths_lil_helper
54
+ bundle
55
+ ./bin/slh
56
+ (then follow instructions)
57
+
58
+ * Via Ruby Gems: Not working yet
59
+
60
+ Assumptions
61
+ ===========
62
+ * Shibboleth Native Service Provider Apache/IIS is already installed on your target web servers.
63
+ * The X509Certificate (sp-cert.pem, sp-key.pem) keys are in their default locations along-side shibboleth2.xml. This tool does not help you generate these keys, that's up to you. The default installation of Native Shib generates keys for you though.
64
+ * The Shibboleth apache module is loaded globally for all vHosts
65
+ * /bin/slh is in your $PATH (automatically done with Rubygem install
66
+ method, manual is git cloned
67
+
68
+ Concept
69
+ =======
70
+
71
+ Auth specs are stated in your shibboleths_lil_helper/config.rb
72
+ via an easily readable ruby parseable domain specific language. From these specs, Shibboleth's Lil Helper is capable of generating all of the required XML files you will need to integrate with
73
+ a Shibboleth Identify Provider (Idp).
74
+
75
+ The generation of these XML files happens through a command line tool
76
+ called "slh". Each particular task is broken into sub-commands such as
77
+ "initialize", "generate", or "metadata" that perform various tasks.
78
+
79
+ For example, given the following shibboleths_lil_helper/config.rb:
80
+
81
+ Slh.for_strategy :umn_apache_shib_test_server do
82
+ set :sp_entity_id, 'https://asr.umn.edu/shibboleth/default'
83
+ set :idp_metadata_url, 'https://idp-test.shib.umn.edu/metadata.xml'
84
+ set :error_support_contact, 'goggins@umn.edu'
85
+ for_host 'asr-web-dev4.oit.umn.edu' do
86
+ for_site 'shib-php-test.asr.umn.edu' do
87
+ protect 'secure'
88
+ end
89
+ for_site 'shib-rails2-test.asr.umn.edu' do
90
+ protect 'secure'
91
+ end
92
+ end
93
+ end
94
+
95
+ an invocation of
96
+
97
+ `slh generate`
98
+
99
+ will produce the a dir structure and various config files
100
+ associated with these specifications for each strategy, host, and site.
101
+
102
+ shibboleths_lil_helper/
103
+ generated/
104
+ <strategy>/ (apache_shib_test_server)
105
+ <hostname>/ (asr-web-dev4.oit.umn.edu)
106
+ idp_metadata.xml
107
+ shib_apache.conf
108
+ shibboleth2.xml
109
+ sp_metadata_for_host_to_give_to_idp.xml
110
+ <site>/ (shib-php-test.asr.umn.edu)
111
+ fetched_metadata.xml
112
+
113
+
114
+ * The generated shibboleth2.xml will have RequestMap specs that restrict
115
+ access to the "/secure" path for the specified vhosts.
116
+
117
+ * These generated files should be checked into a source control repository.
118
+
119
+ The core assumptions of the specifications DSL are
120
+
121
+ * a strategy ("for_strategy")
122
+ * has one IDP entity id (:idp_metadata_url)
123
+ * has one service provider entity id (:sp_entity_id)
124
+ * has many hosts
125
+ * a host (for_host)
126
+ * has many sites
127
+ * a site (for_site)
128
+ * has many site paths that have various auth rules
129
+ * a site path (protect)
130
+ * has a "flavor" such as the following specified like
131
+ *protect "optional_auth", :flavor => :authentication_optional*
132
+ * authentication_required
133
+ * authentication_optional
134
+ * authentication_required_for_specific_users
135
+
136
+
137
+ Usage
138
+ =====
139
+ * Type `slh`, you will see instructions for each sub-command and how
140
+ to get additional information about them. In general the process is
141
+ * [initialize] initialize a shibboleths_lil_helper/config.rb
142
+ * [in your editor] tweak shibboleths_lil_helper/config.rb to reflect the servers you
143
+ will be using shibboleth with
144
+ * [generate] generate shibboleth2.xml, shib_apach.conf
145
+ config files
146
+ * [a deployment tool or manually] deploy these files out to each host (ideally using a deployment automation tool such as Capistrano)
147
+ * [metadata] generate metadata: creates and combines SP Metadata from all
148
+ of the Shib servers into a file(s) you can share with your IDP.
149
+ * [email] send the generated meta data to your IDP
150
+
151
+ Real World Example
152
+ ==================
153
+ The following describes how we integrate this tool's generated output
154
+ into a deployment automation tool called Capistrano.
155
+
156
+ We have a private repo called shibboleth_deployer that includes the shibboleths_lil_helper generated config files and uses Capistrano to push these files out target servers and restarts shibd and httpd. It's usage looks like:
157
+
158
+ cap deploy HOST=asr-web-dev4.oit.umn.edu
159
+
160
+ For each of our target servers we setup Capistrano to have a clone of
161
+ this shibboleth_deployer repo structured in the standard way, e.g:
162
+
163
+ ls /etc/shibboleth_deployer
164
+ current
165
+ releases
166
+ shared
167
+
168
+ Setup symlinks to the appropriate config files within
169
+ shibboleth_deployer from the places the Native Shibboleth SP expects
170
+ files to be, e.g:
171
+
172
+ (from the /etc/shibboleth dir)
173
+ ln -s /etc/shibboleth_deployer/current/shibboleths_lil_helper/generated/apache_shib_test_server/asr-web-dev4.oit.umn.edu/shibboleth2.xml shibboleth2.xml
174
+
175
+ ln -s /etc/shibboleth_deployer/current/shibboleths_lil_helper/generated/apache_shib_test_server/asr-web-dev4.oit.umn.edu/idp_metadata.xml idp_metadata.xml
176
+
177
+ (from the /etc/httpd/conf.d dir)
178
+ ln -s /etc/shibboleth_deployer/current/shibboleths_lil_helper/generated/apache_shib_test_server/asr-web-dev4.oit.umn.edu/shib_apache.conf shib_apache.conf
179
+
180
+ Additional Docs
181
+ ===============
182
+ * doc/nuances.markdown
183
+ * doc/for_slh_developers.markdown
184
+
185
+ How to Help
186
+ ======================
187
+
188
+ Email Us
189
+ ----------------------
190
+ * Let us know you are interested in using the tool.
191
+
192
+ * Voice you ideas about questions you have and features you'd like to see.
193
+
194
+ Authors
195
+ =======
196
+ * Joe Goggins, Academic Support Resources, goggins@umn.edu
197
+ * Chris Dinger, Academic Support Resources, ding0057@umn.edu
198
+
199
+ Copyright (c) 2011 University of Minnesota
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "shibboleths_lil_helper"
18
+ gem.homepage = "http://github.com/joegoggins/shibboleths_lil_helper"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A ruby gem to streamline the setup, deployment, and ongoing management of Apache & IIS web-servers running the Shibboleth Native Service Provider implementations.}
21
+ gem.description = %Q{See the summary text.}
22
+ gem.email = "goggins@umn.edu"
23
+ gem.authors = ["Joe Goggins"]
24
+ gem.executables = 'slh'
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ test.rcov_opts << '--exclude "gems/*"'
42
+ end
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "shibboleths_lil_helper #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/TODOS.txt ADDED
@@ -0,0 +1,15 @@
1
+ * Release as gem
2
+
3
+
4
+ DONE
5
+ * Incorporate FAQ stuff somehow https://www.pivotaltracker.com/story/show/19256223
6
+ * Add something that warns LOUDLY to use slh with source control
7
+ * Rejigger the default config.rb.erb--simplify and reference documentation
8
+ >>> Add is_key_originator
9
+ * Separate metadata and make a verify_metadata command
10
+ * verify is_key_originator has been specified somewhere after a strategy
11
+ has been declared
12
+ * Eliminate *args from all DSL models, it allows you to mis-used the tool easily (i did) with /protect
13
+ * Revert to host level sp metadata instead of all in one
14
+ * Put comments in the generated output that specify the documentation associated with it
15
+ For example, above SPSSO: http://www.schemacentral.com/sc/ulex20/e-md_SPSSODescriptor.html
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/bin/slh ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # This load path thingy
3
+ # for testing executables in gems
4
+ # http://blakesmith.github.com/2010/06/26/gem-executables-loading-the-relative-path.html
5
+ this_files_path = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
6
+ $LOAD_PATH.unshift File.join(File.dirname(this_files_path), *%w[.. lib])
7
+ require 'rubygems'
8
+ require 'shibboleths_lil_helper'
9
+ Slh::Cli.execute
@@ -0,0 +1,8 @@
1
+ ---
2
+ Check the syntax of you shibboleth2.xml
3
+ /usr/sbin/shibd -tc /swadm/etc/shibboleth/shibboleth2.xml
4
+
5
+ ---
6
+ you MUST MUST MUST turn this on in your apache conf:
7
+ UseCanonicalName On
8
+
@@ -0,0 +1,32 @@
1
+ # From Slh::Models::Site
2
+ # These nodes are extracted to create .metadata_site_specific_xml
3
+ # and removed to create metadata_non_site_specific_nokogiri
4
+ # which is used in Host to put the site specific crap below 1 instance of the non specific crap
5
+ # so you can give your IDP one metadata file
6
+ #
7
+ # def self.metadata_site_specific_xpaths
8
+ # ['//md:ArtifactResolutionService', '//md:SingleLogoutService','//md:AssertionConsumerService']
9
+ # end
10
+
11
+ # def metadata_site_specific_xml
12
+ # if @metadata_site_specific_xml.blank?
13
+ # @metadata_site_specific_xml = ''
14
+ # self.class.metadata_site_specific_xpaths.each do |xpath|
15
+ # @metadata_site_specific_xml << self.metadata_nokogiri.xpath(xpath).to_a.join("\n")
16
+ # @metadata_site_specific_xml << "\n"
17
+ # end
18
+ # end
19
+ # @metadata_site_specific_xml
20
+ # end
21
+
22
+ # def metadata_non_site_specific_nokogiri
23
+ # if @metadata_non_site_specific_nokogiri.blank?
24
+ # @metadata_non_site_specific_nokogiri = self.metadata_nokogiri.clone
25
+ # self.class.metadata_site_specific_xpaths.each do |xpath|
26
+ # @metadata_non_site_specific_nokogiri.xpath(xpath).remove
27
+ # end
28
+ # end
29
+ # @metadata_non_site_specific_nokogiri
30
+ # end
31
+
32
+
@@ -0,0 +1,38 @@
1
+ ---
2
+ Find the version of shibboleth you are currently running on a host
3
+ rpm -qi shibboleth
4
+
5
+ FOR SHIBBOLETHS_LIL_HELPER DEVELOPERS
6
+ ---
7
+ If you want to inspect what is happening ANYWHERE in the code (including
8
+ ERB templates in <% %> tags)
9
+ Put
10
+ debugger
11
+ anywhere in the code, and run:
12
+ rdebug slh <SOME_COMMAND>
13
+
14
+ An interactive Ruby shell will pop up and you can hit
15
+ e <THE_NAME_OF_THE_VAR>
16
+
17
+
18
+ ---
19
+ Assuming
20
+ * you are in the root dir of a git clone of shibboleths_lil_helper
21
+ * you have already run initialize and therefore have a
22
+ "shibboleths_lil_helper" sub-dir within the
23
+ shibboleths_lil_helper repo
24
+
25
+ You can get at an irb session loaded with your config stuff like this:
26
+ rake console
27
+
28
+ # then once in console
29
+ require 'shibboleths_lil_helper'
30
+ Slh.load_config
31
+
32
+ # Then tinker with config stuff stemming from
33
+ Slh.strategies
34
+
35
+ DEV_WISH_LIST: `rake console` should do all of these things for you, I
36
+ think this will involve looking at jeweler's "console" rake task and
37
+ figuring out how to add files to load and ruby to run before entering
38
+ the irb session