zaikio-jwt_auth 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e75e96ec3854a6fcaad1f5d4dcc01f92ba444741c34af7de567427cfeec6159
|
4
|
+
data.tar.gz: 9250c75142635ac6eb4a8f31f7c5b16c541493cf660bf99da268f5233ddb4485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6c823c6798566123fcf7fc20b1c40e98bc1acf00314b91e1d6b8d8b645716b347bad5179f58e002484c95945fdcafcc4a30a3f7ffe9843ca46e2ca35583d91d
|
7
|
+
data.tar.gz: 9c9ebfb94fb8b9c2f62f42a9e2bafad58918830f20463dab24dd209cf7a9a33a270f0a52b8f2ac8d2339bc71097736ada9766baadd840d671231ddbefa2a7d60
|
@@ -2,8 +2,8 @@ module Zaikio
|
|
2
2
|
module JWTAuth
|
3
3
|
class RevokeAccessTokenJob < ApplicationJob
|
4
4
|
def perform(event)
|
5
|
-
DirectoryCache.update("api/v1/
|
6
|
-
data["
|
5
|
+
DirectoryCache.update("api/v1/revoked_access_tokens.json", expires_after: 60.minutes) do |data|
|
6
|
+
data["revoked_token_ids"] << event.payload["access_token_id"]
|
7
7
|
data
|
8
8
|
end
|
9
9
|
end
|
data/lib/zaikio/jwt_auth.rb
CHANGED
@@ -26,16 +26,16 @@ module Zaikio
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.revoked_jwt?(jti)
|
29
|
-
|
29
|
+
revoked_token_ids.include?(jti)
|
30
30
|
end
|
31
31
|
|
32
|
-
def self.
|
32
|
+
def self.revoked_token_ids
|
33
33
|
return [] if mocked_jwt_payload
|
34
34
|
|
35
|
-
configuration.
|
36
|
-
"api/v1/
|
35
|
+
configuration.revoked_token_ids || DirectoryCache.fetch(
|
36
|
+
"api/v1/revoked_access_tokens.json",
|
37
37
|
expires_after: 60.minutes
|
38
|
-
)["
|
38
|
+
)["revoked_token_ids"]
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.included(base)
|
@@ -71,7 +71,7 @@ module Zaikio
|
|
71
71
|
|
72
72
|
token_data = TokenData.new(jwt_payload)
|
73
73
|
|
74
|
-
return if
|
74
|
+
return if show_error_if_token_is_revoked(token_data)
|
75
75
|
|
76
76
|
return if show_error_if_authorize_by_jwt_subject_type_fails(token_data)
|
77
77
|
|
@@ -84,11 +84,11 @@ module Zaikio
|
|
84
84
|
render_error("invalid_jwt") && (return)
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
87
|
+
def update_revoked_access_tokens_by_webhook
|
88
88
|
return unless params[:name] == "directory.revoked_access_token"
|
89
89
|
|
90
|
-
DirectoryCache.update("api/v1/
|
91
|
-
data["
|
90
|
+
DirectoryCache.update("api/v1/revoked_access_tokens.json", expires_after: 60.minutes) do |data|
|
91
|
+
data["revoked_token_ids"] << params[:payload][:access_token_id]
|
92
92
|
data
|
93
93
|
end
|
94
94
|
|
@@ -131,7 +131,7 @@ module Zaikio
|
|
131
131
|
render_error("unpermitted_subject")
|
132
132
|
end
|
133
133
|
|
134
|
-
def
|
134
|
+
def show_error_if_token_is_revoked(token_data)
|
135
135
|
return unless Zaikio::JWTAuth.revoked_jwt?(token_data.jti)
|
136
136
|
|
137
137
|
render_error("invalid_jwt")
|
@@ -14,11 +14,11 @@ module Zaikio
|
|
14
14
|
attr_accessor :app_name
|
15
15
|
attr_accessor :redis, :host
|
16
16
|
attr_reader :environment
|
17
|
-
attr_writer :logger, :
|
17
|
+
attr_writer :logger, :revoked_token_ids, :keys
|
18
18
|
|
19
19
|
def initialize
|
20
20
|
@environment = :sandbox
|
21
|
-
@
|
21
|
+
@revoked_token_ids = nil
|
22
22
|
end
|
23
23
|
|
24
24
|
def logger
|
@@ -34,8 +34,8 @@ module Zaikio
|
|
34
34
|
defined?(@keys) && @keys.is_a?(Proc) ? @keys.call : @keys
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
@
|
37
|
+
def revoked_token_ids
|
38
|
+
@revoked_token_ids.is_a?(Proc) ? @revoked_token_ids.call : @revoked_token_ids
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaikio-jwt_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- crispymtn
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-06-
|
13
|
+
date: 2020-06-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: oj
|