warden-jwt_auth 0.1.4 → 0.2.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/.rubocop.yml +2 -0
- data/CHANGELOG.md +7 -0
- data/README.md +1 -1
- data/lib/warden/jwt_auth/errors.rb +4 -0
- data/lib/warden/jwt_auth/strategy.rb +2 -2
- data/lib/warden/jwt_auth/user_decoder.rb +8 -2
- data/lib/warden/jwt_auth/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a2ccfa065ae0684252e27bb7ec7e96ecf0d707d
|
4
|
+
data.tar.gz: c0a21d42ab4f41891f7a9cadd6edb273c2821dc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ce27233145e6481666a408fc2d92066364a04601a127b3b92fc7100aec4318afb077c7909ed3b6a7b5cf66983d82b5111aa67b234c0e7baa32791f10c11dfdd
|
7
|
+
data.tar.gz: 9b423f5b1f7304f91bc88385fbf451cab180c2cb7673071dcf98d594dada87a68398d5876a639a2e38baccc2bc89e02a88c47aa0427d414a83ec01b5a4039d07
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [0.2.0] - 2017-11-23
|
8
|
+
### Added
|
9
|
+
- `fail!` with message
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- Unauthorize when fetched user is nil
|
13
|
+
|
7
14
|
## [0.1.4] - 2017-11-21
|
8
15
|
### Fixed
|
9
16
|
- Update `jwt` dependency
|
data/README.md
CHANGED
@@ -8,6 +8,10 @@ module Warden
|
|
8
8
|
class RevokedToken < JWT::DecodeError
|
9
9
|
end
|
10
10
|
|
11
|
+
# Error raised when the user decoded from a token is nil
|
12
|
+
class NilUser < JWT::DecodeError
|
13
|
+
end
|
14
|
+
|
11
15
|
# Error raised when trying to decode a token for an scope that doesn't
|
12
16
|
# match the one encoded in the payload
|
13
17
|
class WrongScope < JWT::DecodeError
|
@@ -24,13 +24,14 @@ module Warden
|
|
24
24
|
# @return [Interfaces::User] an user, whatever it is
|
25
25
|
# @raise [Errors::RevokedToken] when token has been revoked for the
|
26
26
|
# encoded user
|
27
|
+
# @raise [Errors::NilUser] when decoded user is nil
|
27
28
|
# @raise [Errors::WrongScope] when encoded scope does not match with scope
|
28
29
|
# argument
|
29
30
|
def call(token, scope)
|
30
31
|
payload = TokenDecoder.new.call(token)
|
31
|
-
raise Errors::WrongScope unless helper.scope_matches?(payload, scope)
|
32
|
+
raise Errors::WrongScope, 'wrong scope' unless helper.scope_matches?(payload, scope)
|
32
33
|
user = helper.find_user(payload)
|
33
|
-
|
34
|
+
check_valid_user(payload, user, scope)
|
34
35
|
user
|
35
36
|
end
|
36
37
|
|
@@ -40,6 +41,11 @@ module Warden
|
|
40
41
|
strategy = revocation_strategies[scope]
|
41
42
|
strategy.jwt_revoked?(payload, user)
|
42
43
|
end
|
44
|
+
|
45
|
+
def check_valid_user(payload, user, scope)
|
46
|
+
raise Errors::NilUser, 'nil user' unless user
|
47
|
+
raise Errors::RevokedToken, 'revoked token' if revoked?(payload, user, scope)
|
48
|
+
end
|
43
49
|
end
|
44
50
|
end
|
45
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden-jwt_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Busqué
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|