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: c12ee3b69a3ce0152c39d0af1a5af71bc79ac24651b622e7cfa411c851c8d35f
4
- data.tar.gz: 48e86c7cf283611de01b8754b5125f16545107c576a544c0c91c9d78be8ebac7
3
+ metadata.gz: 5e75e96ec3854a6fcaad1f5d4dcc01f92ba444741c34af7de567427cfeec6159
4
+ data.tar.gz: 9250c75142635ac6eb4a8f31f7c5b16c541493cf660bf99da268f5233ddb4485
5
5
  SHA512:
6
- metadata.gz: 22cbcb8445e7c8a7bc56aff7516a4dbce5f5763b41a37599fd123957950883af076f5138d40ceef37ee9a0d8d121e36adb924ac1d9d06aaf4f1df4e762cede4d
7
- data.tar.gz: 1d2d5d926d21a79eb734b6ddfd1b4c03f8b7b17b4fc8261bc11dba58722adea46340cb2901c24ac0588553a5d78048145d4ded1e84333246db4e9dfa023b8ca3
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/blacklisted_access_tokens.json", expires_after: 60.minutes) do |data|
6
- data["blacklisted_token_ids"] << event.payload["access_token_id"]
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
@@ -26,16 +26,16 @@ module Zaikio
26
26
  end
27
27
 
28
28
  def self.revoked_jwt?(jti)
29
- blacklisted_token_ids.include?(jti)
29
+ revoked_token_ids.include?(jti)
30
30
  end
31
31
 
32
- def self.blacklisted_token_ids
32
+ def self.revoked_token_ids
33
33
  return [] if mocked_jwt_payload
34
34
 
35
- configuration.blacklisted_token_ids || DirectoryCache.fetch(
36
- "api/v1/blacklisted_access_tokens.json",
35
+ configuration.revoked_token_ids || DirectoryCache.fetch(
36
+ "api/v1/revoked_access_tokens.json",
37
37
  expires_after: 60.minutes
38
- )["blacklisted_token_ids"]
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 show_error_if_token_is_blacklisted(token_data)
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 update_blacklisted_access_tokens_by_webhook
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/blacklisted_access_tokens.json", expires_after: 60.minutes) do |data|
91
- data["blacklisted_token_ids"] << params[:payload][:access_token_id]
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 show_error_if_token_is_blacklisted(token_data)
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, :blacklisted_token_ids, :keys
17
+ attr_writer :logger, :revoked_token_ids, :keys
18
18
 
19
19
  def initialize
20
20
  @environment = :sandbox
21
- @blacklisted_token_ids = nil
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 blacklisted_token_ids
38
- @blacklisted_token_ids.is_a?(Proc) ? @blacklisted_token_ids.call : @blacklisted_token_ids
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
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module JWTAuth
3
- VERSION = "0.2.5".freeze
3
+ VERSION = "0.3.0".freeze
4
4
  end
5
5
  end
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.2.5
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-04 00:00:00.000000000 Z
13
+ date: 2020-06-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: oj