usps-jwt_auth 0.1.0 → 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 +4 -4
- data/README.md +3 -0
- data/lib/usps/jwt_auth/concern.rb +3 -3
- data/lib/usps/jwt_auth/config.rb +1 -1
- data/lib/usps/jwt_auth/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4ba26d6eaed75b285ebfc99c508c1293fcfa256829ec0bfdd8aae3d53bb32614
|
|
4
|
+
data.tar.gz: 0f4798665bd519bf0b09da6ff765fb656b4cbd634cfa14d0fe02b9277567bba7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee25cbc235574214e7a6584f6ec2adc69adf79393307b96f6e5b2e0fe884c9c73a1b5ce4b06c6772e4719eb3b070fdc1d093328a99c9b199932e929c29c14b43
|
|
7
|
+
data.tar.gz: 11c096d289512d8650e82b4ca5e9ec2ac03344cd0d7d70ec12375405d7aac292dab3f910b276eddeb8d4f8b874a9f6cde31e5edc99eea4ebbef54464403195c3
|
data/README.md
CHANGED
|
@@ -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
|
|
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 =
|
|
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 ||=
|
|
66
|
+
@jwt_user ||= JwtAuth.configuration.find_member.call(jwt['certificate']) if fetch_jwt
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def set_new_jwt
|
data/lib/usps/jwt_auth/config.rb
CHANGED