rack-jive-signed_request 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d92d63dced6750397eb150a24e85ac564fd7d51f
4
- data.tar.gz: bf6f6719bc151850aa85f9aca65c971171c9cef7
3
+ metadata.gz: 9c1e5d12872f53f0d220590ff065e87d60c4cfa1
4
+ data.tar.gz: e7333566f7c0767eb1737aa7e9ec80d514c83685
5
5
  SHA512:
6
- metadata.gz: e63c392288aa7e5d43c7820dadbe82a93aeb1188f6269a971264b5513b92c9409c0c912833f6d969bd08a4a236b825f7c5db9daaf69687b9c1e51e6185a247ec
7
- data.tar.gz: ced1441b2473e208dee8c0341d2c837e1b19c5129145258a2d08d70a1a0915ca24fd1d1b792076fe1411026d5ba2cbd92c1f47cd6c24150bbbcb96cae8bc7be8
6
+ metadata.gz: 69c340d0d22e93874e4125a8c4ceb0f0013e45aba741065b32f78149a319883fb4257e6da3aa6e07640c0047a05dcb1c35d26a9b618174f3c247cb028a52e243
7
+ data.tar.gz: 0a15ed523095c97aeb615de7e13473c17ba218cfca4361f8e844a3ec9de1869bdc18e54edb8dff1f00573fece631e173deac9016ef4abe80460ba970b5f166d0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-jive-signed_request (0.1.0)
4
+ rack-jive-signed_request (0.1.1)
5
5
  jive-signed_request
6
6
  rack (>= 1.1)
7
7
 
data/README.md CHANGED
@@ -54,6 +54,10 @@ module ExampleApp
54
54
  end
55
55
  ```
56
56
 
57
+ # Usage
58
+
59
+ `request.env['jive.user_id']` will be populated with the authenticated users Jive ID
60
+
57
61
  ## Development
58
62
 
59
63
  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.
@@ -22,14 +22,12 @@ module Rack
22
22
  def call(env)
23
23
  request = Request.new(env)
24
24
 
25
- status, headers, body = @app.call(env)
26
-
27
25
  # 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/,'')
26
+ if env["X-Shindig-AuthType"] === "signed" || env["Authorization"].to_s.match(/^JiveEXTN/)
27
+ auth_header_params = ::CGI.parse env["Authorization"].gsub(/^JiveEXTN\s/,'')
30
28
 
31
29
  begin
32
- unless ::Jive::SignedRequest.authenticate(headers["Authorization"], @secret.call(auth_header_params))
30
+ unless ::Jive::SignedRequest.authenticate(env["Authorization"], @secret.call(auth_header_params))
33
31
  return [401, {"Content-Type" => "text/html"}, ["Invalid"]]
34
32
  end
35
33
  rescue ArgumentError => $e
@@ -37,7 +35,11 @@ module Rack
37
35
  end
38
36
  end
39
37
 
40
- [status, headers, body]
38
+ env["jive.user_id"] = env["X-Jive-User-ID"]
39
+ env["jive.email"] = env["X-Jive-User-Email"]
40
+ env["jive.external"] = (env["X-Jive-User-External"] === "true")
41
+
42
+ @app.call(env)
41
43
  end
42
44
 
43
45
  def secret(&block)
@@ -1,7 +1,7 @@
1
1
  module Rack
2
2
  module Jive
3
3
  class SignedRequest
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-jive-signed_request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Butch Marshall