rack-slack_request_verification 1.0.0.pre → 1.0.0.pre2
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 611a7a94c26a77aa4271271bc7ec8c2f0687b67ed9a7d2285f3eacae307aec37
|
4
|
+
data.tar.gz: 78d01fc1898076ebc9a3884fcc683753c073a89f593c26c3171963c0a821f9e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef98e09441fac16dfd696e220de7b72b3904f8d069c1c683a720f6a76ca95136f9a491ffe92e168158f4ab3f61c559a04d2a98f45be2682611b19bd0b3ae5234
|
7
|
+
data.tar.gz: 780f5340ca7a852fd29482a1b8927500feb02b047b9f0bc9a602e3543030cc7b6099bb38e4870b4bb44b7fad88eecb7715d6619ba3bd9892211a26c8f96e7787
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,12 +28,12 @@ use Rack::SlackRequestVerification, path_pattern: %{^/slack/}
|
|
28
28
|
run MyApp
|
29
29
|
```
|
30
30
|
|
31
|
-
Will use a `
|
31
|
+
Will use a `SLACK_SIGNING_SECRET` environment variable by default.
|
32
32
|
|
33
33
|
You can override this with:
|
34
34
|
|
35
35
|
```ruby
|
36
|
-
use Rack::SlackRequestVerification, path_pattern: %{^/slack/},
|
36
|
+
use Rack::SlackRequestVerification, path_pattern: %{^/slack/}, signing_secret: '...'
|
37
37
|
```
|
38
38
|
|
39
39
|
A **401 Not Authorized** is returned in the following circumstances:
|
@@ -51,10 +51,10 @@ use Rack::SlackRequestVerification, {
|
|
51
51
|
# A regular expression used to determine which requests to verify
|
52
52
|
path_pattern: %r{^/slack/},
|
53
53
|
|
54
|
-
# You can provide a signing
|
55
|
-
# or customise the env var to something else
|
56
|
-
|
57
|
-
|
54
|
+
# You can provide a signing secret directly, set a SLACK_SIGNING_SECRET
|
55
|
+
# env var or customise the env var to something else
|
56
|
+
signing_secret: nil,
|
57
|
+
signing_secret_env_var: 'SLACK_SIGNING_SECRET',
|
58
58
|
|
59
59
|
# Mitigates replay attacks by verifying the request was sent recently –
|
60
60
|
# a better strategy is to record the signature header to ensure you only
|
@@ -4,7 +4,7 @@ require 'forwardable'
|
|
4
4
|
module Rack::SlackRequestVerification
|
5
5
|
class ComputedSignature
|
6
6
|
extend Forwardable
|
7
|
-
def_delegators :@config, :
|
7
|
+
def_delegators :@config, :signing_secret, :signing_version
|
8
8
|
def_delegators :@request, :body, :timestamp
|
9
9
|
|
10
10
|
def initialize(request)
|
@@ -27,7 +27,7 @@ module Rack::SlackRequestVerification
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def digest
|
30
|
-
OpenSSL::HMAC.hexdigest("SHA256",
|
30
|
+
OpenSSL::HMAC.hexdigest("SHA256", signing_secret, signature_base_string)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -3,7 +3,7 @@ require 'logger'
|
|
3
3
|
module Rack::SlackRequestVerification
|
4
4
|
class Configuration
|
5
5
|
attr_reader *%i(
|
6
|
-
|
6
|
+
signing_secret
|
7
7
|
path_pattern
|
8
8
|
signing_version
|
9
9
|
timestamp_header
|
@@ -17,10 +17,10 @@ module Rack::SlackRequestVerification
|
|
17
17
|
# A regular expression used to determine which requests to verify
|
18
18
|
path_pattern:,
|
19
19
|
|
20
|
-
# You can provide a signing
|
21
|
-
# or customise the env var to something else
|
22
|
-
|
23
|
-
|
20
|
+
# You can provide a signing secret directly, set a SLACK_SIGNING_SECRET
|
21
|
+
# env var or customise the env var to something else
|
22
|
+
signing_secret: nil,
|
23
|
+
signing_secret_env_var: 'SLACK_SIGNING_SECRET',
|
24
24
|
|
25
25
|
# Mitigates replay attacks by verifying the request was sent recently –
|
26
26
|
# a better strategy is to record the signature header to ensure you only
|
@@ -46,8 +46,8 @@ module Rack::SlackRequestVerification
|
|
46
46
|
@max_staleness_in_secs = max_staleness_in_secs
|
47
47
|
@request_body_limit_in_bytes = request_body_limit_in_bytes
|
48
48
|
|
49
|
-
@
|
50
|
-
fail Error, "#{
|
49
|
+
@signing_secret = signing_secret || ENV.fetch(signing_secret_env_var) do
|
50
|
+
fail Error, "#{signing_secret_env_var} env var not set, please configure a signing secret"
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|