rack-jive-signed_request 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +46 -0
- data/LICENSE.txt +21 -0
- data/README.md +71 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/rack/jive/signed_request.rb +51 -0
- data/lib/rack/jive/signed_request/version.rb +7 -0
- data/rack-jive-signed_request.gemspec +28 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d92d63dced6750397eb150a24e85ac564fd7d51f
|
4
|
+
data.tar.gz: bf6f6719bc151850aa85f9aca65c971171c9cef7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e63c392288aa7e5d43c7820dadbe82a93aeb1188f6269a971264b5513b92c9409c0c912833f6d969bd08a4a236b825f7c5db9daaf69687b9c1e51e6185a247ec
|
7
|
+
data.tar.gz: ced1441b2473e208dee8c0341d2c837e1b19c5129145258a2d08d70a1a0915ca24fd1d1b792076fe1411026d5ba2cbd92c1f47cd6c24150bbbcb96cae8bc7be8
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
group :test do
|
4
|
+
gem 'json', '>= 1.8.1', :platforms => [:jruby, :ruby_18, :ruby_19]
|
5
|
+
gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
|
6
|
+
gem 'rack-test'
|
7
|
+
end
|
8
|
+
|
9
|
+
# Specify your gem's dependencies in rack-jive-signed_request.gemspec
|
10
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rack-jive-signed_request (0.1.0)
|
5
|
+
jive-signed_request
|
6
|
+
rack (>= 1.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.2.5)
|
12
|
+
jive-signed_request (0.1.1)
|
13
|
+
json (1.8.3)
|
14
|
+
mime-types (1.25.1)
|
15
|
+
rack (1.6.4)
|
16
|
+
rack-test (0.6.3)
|
17
|
+
rack (>= 1.0)
|
18
|
+
rake (10.4.2)
|
19
|
+
rspec (3.4.0)
|
20
|
+
rspec-core (~> 3.4.0)
|
21
|
+
rspec-expectations (~> 3.4.0)
|
22
|
+
rspec-mocks (~> 3.4.0)
|
23
|
+
rspec-core (3.4.1)
|
24
|
+
rspec-support (~> 3.4.0)
|
25
|
+
rspec-expectations (3.4.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.4.0)
|
28
|
+
rspec-mocks (3.4.0)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.4.0)
|
31
|
+
rspec-support (3.4.1)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler (~> 1.10)
|
38
|
+
json (>= 1.8.1)
|
39
|
+
mime-types (~> 1.25)
|
40
|
+
rack-jive-signed_request!
|
41
|
+
rack-test
|
42
|
+
rake (~> 10.0)
|
43
|
+
rspec
|
44
|
+
|
45
|
+
BUNDLED WITH
|
46
|
+
1.10.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Butch Marshall
|
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/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/rack-jive-signed_request.svg)](http://badge.fury.io/rb/rack-jive-signed_request)
|
2
|
+
[![Build Status](https://travis-ci.org/butchmarshall/rack-jive-signed_request.svg?branch=master)](https://travis-ci.org/butchmarshall/rack-jive-signed_request)
|
3
|
+
|
4
|
+
# Jive Signed Request Middleware
|
5
|
+
|
6
|
+
`Rack::Jive::SignedRequest` provides support for handling [Jive](https://www.jivesoftware.com/) signed requests in Rack compatible applications.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'rack-jive-signed_request', :require => 'rack-jive-signed_request'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install rack-jive-signed_request
|
23
|
+
|
24
|
+
# Configuration
|
25
|
+
|
26
|
+
## Rack
|
27
|
+
|
28
|
+
In the `config.ru`
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
use Rack::Jive::SignedRequest
|
32
|
+
# Your app might support multiple Jive instances
|
33
|
+
# This block allows you to determine what secret to use based on the Authorization header
|
34
|
+
secret do |auth_header_params|
|
35
|
+
"this_should_be_the_app_secret_for_authentication_header_params"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Rails
|
41
|
+
|
42
|
+
In `config/application.rb`
|
43
|
+
```ruby
|
44
|
+
module ExampleApp
|
45
|
+
class Application < Rails::Application
|
46
|
+
config.middleware.use "Rack::Jive::SignedRequest" do
|
47
|
+
# Your app might support multiple Jive instances
|
48
|
+
# This block allows you to determine what secret to use based on the Authorization header
|
49
|
+
secret do |auth_header_params|
|
50
|
+
"this_should_be_the_app_secret_for_authentication_header_params"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
## Development
|
58
|
+
|
59
|
+
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.
|
60
|
+
|
61
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rack-jive-signed_request.
|
66
|
+
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
71
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rack/jive/signed_request"
|
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,51 @@
|
|
1
|
+
require "rack"
|
2
|
+
require "rack/request"
|
3
|
+
require "rack/jive/signed_request/version"
|
4
|
+
|
5
|
+
require "jive/signed_request"
|
6
|
+
|
7
|
+
module Rack
|
8
|
+
module Jive
|
9
|
+
class SignedRequest
|
10
|
+
def initialize(app, opts={}, &block)
|
11
|
+
@app = app
|
12
|
+
|
13
|
+
if block_given?
|
14
|
+
if block.arity == 1
|
15
|
+
block.call(self)
|
16
|
+
else
|
17
|
+
instance_eval(&block)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def call(env)
|
23
|
+
request = Request.new(env)
|
24
|
+
|
25
|
+
status, headers, body = @app.call(env)
|
26
|
+
|
27
|
+
# Only bother authenticating if the request is identifying itself as signed
|
28
|
+
if headers["X-Shindig-AuthType"] === "signed" || headers["Authorization"].to_s.match(/^JiveEXTN/)
|
29
|
+
auth_header_params = ::CGI.parse headers["Authorization"].gsub(/^JiveEXTN\s/,'')
|
30
|
+
|
31
|
+
begin
|
32
|
+
unless ::Jive::SignedRequest.authenticate(headers["Authorization"], @secret.call(auth_header_params))
|
33
|
+
return [401, {"Content-Type" => "text/html"}, ["Invalid"]]
|
34
|
+
end
|
35
|
+
rescue ArgumentError => $e
|
36
|
+
return [401, {"Content-Type" => "text/html"}, [$e.message]]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
[status, headers, body]
|
41
|
+
end
|
42
|
+
|
43
|
+
def secret(&block)
|
44
|
+
@secret = block
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Request < ::Rack::Request
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rack/jive/signed_request/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rack-jive-signed_request"
|
8
|
+
spec.version = Rack::Jive::SignedRequest::VERSION
|
9
|
+
spec.authors = ["Butch Marshall"]
|
10
|
+
spec.email = ["butch.a.marshall@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Rack middleware for Jive signed requests.}
|
13
|
+
spec.description = %q{Authenticates signed server requests from Jive and resolves the Jive instance user.}
|
14
|
+
spec.homepage = "https://github.com/butchmarshall/rack-jive-signed_request"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
|
26
|
+
spec.add_runtime_dependency "rack", ">= 1.1"
|
27
|
+
spec.add_runtime_dependency "jive-signed_request"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-jive-signed_request
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Butch Marshall
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jive-signed_request
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Authenticates signed server requests from Jive and resolves the Jive
|
84
|
+
instance user.
|
85
|
+
email:
|
86
|
+
- butch.a.marshall@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- lib/rack/jive/signed_request.rb
|
101
|
+
- lib/rack/jive/signed_request/version.rb
|
102
|
+
- rack-jive-signed_request.gemspec
|
103
|
+
homepage: https://github.com/butchmarshall/rack-jive-signed_request
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.4.8
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Rack middleware for Jive signed requests.
|
127
|
+
test_files: []
|