usps-jwt_auth 0.0.12 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08b2986886329a7add9ad0cb47b90a1daaa870b2ade79072c20e650dbef455b7'
4
- data.tar.gz: c52a9a66374742a3fedd25149b4b7394c2568c9c6eaca89f4c3259f9e184707d
3
+ metadata.gz: 4ba26d6eaed75b285ebfc99c508c1293fcfa256829ec0bfdd8aae3d53bb32614
4
+ data.tar.gz: 0f4798665bd519bf0b09da6ff765fb656b4cbd634cfa14d0fe02b9277567bba7
5
5
  SHA512:
6
- metadata.gz: 87346a7fb222c2a4348623971b3e095db84780e2580317901677bfd2e972a2fed15a3abdd9810c153dd0ca1997a64c41f5f6aff2021ad277119ddfe463d371c3
7
- data.tar.gz: 7c0055bf8e118d80e333e28c7e5a5a0f49955f066fe7a177c8882e6db7207519a95a639ac130dfa036e11f73e1a5c6bdf3cdef687ea427863b653e9a9b54395b
6
+ metadata.gz: ee25cbc235574214e7a6584f6ec2adc69adf79393307b96f6e5b2e0fe884c9c73a1b5ce4b06c6772e4719eb3b070fdc1d093328a99c9b199932e929c29c14b43
7
+ data.tar.gz: 11c096d289512d8650e82b4ca5e9ec2ac03344cd0d7d70ec12375405d7aac292dab3f910b276eddeb8d4f8b874a9f6cde31e5edc99eea4ebbef54464403195c3
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  Add the gem to your Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'usps-jwt_auth', '>= 0.0.12'
10
+ gem 'usps-jwt_auth', '>= 0.1.0'
11
11
  ```
12
12
 
13
13
  Then run the install task:
@@ -29,6 +29,9 @@ Usps::JwtAuth.configure do |config|
29
29
  issuer_base: ENV.fetch('JWT_ISSUER_BASE', 'usps:1'),
30
30
  issuers: ENV.fetch('JWT_ISSUERS', 'admin:1').split(',')
31
31
  }
32
+
33
+ config.is_admin = ->(user) { Pundit.policy(user, :admin).admin? }
34
+ config.find_member = ->(certificate) { Members::Member.find(certificate) }
32
35
  end
33
36
  ```
34
37
 
@@ -49,10 +49,10 @@ module Usps
49
49
 
50
50
  def load_current_user
51
51
  @current_user = jwt_user
52
- return @current_user unless Pundit.policy(@current_user, :admin).admin? && session.key?('impersonate')
52
+ return @current_user unless JwtAuth.configuration.is_admin.call(@current_user) && session.key?('impersonate')
53
53
 
54
54
  # Admin has entered impersonation mode -- override current_user
55
- @current_user = Members::Member.find(session['impersonate']['impersonated'])
55
+ @current_user = JwtAuth.configuration.find_member.call(session['impersonate']['impersonated'])
56
56
  rescue JWT::ExpiredSignature
57
57
  clear_jwt
58
58
  nil
@@ -63,7 +63,7 @@ module Usps
63
63
  end
64
64
 
65
65
  def jwt_user
66
- @jwt_user ||= Members::Member.find(jwt['certificate']) if fetch_jwt
66
+ @jwt_user ||= JwtAuth.configuration.find_member.call(jwt['certificate']) if fetch_jwt
67
67
  end
68
68
 
69
69
  def set_new_jwt
@@ -5,7 +5,7 @@ module Usps
5
5
  # Configure JWT Authentication
6
6
  #
7
7
  class Config
8
- attr_accessor :environment
8
+ attr_accessor :environment, :is_admin, :find_member
9
9
  attr_writer :key_size
10
10
  attr_reader :keys_path, :public_keys_path, :jwt
11
11
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module JwtAuth
5
- VERSION = '0.0.12'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander