aaf-mdqt 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/codeql-analysis.yml +70 -0
  3. data/.github/workflows/ruby.yml +41 -0
  4. data/.gitignore +25 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +1 -0
  7. data/.rubocop_todo.yml +296 -0
  8. data/.ruby-version +1 -0
  9. data/.tool-versions +1 -0
  10. data/.travis.yml +7 -0
  11. data/CHANGELOG.md +168 -0
  12. data/CODE_OF_CONDUCT.md +74 -0
  13. data/Gemfile +9 -0
  14. data/LICENSE.txt +21 -0
  15. data/Makefile +4 -0
  16. data/README.md +268 -0
  17. data/Rakefile +5 -0
  18. data/aaf-mdqt.gemspec +46 -0
  19. data/bin/console +14 -0
  20. data/bin/setup +8 -0
  21. data/cucumber.yml +2 -0
  22. data/exe/mdqt +174 -0
  23. data/lib/mdqt/cli/base.rb +190 -0
  24. data/lib/mdqt/cli/cache_control.rb +25 -0
  25. data/lib/mdqt/cli/check.rb +78 -0
  26. data/lib/mdqt/cli/compliance.rb +0 -0
  27. data/lib/mdqt/cli/defaults.rb +70 -0
  28. data/lib/mdqt/cli/entities.rb +47 -0
  29. data/lib/mdqt/cli/exists.rb +0 -0
  30. data/lib/mdqt/cli/get.rb +130 -0
  31. data/lib/mdqt/cli/list.rb +65 -0
  32. data/lib/mdqt/cli/ln.rb +81 -0
  33. data/lib/mdqt/cli/ls.rb +54 -0
  34. data/lib/mdqt/cli/rename.rb +75 -0
  35. data/lib/mdqt/cli/reset.rb +27 -0
  36. data/lib/mdqt/cli/services.rb +25 -0
  37. data/lib/mdqt/cli/transform.rb +33 -0
  38. data/lib/mdqt/cli/url.rb +37 -0
  39. data/lib/mdqt/cli/version.rb +17 -0
  40. data/lib/mdqt/cli.rb +24 -0
  41. data/lib/mdqt/client/identifier_utils.rb +51 -0
  42. data/lib/mdqt/client/metadata_file.rb +144 -0
  43. data/lib/mdqt/client/metadata_response.rb +182 -0
  44. data/lib/mdqt/client/metadata_service.rb +194 -0
  45. data/lib/mdqt/client/metadata_validator.rb +81 -0
  46. data/lib/mdqt/client.rb +83 -0
  47. data/lib/mdqt/schema/MetadataExchange.xsd +112 -0
  48. data/lib/mdqt/schema/mdqt_check_schema.xsd +5 -0
  49. data/lib/mdqt/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd +195 -0
  50. data/lib/mdqt/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd +108 -0
  51. data/lib/mdqt/schema/saml-schema-assertion-2.0.xsd +283 -0
  52. data/lib/mdqt/schema/saml-schema-metadata-2.0.xsd +337 -0
  53. data/lib/mdqt/schema/ws-addr.xsd +137 -0
  54. data/lib/mdqt/schema/ws-authorization.xsd +145 -0
  55. data/lib/mdqt/schema/ws-federation.xsd +471 -0
  56. data/lib/mdqt/schema/ws-securitypolicy-1.2.xsd +1205 -0
  57. data/lib/mdqt/schema/xenc-schema.xsd +136 -0
  58. data/lib/mdqt/schema/xml.xsd +287 -0
  59. data/lib/mdqt/schema/xmldsig-core-schema.xsd +309 -0
  60. data/lib/mdqt/version.rb +3 -0
  61. data/lib/mdqt.rb +5 -0
  62. data/lib/tasks/cucumber.rake +8 -0
  63. data/lib/tasks/spec.rake +5 -0
  64. data/lib/tasks/tests.rake +6 -0
  65. data/lib/tasks/yard.rake +6 -0
  66. metadata +332 -0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at pete@binary-ape.org. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mdq.gemspec
4
+ gemspec
5
+
6
+ gem 'simplecov', require: false, group: :test
7
+
8
+ gem 'pry'
9
+ gem 'rake'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Pete Birkinshaw
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,4 @@
1
+ publish-gem:
2
+ gem build aaf-mdqt.gemspec
3
+ gem push aaf-mdqt-*.gem
4
+ rm aaf-mdqt-*.gem
data/README.md ADDED
@@ -0,0 +1,268 @@
1
+ # MDQT - A Metadata Query Tool
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/mdqt.svg)](https://badge.fury.io/rb/mdqt) [![Maintainability](https://api.codeclimate.com/v1/badges/111c46aaebfe25e4a4a9/maintainability)](https://codeclimate.com/github/Digital-Identity-Labs/mdqt/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/111c46aaebfe25e4a4a9/test_coverage)](https://codeclimate.com/github/Digital-Identity-Labs/mdqt/test_coverage) [![Build Status](https://travis-ci.org/Digital-Identity-Labs/mdqt.svg?branch=master)](https://travis-ci.org/Digital-Identity-Labs/mdqt)
4
+
5
+ MDQT is small library and commandline tool to query MDQ services for SAML metadata.
6
+ You could do this with `curl` and `xmlsec1` but it's a little more convenient to use `mdqt` instead.
7
+
8
+ MDQT also has features for managing local metadata files, to help when running an MDQ service or a Shibboleth IdP or SP.
9
+
10
+ MDQ currently provides these features:
11
+
12
+ - Downloading single entities, lists or aggregates
13
+ - Signature verification
14
+ - Validating metadata against SAML2 schema
15
+ - Saving metadata to disk
16
+ - Extracting entity IDs from both aggregate and individual metadata files
17
+ - Renaming metadata files to their entity ID sha1 hashes (for use with LocalDynamicMetadataProvider)
18
+ - Creating sha1 hash symlinks to metadata files (also for use with Local Dynamic Metadata)
19
+ - Listing the entity IDs of downloaded metadata files
20
+ - Showing the full URL of an entity
21
+ - Caching entity metadata and using Gzip compression
22
+
23
+
24
+ ## MDQ?
25
+
26
+ MDQ is a simple HTTP-based standard for looking up individual SAML entity metadata. Rather than regularly
27
+ downloading large metadata aggregates containing thousands of entity descriptions,
28
+ an IdP or SP can download the metadata for an individual entity whenever it is needed.
29
+
30
+ The UK Access Management Federation has a
31
+ [useful page explaining MDQ](https://www.ukfederation.org.uk/content/Documents/MDQ)
32
+
33
+ ## Installation
34
+
35
+ MDQT is tested on recent MacOS and Linux, and should work with
36
+ Ruby 3.0.0 or later and recent JRuby releases.
37
+
38
+ ### As a gem for general use
39
+
40
+ To install system-wide on your default Ruby, use
41
+
42
+ $ sudo gem install mdqt
43
+
44
+ If using a per-user Ruby via `rbenv`, `asdf` or similar, you'll need
45
+
46
+ $ gem install mdqt
47
+
48
+ ### As part of a Ruby project
49
+
50
+ To add MDQT to a Ruby project include this line in your application's `Gemfile`
51
+
52
+ ```ruby
53
+ gem 'mdqt'
54
+ ```
55
+
56
+ and then execute:
57
+
58
+ $ bundle
59
+
60
+ ### As a Docker container
61
+
62
+ (Experimental)
63
+ See the instructions at [MDQT-Container](https://github.com/Digital-Identity-Labs/mdqt-container)
64
+
65
+ ### Verifying signed metadata, installing Nokogiri
66
+
67
+ MDQT can check that metadata has not been tampered with by verifying its
68
+ signature. Some MDQ services use unencrypted HTTP connections and rely
69
+ on signed metadata.
70
+
71
+ MDQT supports signature verification but requires a Ruby library called
72
+ Nokogiri to do the hard work. Nokogiri is fast and useful but can sometimes
73
+ be awkward to install for non-developers (it can sometimes require a C development
74
+ environment and various XML libraries). In most cases Nokogiri will install
75
+ automatically, without problems, when you install MDQT, but if you encounter any
76
+ problems installing Nokogiri the [Installing Nokogiri](http://www.nokogiri.org/tutorials/installing_nokogiri.html) documentation is very helpful.
77
+
78
+ ## Commandline Usage as an MDQ client
79
+
80
+ You can see a list of commandline options by typing:
81
+
82
+ $ mdqt help
83
+
84
+ To see more information about a command, use the `--help` option after the command or type `help <command>`:
85
+
86
+ $ mdqt help get
87
+
88
+ ### Selecting an MDQ service to access
89
+
90
+ You can specify the MDQ service with a commandline option:
91
+
92
+ $ mdqt get --service https://mdq.example.com/mdq http://entity.ac.uk/shibboleth
93
+
94
+ It's more convenient to set an environment variable to specify a default MDQ
95
+ service. Set `MDQT_SERVICE` or `MDQ_BASE_URL` to the base URL of your MDQ service.
96
+
97
+ $ export MDQT_SERVICE=https://mdq.example.com/mdq
98
+ $ mdqt get http://entity.ac.uk/shibboleth
99
+ $ mdqt get http://example.org/service
100
+
101
+ Finally, if you don't specify an MDQ service with `--service` or `MDQT_SERVICE` then `mdqt` *might* be
102
+ able to guess your local NREN's MDQ service. Do not do this in production!
103
+
104
+ If an MDQ service is known to MDQT it can be selected using an alias:
105
+
106
+ $ mdqt get --service incommon http://entity.edu/shibboleth
107
+
108
+ You can see known services and their aliases using `mdqt services`
109
+
110
+ ### Downloading entity metadata
111
+
112
+ Downloading entity metadata to STDOUT:
113
+
114
+ $ mdqt get https://test-idp.ukfederation.org.uk/idp/shibboleth
115
+
116
+ Using the sha1 hashed version of entity IDs requires quotes or escaping in some shells:
117
+
118
+ $ mdqt get "{sha1}52e2065fc0d53744e8d4ee2c2f30696ebfc5def9"
119
+
120
+ $ mdqt get \{sha1\}52e2065fc0d53744e8d4ee2c2f30696ebfc5def9
121
+
122
+ $ mdqt get [sha1]52e2065fc0d53744e8d4ee2c2f30696ebfc5def9
123
+
124
+ Requesting all metadata from an MDQ endpoint is done by specifying `--all`:
125
+
126
+ $ mdqt get --all
127
+
128
+
129
+ ### Caching metadata
130
+
131
+ Caching can be enabled using `--cache`. At the moment the `mdqt` executable
132
+ only supports caching to disk. It will create a cache directory in your temporary
133
+ directory.
134
+
135
+ $ mdqt get --cache --service https://mdq.example.com/mdq http://entity.ac.uk/shibboleth
136
+
137
+ Caching is now on by default. To force a single command to *not* use the cache, include `--reset`
138
+
139
+ $ mdqt get --reset --service https://mdq.example.com/mdq http://entity.ac.uk/shibboleth
140
+
141
+ You can clear the cache by using the `reset` command:
142
+
143
+ $ mdqt reset
144
+
145
+
146
+ ### Verifying metadata
147
+
148
+ If you have enabled verification by installing `xmldsig` (and have downloaded and checked a suitable
149
+ certificate for your MDQ server) you can require verification by passing
150
+ they `verify-with` flag with the path of your certificate.
151
+
152
+ $ mdqt get --verify-with myfederation.pem https://indiid.net/idp/shibboleth
153
+
154
+ It's possible to pass more than one certificate by separating them with commas
155
+
156
+ $ mdqt get --verify-with myfederation.pem,previous.pem https://indiid.net/idp/shibboleth
157
+
158
+ Basic XML correctness and validation against SAML2 Metadata schema can be enabled with the
159
+ `--validate` switch:
160
+
161
+ $ mdqt get --validate https://indiid.net/idp/shibboleth
162
+
163
+ If you need to check metadata that has already been downloaded then try the `check`
164
+ command:
165
+
166
+ $ mdqt check metadata.xml # Just validate
167
+ $ mdqt check --verify-with myfederation.pem metadata.xml # Verify signature too
168
+
169
+ You shouldn't need to *validate* XML from a trusted MDQ service such as one run by a
170
+ national federation. You should however always *verify* the signature of XML sent over an unencrypyted HTTP connection,
171
+ and probably even over HTTPS. MDQT's validation check is mostly for use when writing
172
+ or debugging your own MDQ service.
173
+
174
+ ### Saving metadata as files
175
+
176
+ The simplest way to save metadata is to redirect output from the `get` command:
177
+
178
+ $ mdqt get http://entity.ac.uk/shibboleth > metadata.xml
179
+
180
+ MDQT also offers the `--save-to` option to write all metadata into a directory
181
+
182
+ $ mdqt get http://entity.ac.uk/shibboleth --save-to metadata_directory
183
+
184
+ The `--save-to` option requires a directory to be specified. All files will be saved
185
+ with a name based on their transformed identifier (sha1 hash) such as
186
+ `77603e0cbda1e00d50373ca8ca20a375f5d1f171.xml`
187
+
188
+ ### Other Features
189
+
190
+ For more information about current settings, download results, and so on, add
191
+ `--verbose` to commands:
192
+
193
+ $mdqt get --verbose http://entity.ac.uk/shibboleth
194
+
195
+ To convert normal URI entity IDs into MDQ SHA1 hashed transformed identifiers use the `transform` command:
196
+
197
+ $ mdqt transform http://example.org/service
198
+
199
+ Transforming identifiers that have already been transformed should not re-transform them.
200
+
201
+ To see more details of what is being sent and received by a `get` command add the `--explain` flag
202
+
203
+ $ mdqt get --explain --service https://mdq.example.com/mdq http://entity.ac.uk/shibboleth
204
+
205
+ MDQT will then show a table of sent and received headers which may be useful when debugging servers.
206
+
207
+ To extract a list of all entity IDs from a file:
208
+
209
+ $ mdqt entities metadata.xml
210
+
211
+ $ mdqt entities --sha1 metadata.xml
212
+
213
+ To create sha1 symlinks to a metadata file:
214
+
215
+ $ mdqt ln example_idp.xml
216
+
217
+ To rename a file to its entity ID sha1 has:
218
+
219
+ $ mdqt rename example_idp.xml
220
+
221
+ To list the entity IDs of files in a directory:
222
+
223
+ $ mdqt ls
224
+
225
+ To list all entities available at an MDQ service:
226
+
227
+ $ mdqt list
228
+
229
+ To show the MDQ services known to MDQT, and their aliases:
230
+
231
+ $ mdqt services
232
+
233
+ To show the full MDQ URL of an entity
234
+
235
+ $ mdqt url http://entity.ac.uk/shibboleth
236
+
237
+ MDQT can accept input on stdin, allowing composition and pipelining
238
+
239
+ $ cat list_of_ids.txt | mdqt url
240
+
241
+ $ mdqt list | grep cern.ch | mdqt get --save-to cern_metadata/ --list | mdqt ls
242
+
243
+ ## Alternatives
244
+
245
+ * [SAML Library](https://github.com/trscavo/saml-library) is a set of scripts to help with metadata-related tasks, written
246
+ by Tom Scavo of Internet2. Some of the scripts provide similar functionality to MDQT, and are designed to be piped together.
247
+
248
+ ## Library Usage
249
+
250
+ Please don't! We originally had plans to include a usable generic library was part of MDQT but unless there's new demand
251
+ for it that's now unlikely to happen. However, we do now have a set of libraries for the Elixir language, based around
252
+ [Smee](https://github.com/Digital-Identity-Labs/smee) - not very helpful for Ruby projects but possibly of use for new
253
+ projects.
254
+
255
+ ## Development
256
+
257
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
258
+
259
+ To install this gem onto your local machine, run `bundle exec rake install`.
260
+
261
+ ## Contributing
262
+
263
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Digital-Identity-Labs/mdqt.
264
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
265
+
266
+ ## License
267
+
268
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir.glob('lib/tasks/*.rake').each { |r| load r}
4
+
5
+ task :default => :tests
data/aaf-mdqt.gemspec ADDED
@@ -0,0 +1,46 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mdqt/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "aaf-mdqt"
8
+ spec.version = MDQT::VERSION
9
+ spec.authors = ["Pete Birkinshaw", "Australian Access Federation"]
10
+ spec.email = []
11
+
12
+ spec.summary = %q{Commandline utility for accessing MDQ services}
13
+ spec.description = %q{Commandline utility for downloading SAML metadata from MDQ services}
14
+ spec.homepage = "https://github.com/Digital-Identity-Labs/mdqt"
15
+ spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = '>= 3.0.0'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency 'commander', "~>4.6"
27
+ spec.add_dependency 'faraday', "~>2.9.0"
28
+ spec.add_dependency 'faraday-http-cache', "~>2.5.0"
29
+ spec.add_dependency 'faraday-follow_redirects', "~>0.3.0"
30
+ spec.add_dependency 'httpx', "~>1.2.0"
31
+ spec.add_dependency 'activesupport', "~>7"
32
+ spec.add_dependency 'dalli', "~>3.2"
33
+ spec.add_dependency 'pastel', "~>0.8"
34
+ spec.add_dependency 'terminal-table', "~>3.0"
35
+ spec.add_dependency 'concurrent-ruby-ext', "~>1.2.2"
36
+ spec.add_dependency 'xmldsig', "~>0.7.0"
37
+
38
+ # spec.add_development_dependency "bundler", "~>2"
39
+ # spec.add_development_dependency "rake", ">= 13.1.0"
40
+ spec.add_development_dependency "rspec", "~> 3.10"
41
+ spec.add_development_dependency "cucumber", "~> 7.1"
42
+ spec.add_development_dependency "aruba", "~> 2.0"
43
+ spec.add_development_dependency "vcr", "~> 6.0"
44
+ spec.add_development_dependency "yard", "~> 0.9"
45
+ #spec.add_development_dependency "yard-cucumber", "~> 4.0"
46
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mdqt"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/cucumber.yml ADDED
@@ -0,0 +1,2 @@
1
+ default: --publish
2
+
data/exe/mdqt ADDED
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'mdqt/cli'
4
+ require 'mdqt/version'
5
+
6
+ require 'commander'
7
+
8
+ Signal.trap('SIGINT') do
9
+ puts 'Received signal, halting'
10
+ exit 1
11
+ end
12
+
13
+ Commander.configure do
14
+ program :name, 'mdqt'
15
+ program :version, MDQT::VERSION
16
+ program :description, 'MDQ SAML metadata client'
17
+
18
+ #global_option '--verbose'
19
+
20
+ default_command :help
21
+
22
+ command :version do |c|
23
+ c.syntax = 'mdqt version'
24
+ c.description = 'Show version of MDQT'
25
+ c.action do |args, options|
26
+ options.default MDQT::CLI::Defaults.cli_defaults
27
+ options.default({ service: :not_required })
28
+ MDQT::CLI::Version.run(args, options)
29
+ end
30
+ end
31
+
32
+ command :get do |c|
33
+ c.syntax = 'mdqt get [options] entityidentifier '
34
+ c.description = 'Download one entity record or an aggregate of entity records'
35
+ c.option '--service URL', String, 'MDQ service to search for entities. Defaults to MDQT_SERVICE or MDQ_BASE_URL env variables'
36
+ c.option '--cache', "Cache downloads and try to fetch from cache where appropriate (deprecated)"
37
+ c.option '--refresh', "Never cache (will prevent --cache)"
38
+ c.option '--verify-with PATHS', Array, 'Validate downloads using specified certificates'
39
+ c.option '--validate', 'Validate downloaded metadata against SAML2 schema (not normally needed)'
40
+ #c.option '--stdin', 'accept one or more entity ids from STDIN'
41
+ c.option '--all', 'Request all entity records'
42
+ c.option '--explain', 'Show details of client request and server response'
43
+ c.option '--tls-risky', "Don't check certificate used for TLS (usually a bad idea)"
44
+ c.option '--save-to PATH', String, 'Write all data to files in the specified directory'
45
+ #c.option '--link-id', 'If saving files, save files with aliases (requires `--save-to`)'
46
+ c.option '--list', 'If saving files, print the names of files written to disk (requires `--save-to`)'
47
+ c.option '--verbose', 'Display extra information on stderr'
48
+ c.action do |args, options|
49
+ options.default MDQT::CLI::Defaults.cli_defaults
50
+ options.default({ service: MDQT::CLI::Defaults.base_url }) if options.service.to_s == ''
51
+ MDQT::CLI::Get.run(args, options)
52
+ end
53
+ end
54
+
55
+ command :reset do |c|
56
+ c.syntax = 'mdqt reset'
57
+ c.description = 'Delete all cached data'
58
+ c.option '--verbose', 'Display extra information on stderr'
59
+ c.action do |args, options|
60
+ options.default MDQT::CLI::Defaults.cli_defaults
61
+ options.default({ service: :not_required })
62
+ MDQT::CLI::Reset.run(args, options)
63
+ end
64
+ end
65
+
66
+ command :transform do |c|
67
+ c.syntax = 'mdqt transform ENTITYIDS'
68
+ c.description = 'Show transformed entity IDs'
69
+ c.option '--verbose', 'Display extra information on stderr'
70
+ c.action do |args, options|
71
+ options.default MDQT::CLI::Defaults.cli_defaults
72
+ options.default({ service: :not_required })
73
+ MDQT::CLI::Transform.run(args, options)
74
+ end
75
+ end
76
+
77
+ command :check do |c|
78
+ c.syntax = 'mdqt check XML_FILENAME [--verify-with ./CERTIFICATE_FILENAME]'
79
+ c.description = 'Validate XML and check signatures'
80
+ c.option '--verbose', 'Display extra information on stderr'
81
+ c.option '--verify-with PATHS', Array, 'Validate file using specified certificates'
82
+ c.action do |args, options|
83
+ options.default MDQT::CLI::Defaults.cli_defaults
84
+ options.default({ service: :not_required, validate: true })
85
+ MDQT::CLI::Check.run(args, options)
86
+ end
87
+ end
88
+
89
+ command :entities do |c|
90
+ c.syntax = 'mdqt entities XML_FILENAME'
91
+ c.description = 'Extract entity IDs from a metadata file'
92
+ c.option '--sha1', 'include the sha1 hash for each entity ID'
93
+ c.action do |args, options|
94
+ args = Dir.glob("*.xml") unless args && !args.empty?
95
+ options.default MDQT::CLI::Defaults.cli_defaults
96
+ options.default({ service: :not_required })
97
+ MDQT::CLI::Entities.run(args, options)
98
+ end
99
+ end
100
+
101
+ command :ln do |c|
102
+ c.syntax = 'mdqt ln XML_FILENAME'
103
+ c.description = 'Create a soft link to the file using an sha1 hash of the entityID'
104
+ c.option '--force', 'Overwrite any existing links'
105
+ c.option '--verbose', 'Display extra information on stderr'
106
+ c.action do |args, options|
107
+ options.default MDQT::CLI::Defaults.cli_defaults
108
+ options.default({ service: :not_required })
109
+ MDQT::CLI::Ln.run(args, options)
110
+ end
111
+ end
112
+
113
+ command :ls do |c|
114
+ c.syntax = 'mdqt ls XML_FILENAME/DIRECTORY'
115
+ c.description = 'List valid metadata files in directory'
116
+ c.option '--verbose', 'Display extra information on stderr'
117
+ c.action do |args, options|
118
+ options.default MDQT::CLI::Defaults.cli_defaults
119
+ options.default({ service: :not_required })
120
+ MDQT::CLI::Ls.run(args, options)
121
+ end
122
+ end
123
+
124
+ command :list do |c|
125
+ c.syntax = 'mdqt list [options]'
126
+ c.description = 'List entities available at the MDQ service'
127
+ c.option '--service URL', String, 'MDQ service to search for entities. Defaults to MDQT_SERVICE or MDQ_BASE_URL env variables'
128
+ c.option '--cache', "Cache downloads and try to fetch from cache where appropriate (deprecated)"
129
+ c.option '--refresh', "Never cache (will prevent --cache)"
130
+ c.option '--verbose', 'Display extra information on stderr'
131
+ c.action do |args, options|
132
+ options.default MDQT::CLI::Defaults.cli_defaults
133
+ options.default({ service: MDQT::CLI::Defaults.base_url }) if options.service.to_s == ''
134
+ MDQT::CLI::List.run(args, options)
135
+ end
136
+ end
137
+
138
+ command :services do |c|
139
+ c.syntax = 'mdqt services'
140
+ c.description = 'List URLs and aliases for known MDQ services'
141
+ c.action do |args, options|
142
+ options.default MDQT::CLI::Defaults.cli_defaults
143
+ options.default({ service: :not_required })
144
+ MDQT::CLI::Services.run(args, options)
145
+ end
146
+ end
147
+
148
+ command :rename do |c|
149
+ c.syntax = 'mdqt rename XML_FILENAME'
150
+ c.description = 'Rename a file using the sha1 hash of its entityID'
151
+ c.option '--force', 'Overwrite any existing files with that name'
152
+ c.option '--verbose', 'Display extra information on stderr'
153
+ c.option '--link', 'Add a symlink with the original filename'
154
+ c.action do |args, options|
155
+ options.default MDQT::CLI::Defaults.cli_defaults
156
+ options.default({ service: :not_required })
157
+ MDQT::CLI::Rename.run(args, options)
158
+ end
159
+ end
160
+
161
+ command :url do |c|
162
+ c.syntax = 'mdqt url ENTITYIDS'
163
+ c.description = 'List URLs for each entity ID at the MDQ service'
164
+ c.option '--verbose', 'Display extra information on stderr'
165
+ c.option '--service URL', String, 'MDQ service to search for entities. Defaults to MDQT_SERVICE or MDQ_BASE_URL env variables'
166
+ c.action do |args, options|
167
+ options.default MDQT::CLI::Defaults.cli_defaults
168
+ options.default({ service: MDQT::CLI::Defaults.base_url }) if options.service.to_s == ''
169
+ MDQT::CLI::URL.run(args, options)
170
+ end
171
+ end
172
+
173
+ end
174
+