roda 3.100.0 → 3.101.0
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 +4 -4
- data/MIT-LICENSE +1 -1
- data/lib/roda/plugins/bearer_token.rb +28 -0
- data/lib/roda/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7b1458c27a93cf829302766fa6299abadc1b52a7cc45375c23e588d0a28bbf7
|
|
4
|
+
data.tar.gz: d9312bd50698b9eba385272903d3c12a04f5d699185f299b5ddc250fdcbac2ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1483575934392739f5ee8c79cd74ca78f434ba9d798d9c2066f24f737f39fbfd0c0ad818acbd28b113ffaedf7751b3c45302ee17f8590c1dd47d6072de785453
|
|
7
|
+
data.tar.gz: 20f6bc4308bcebd17abc063c4303487d80fd2ac63a1a35b35b99ae0ed2a2a82cf2c5effb480464817a3c1fbed343006a74547743022b1b2e2717c16164f06740
|
data/MIT-LICENSE
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen-string-literal: true
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
class Roda
|
|
5
|
+
module RodaPlugins
|
|
6
|
+
# The bearer_token plugin adds an +r.bearer_token+ method for retrieving
|
|
7
|
+
# a bearer token from the +Authorization+ HTTP header. Bearer tokens will
|
|
8
|
+
# in the authorization header will be recognized as long as they start
|
|
9
|
+
# with the case insensitive string "bearer ".
|
|
10
|
+
module BearerToken
|
|
11
|
+
# :nocov:
|
|
12
|
+
METHOD = RUBY_VERSION >= "2.4" ? :match? : :match
|
|
13
|
+
# :nocov:
|
|
14
|
+
|
|
15
|
+
module RequestMethods
|
|
16
|
+
# Return the bearer token for the request if there is one in the
|
|
17
|
+
# authorization HTTP header.
|
|
18
|
+
def bearer_token
|
|
19
|
+
if (auth = @env["HTTP_AUTHORIZATION"]) && auth.send(METHOD, /\Abearer /i)
|
|
20
|
+
auth[7, 100000000]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
register_plugin(:bearer_token, BearerToken)
|
|
27
|
+
end
|
|
28
|
+
end
|
data/lib/roda/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: roda
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.101.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Evans
|
|
@@ -176,6 +176,7 @@ files:
|
|
|
176
176
|
- lib/roda/plugins/autoload_hash_branches.rb
|
|
177
177
|
- lib/roda/plugins/autoload_named_routes.rb
|
|
178
178
|
- lib/roda/plugins/backtracking_array.rb
|
|
179
|
+
- lib/roda/plugins/bearer_token.rb
|
|
179
180
|
- lib/roda/plugins/branch_locals.rb
|
|
180
181
|
- lib/roda/plugins/break.rb
|
|
181
182
|
- lib/roda/plugins/caching.rb
|