alexa_verifier 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dc08649cb9ee69a9726eaa93c234b58828b26e02
4
- data.tar.gz: 09bba4949ec077e8d9041b2101ab50b78d61b8ba
2
+ SHA256:
3
+ metadata.gz: 4a87865b33c6e4c0375fa54a4f30bd5dca32077805d96ea423a6473d68fb89b2
4
+ data.tar.gz: 6c60fd2e94cb2ed120e8b0a8de761b11bb41294902d746b055a58a591318bd76
5
5
  SHA512:
6
- metadata.gz: bb68dc5d02e75887efa2771e71c94871e57b10571a0a4b27d6b348d7c775f2c89ea9226819c0579abae34747c036f2900d85f9c450a26838abc6bbe37861862e
7
- data.tar.gz: ed501217e4dc3a400a2b2ed4b04058be86894a05d4709c82c00322911ff9c6eac8812f5b4f93752c0bd77efb18f8288cc7973e2dcbcc6ac3dba5f56b1b4a466f
6
+ metadata.gz: 6a311acc8702c6a96a58e35b0b53ae64e253ae204f587ec13d6c4bf8ff5ec8be8980fa4ef2a06944f77e616a19f1993c9668426a1b5f39a2dc563f593397551b
7
+ data.tar.gz: 4ffe5912d050d2011eae964b2d579f0c200ecc99cb1a65de5e48e334710c3ea66b9b7df9cca463dd0291f09adcf9f739c3644de29353501821e697a92dad63c8
data/.gitignore CHANGED
@@ -1,9 +1,10 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
9
+ .rspec_status
10
+ Gemfile.lock
@@ -0,0 +1,2 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
2
  --color
3
+ --require spec_helper
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ Exclude:
3
+ - spec/**/*.rb
4
+
5
+ Metrics/LineLength:
6
+ Enabled: false
7
+
8
+ Style/FrozenStringLiteralComment:
9
+ Enabled: false
10
+
11
+ # We want to maintain compatibility with Ruby 2.0+, safe nav is a 2.3 feature
12
+ Style/SafeNavigation:
13
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.4.2
@@ -1,4 +1,23 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
- - 2.0.0
4
- before_install: gem install bundler -v 1.10.5
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3
8
+ - 2.4
9
+ - 2.4.2
10
+ - ruby-head
11
+
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: ruby-head
15
+
16
+ deploy:
17
+ provider: rubygems
18
+ api_key:
19
+ secure: fFDgkJ+3Uu+OCAg6o9dfw/tb1fePtHavVzkxJyb4V91iTKrzAtzZ/mSgeol7V28OOdVGSQ1sl+rkXIFe4nytDBuw7fdQxYujN+97uzTxyuX8tMUAtUjT3+6FGGCd7T2fNwaOSI50+I3pcQdr//1ZTFOZjK/lM63R2WXGgX2yDDDmgjUNMu15gUGGuVgZCNafVG74tNTGfr5CEUOMCjETq+zjytia5GbhkbE6mXgMCv5J08mv44Ustta9TF0Fj3Sg7C4wmCJtBS8SHOZVptf2NlrJBZr8ac52v+hAxC+6VC2BbhOQH2lRqlgprlWNbPkTIfzhsat4HMAj1Rk11OYnVvxGS5JWnHirlPftJ0ddtKO9z2Mj/Nhbe99GyrcSWbZtFlxLdO93Yc00N0c+TkSrnY8Cq/OabrL+HqxQnrZdMb7ZOG50nwdnRQnF3RVMTl1d1dpgawA1SrGfkEacNB+4iZ0jHj8nKOBQdaUYTYikL77WUvFdShzfZf5cRAVQTj7xyMd5pJWiTxtIeRzQgTmWFeRaVLAsvRRUoPA0npbs6J2huI34uEDWRiXwYXX7/aWkL19G69eOdSh1/19m0GsneUzeuK03VJ8H0GsG6hp+o7BpxnubkWvopldg5HGbCIWaklNoP/tMSAOKNUXVDFFnXcyLB2rlX1Y5Yt5GXSuEONY=
20
+ gem: alexa_verifier
21
+ on:
22
+ tags: true
23
+ repo: sidoh/alexa_verifier
@@ -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 m@rayner.io. 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 CHANGED
@@ -1,4 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
3
5
  # Specify your gem's dependencies in alexa_verifier.gemspec
4
6
  gemspec
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2015 Christopher
3
+ Copyright (c) 2017 Matt Rayner
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
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.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,2 +1,209 @@
1
- # alexa_verifier
2
- Rubygem to verify requests sent to an Alexa skill are sent from Amazon
1
+ # Alexa Verifier
2
+
3
+ [AlexaVerifier][alexa_verifier] is a gem created to verify that requests received within a [Rack][rack]-based application originate from Amazon's Alexa API.
4
+
5
+ This gem is framework agnostic and should work with any Rack based application including both [Rails][rails] and [Sinatra][sinatra].
6
+
7
+ [![Gem Version][shield-gem]][info-gem] [![Build Status][shield-travis]][info-travis] [![Code Coverage][shield-coveralls]][info-coveralls] [![License][shield-license]][info-license]
8
+
9
+ ## Contents
10
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
11
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
12
+
13
+
14
+ - [Requirements](#requirements)
15
+ - [Installation](#installation)
16
+ - [Usage](#usage)
17
+ - [Methods](#methods)
18
+ - [Disabling checks](#disabling-checks)
19
+ - [Examples](#examples)
20
+ - [Globally](#globally)
21
+ - [Instance level](#instance-level)
22
+ - [With a block](#with-a-block)
23
+ - [Calling `#configure`](#calling-configure)
24
+ - [Handling errors](#handling-errors)
25
+ - [Getting Started with Development](#getting-started-with-development)
26
+ - [Running the tests](#running-the-tests)
27
+ - [Contributing](#contributing)
28
+ - [License](#license)
29
+ - [Code of Conduct](#code-of-conduct)
30
+
31
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
32
+
33
+
34
+ ## Requirements
35
+ [AlexaVerifier][alexa_verifier] requires the following:
36
+ * [Ruby][ruby] - version 2.0 or greater
37
+
38
+
39
+ ## Installation
40
+
41
+ Add this line to your application's Gemfile:
42
+
43
+ ```ruby
44
+ gem 'alexa_verifier'
45
+ ```
46
+
47
+
48
+ ## Usage
49
+ This gem's main function is taking an [Rack][rack] request and verifying that it was sent by Amazon.
50
+
51
+ ### Sinatra
52
+ ```ruby
53
+ # within server.rb (or equivalent)
54
+
55
+ post '/' do
56
+ AlexaVerifier.valid!(request)
57
+ end
58
+ ```
59
+
60
+
61
+ ### Rails
62
+ ```ruby
63
+ # config/routes.rb
64
+
65
+ post '/', to: 'alexa#index'
66
+ ```
67
+
68
+ ```ruby
69
+ # app/controllers/alexa_controller.rb
70
+
71
+ class AlexaController < ApplicationController
72
+ skip_before_action :verify_authenticity_token, only: :index
73
+
74
+ def index
75
+ AlexaVerifier.valid!(request)
76
+ end
77
+ end
78
+ ```
79
+
80
+ ### Methods
81
+ [AlexaVerifier][alexa_verifier] has two main entry points, detailsed below:
82
+
83
+ Method | Parameter type | Returns
84
+ ---|---|---
85
+ `AlexaVerifier.valid!(request)` | Rack-based request object | `true` on successful verification. Raises an error if unsuccessful.
86
+ `AlexaVerifier.valid?(request)` | Rack-based request object | `true` on successful verificatipn. `false` if unsuccessful.
87
+
88
+ You are also able to configure [AlexaVerifier][alexa_verifier] to disable some checks. This is detailed in the section below.
89
+
90
+
91
+ ### Disabling checks
92
+ If you'd like to disable one (or more) of the checks performed by [AlexaVerifier][alexa_verifier], you can do so by passing a #configure block. Each of the configuration attributes are Boolean values and are detailed below.
93
+
94
+ It is possible to disable checks either globally, or for a specific instance. This is useful if you want to run multiple instances of the verifier within your application.
95
+
96
+ Option | Default | Description
97
+ ---|---|---
98
+ `enabled` | `true` | Enables or disables AlexaVerifier checks. This setting overrides all others i.e. setting `config.enabled = false` disables all checks even if you set others to true.
99
+ `verify_uri` | `true` | Enables or disables checks on the certificate URI. Set to `false` to allow serving of certificates from non-amazon approved domains.
100
+ `verify_timeliness` | `true` | Enables or disables timeliness checks. Set to `false` to allow requests generated in the past to be executed. Good for serving test requests.
101
+ `verify_certificate` | `true` | Enables or disabled checks on whether the certificate is in date, or contains the SAN address we expect.
102
+ `verify_signature` | `true` | Enables or disables checks to see if a request was actually signed by a certificate.
103
+
104
+ #### Examples
105
+ The below is an example of a 'complete' configure block, setting attributes both globally and for an individual instance.
106
+
107
+ ##### Globally
108
+ ```ruby
109
+ AlexaVerifier.configure do |config|
110
+ config.enabled = false # Disables all checks, even though we enable them individually below
111
+ config.verify_uri = true
112
+ config.verify_timeliness = true
113
+ config.verify_certificate = true
114
+ config.verify_signature = true
115
+ end
116
+ AlexaVerifier.valid!(request)
117
+ ```
118
+
119
+ ##### Instance level
120
+ ###### With a block
121
+ ```ruby
122
+ verifier = AlexaVerifier::Verifier.new do |config|
123
+ config.enabled = false
124
+ config.verify_uri = true
125
+ config.verify_timeliness = true
126
+ config.verify_certificate = true
127
+ config.verify_signature = true
128
+ end
129
+ verifier.valid!(request)
130
+ ```
131
+
132
+ ###### Calling `#configure`
133
+ ```ruby
134
+ verifier = AlexaVerifier::Verifier.new
135
+ verifier.configure do |config|
136
+ config.enabled = false
137
+ config.verify_uri = true
138
+ config.verify_timeliness = true
139
+ config.verify_certificate = true
140
+ config.verify_signature = true
141
+ end
142
+ verifier.valid!(request)
143
+ ```
144
+
145
+
146
+ ### Handling errors
147
+ AlexaVerifier#valid! will raise one of the following *expected* errors if verification cannot be performed.
148
+
149
+ > Please note that all errors come with (hopefully) helpful accompanying messages.
150
+
151
+ Error | Description
152
+ ---|---
153
+ `AlexaVerifier::InvalidCertificateURIError` | Raised when the certificate URI does not pass validation.
154
+ `AlexaVerifier::InvalidCertificateError` | Raised when the certificate itself does not pass validation e.g. out of date, does not contain the requires SAN extension, etc.
155
+ `AlexaVerifier::InvalidRequestError` | Raised when the request cannot be verified (not timely, not signed with the certificate, etc.)
156
+
157
+
158
+ ## Getting Started with Development
159
+ To clone the repository and set up the dependencies, run the following:
160
+ ```bash
161
+ git clone https://github.com/mattrayner/alexa_verifier.git
162
+ cd alexa_verifier
163
+ bundle install
164
+ ```
165
+
166
+ ### Running the tests
167
+ We use [RSpec][rspec] as our testing framework and tests can be run using:
168
+ ```bash
169
+ bundle exec rake
170
+ ```
171
+
172
+
173
+ ## Contributing
174
+ If you wish to submit a bug fix or feature, you can create a pull request and it will be merged pending a code review.
175
+
176
+ 1. Fork the repository
177
+ 1. Create your feature branch (`git checkout -b my-new-feature`)
178
+ 1. Commit your changes (`git commit -am 'Add some feature'`)
179
+ 1. Push to the branch (`git push origin my-new-feature`)
180
+ 1. Ensure your changes are tested using [Rspec][rspec]
181
+ 1. Create a new Pull Request
182
+
183
+
184
+ ## License
185
+ [AlexaVerifier][alexa_verifier] is licensed under the [MIT][info-license].
186
+
187
+
188
+ ## Code of Conduct
189
+ Everyone interacting in the AlexaVerifier project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct][code_of_conduct].
190
+
191
+ [alexa_verifier]: https://github.com/sidoh/alexa_verifier
192
+ [ruby]: http://ruby-lang.org
193
+ [rack]: https://rack.github.io
194
+ [rails]: http://rubyonrails.org
195
+ [sinatra]: http://sinatrarb.com
196
+ [rspec]: http://rspec.info
197
+ [code_of_conduct]: https://github.com/mattrayner/alexa_verifier/blob/master/CODE_OF_CONDUCT.md
198
+
199
+ [info-gem]: https://rubygems.org/gems/alexa_verifier
200
+ [shield-gem]: https://img.shields.io/gem/v/alexa_verifier.svg
201
+
202
+ [info-travis]: https://travis-ci.org/sidoh/alexa_verifier
203
+ [shield-travis]: https://img.shields.io/travis/sidoh/alexa_verifier.svg
204
+
205
+ [info-coveralls]: https://coveralls.io/github/sidoh/alexa_verifier
206
+ [shield-coveralls]: https://img.shields.io/coveralls/github/sidoh/alexa_verifier.svg
207
+
208
+ [info-license]: https://github.com/sidoh/alexa_verifier/blob/master/LICENSE
209
+ [shield-license]: https://img.shields.io/badge/license-MIT-blue.svg
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,27 +1,31 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- require 'alexa_verifier'
3
+ require 'alexa_verifier/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
- spec.name = "alexa_verifier"
6
+ spec.name = 'alexa_verifier'
9
7
  spec.version = AlexaVerifier::VERSION
10
- spec.authors = ["Christopher Mullins"]
11
- spec.email = ["chris@sidoh.org"]
8
+ spec.authors = ['Christopher Mullins', 'Matt Rayner']
9
+ spec.email = %w[chris@sidoh.org m@rayner.io]
12
10
 
13
- spec.summary = %q{Verifies requests sent to an Alexa skill are sent from Amazon}
14
- spec.homepage = "http://www.github.com/sidoh/alexa_verifier"
15
- spec.license = "MIT"
11
+ spec.summary = 'Verify HTTP requests sent to an Alexa skill are sent from Amazon.'
12
+ spec.description = 'This gem is designed to work with Rack applications that serve as back-ends for Amazon Alexa skills.'
13
+ spec.homepage = 'https://github.com/sidoh/alexa_verifier'
14
+ spec.license = 'MIT'
16
15
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
19
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
21
22
 
22
- spec.add_development_dependency "bundler", "~> 1.10"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec"
25
- spec.add_development_dependency "curb", "~> 0.7.16"
26
- spec.add_development_dependency "webmock"
23
+ spec.add_development_dependency 'bundler', '~> 1.16'
24
+ spec.add_development_dependency 'coveralls', '~> 0.8.21'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_development_dependency 'simplecov', '~> 0.14'
28
+ spec.add_development_dependency 'timecop', '~> 0.9'
29
+ spec.add_development_dependency 'vcr', '~> 3.0'
30
+ spec.add_development_dependency 'webmock', '~> 3.0'
27
31
  end