researchable_jwt-authenticable 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/jwt_authenticable/auth.rb +8 -3
- data/lib/jwt_authenticable/exceptions.rb +7 -0
- data/lib/jwt_authenticable/version.rb +1 -1
- data/lib/jwt_authenticable.rb +3 -0
- data/node_modules/semantic-release-rubygem/src/__tests__/fixtures/valid/lib/test-gem/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abeaaf5f3a590567cc0e31b701204f3fea0ef6598fddfa03eb97dcb34beb4436
|
4
|
+
data.tar.gz: e72942114fc0c82482d01d8a6e9b8c4083fc2223466290de06e2b6ffb4c4397e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '00519275b196a8d5b2dd2d75c1a1951ed8b91076e937ed34285f768eec98365468aaa4881c9a7084c03b5d0d495b0ce70bc7ffc6ebd19148f8335a3def579ef9'
|
7
|
+
data.tar.gz: ba644ed5e3a31da8d29ca334d393857ae3abf97e9d694613b850d9ee98ddb4d27e16be5113450d9859dda256fafbb582594a9af78c07275a50d33cb4305ab63f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [1.1.0](https://gitlab.com/researchable/general/gems/jwt-authenticable/compare/v1.0.1...v1.1.0) (2023-06-30)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* enforce 2fa ([a65aed5](https://gitlab.com/researchable/general/gems/jwt-authenticable/commit/a65aed5e2ae0ad180239e51aa20dd9d2aa588e81))
|
7
|
+
|
1
8
|
## [1.0.1](https://gitlab.com/researchable/general/gems/jwt-authenticable/compare/v1.0.0...v1.0.1) (2023-06-14)
|
2
9
|
|
3
10
|
|
@@ -13,7 +13,8 @@ module JwtAuthenticable
|
|
13
13
|
# @raise MissingAuthScope if the jwt does not have the right scope
|
14
14
|
def authenticate_user!
|
15
15
|
validate_jwt_token! token: authorization_token!
|
16
|
-
rescue MissingAuth, MissingAuthScope, InvalidAuthScheme, JWT::VerificationError,
|
16
|
+
rescue MissingAuth, MissingAuthScope, InvalidAuthScheme, TwoFANotEnabledError, JWT::VerificationError,
|
17
|
+
JWT::ExpiredSignature => e
|
17
18
|
unauthorized(e.message)
|
18
19
|
end
|
19
20
|
|
@@ -28,8 +29,12 @@ module JwtAuthenticable
|
|
28
29
|
# @return [Hash] the JWT payload
|
29
30
|
def validate_jwt_token!(token:)
|
30
31
|
# NOTE: it is still safe if JWT_SECRET_KEY is not set. The method will trigger a JWT exception
|
31
|
-
JWT.decode(token, JwtAuthenticable.config.jwt_secret_key, true,
|
32
|
-
|
32
|
+
payload = JWT.decode(token, JwtAuthenticable.config.jwt_secret_key, true,
|
33
|
+
{ algorithm: algorithm }).first
|
34
|
+
|
35
|
+
raise TwoFANotEnabledError if JwtAuthenticable.config.enforce_2fa && !payload['2fa']
|
36
|
+
|
37
|
+
payload
|
33
38
|
end
|
34
39
|
|
35
40
|
# Extracts the authorization token from the Authorization header
|
@@ -47,5 +47,12 @@ module JwtAuthenticable
|
|
47
47
|
"Authorization error: #{@msg}"
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
# Exception to raise when 2fa enforce is enabled but user has not enabled 2fa
|
52
|
+
class TwoFANotEnabledError < StandardError
|
53
|
+
def message
|
54
|
+
'2FA must be enabled'
|
55
|
+
end
|
56
|
+
end
|
50
57
|
end
|
51
58
|
end
|
data/lib/jwt_authenticable.rb
CHANGED
@@ -11,6 +11,9 @@ module JwtAuthenticable
|
|
11
11
|
# Note that for RSA algorithms this will actually be the public key
|
12
12
|
setting :jwt_secret_key, default: nil
|
13
13
|
|
14
|
+
# If set to true, a jwt will only be considered valid if 2fa has been enabled
|
15
|
+
setting :enforce_2fa, default: false
|
16
|
+
|
14
17
|
SUPPORTED_ALGOS = [JWT::Algos::Hmac, JWT::Algos::Rsa].freeze
|
15
18
|
|
16
19
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: researchable_jwt-authenticable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Researchable
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -67,7 +67,7 @@ files:
|
|
67
67
|
- node_modules/semantic-release-rubygem/src/__tests__/fixtures/prerelease/lib/test-gem/version.rb
|
68
68
|
- node_modules/semantic-release-rubygem/src/__tests__/fixtures/valid/lib/test-gem/version.rb
|
69
69
|
- sig/jwt_authenticable.rbs
|
70
|
-
homepage: https://gitlab.com/researchable/general/gems/jwt-authenticable/-/blob/v1.0
|
70
|
+
homepage: https://gitlab.com/researchable/general/gems/jwt-authenticable/-/blob/v1.1.0/README.md
|
71
71
|
licenses:
|
72
72
|
- MIT
|
73
73
|
metadata:
|