jot-helpers 1.0.0.beta1 → 1.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/jot/rails/authentication_helper.rb +6 -0
- data/lib/jot/version.rb +1 -1
- data/lib/jot-helpers.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbbe16be31ced7f4112c725850272c26bd91fbba4ba060aefc16d6b7292cc85e
|
4
|
+
data.tar.gz: c4094b3f477538683ac34be6f428ade5c4c138c290654b8ab9fe3d0814bb8c16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 343bb0e4f8a9fa376900f5a684191ff3c8582ca9c7e89edfb1732b16931e147f9fe5df9d105059abaca86c6233d32b14cdec430327610194540291fdd67da9eb
|
7
|
+
data.tar.gz: c6214640f8e904216dccb1052d14cc558181ddd0cbb7d1515bd5a5e577bb03b1a2cc09f3870574e10491b5bc42102237be65a1daaa660cabf1f88d4b1ff486b7
|
data/README.md
CHANGED
@@ -18,13 +18,13 @@ end
|
|
18
18
|
Encode a payload:
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
|
21
|
+
Jot.encode({ user_id: 1 }) # => "eyJhbGciOiJIUz..."
|
22
22
|
```
|
23
23
|
|
24
24
|
Decode a payload:
|
25
25
|
|
26
26
|
```ruby
|
27
|
-
|
27
|
+
Jot.decode("eyJhbGciOiJIUz...") # => { "user_id" => 1 }
|
28
28
|
```
|
29
29
|
|
30
30
|
Exceptions raised for invalid / expired tokens will be the same as those raised by the JWT gem.
|
@@ -1,7 +1,13 @@
|
|
1
1
|
class Jot
|
2
|
+
NoAuthorizationHeaderError = Class.new(StandardError)
|
3
|
+
|
2
4
|
module Rails
|
3
5
|
module AuthenticationHelper
|
4
6
|
def jot_decode(request)
|
7
|
+
if request.headers["Authorization"].nil?
|
8
|
+
raise NoAuthorizationHeaderError, "no Authorization header detected. Cannot decode token."
|
9
|
+
end
|
10
|
+
|
5
11
|
token = request.headers["Authorization"].split(" ").last
|
6
12
|
payload, header = Jot.decode(token)
|
7
13
|
payload
|
data/lib/jot/version.rb
CHANGED
data/lib/jot-helpers.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'jot'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jot-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -48,16 +48,17 @@ files:
|
|
48
48
|
- ".rspec"
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
|
+
- lib/jot-helpers.rb
|
51
52
|
- lib/jot.rb
|
52
53
|
- lib/jot/configuration.rb
|
53
54
|
- lib/jot/rails/authentication_helper.rb
|
54
55
|
- lib/jot/version.rb
|
55
56
|
- sig/jot.rbs
|
56
|
-
homepage: https://github.com/radar/
|
57
|
+
homepage: https://github.com/radar/jot
|
57
58
|
licenses: []
|
58
59
|
metadata:
|
59
|
-
homepage_uri: https://github.com/radar/
|
60
|
-
source_code_uri: https://github.com/radar/
|
60
|
+
homepage_uri: https://github.com/radar/jot
|
61
|
+
source_code_uri: https://github.com/radar/jot
|
61
62
|
post_install_message:
|
62
63
|
rdoc_options: []
|
63
64
|
require_paths:
|