usps-jwt_auth 1.0.0.pre.rc.1 → 1.0.0.pre.rc.2
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/Gemfile.lock +1 -1
- data/lib/usps/jwt_auth/concern.rb +19 -4
- data/lib/usps/jwt_auth/incorrect_login.rb +7 -0
- data/lib/usps/jwt_auth/version.rb +1 -1
- data/lib/usps/jwt_auth.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 71ef9d51e59a0dea30294ac18846b64c4bc9bbf60023d497d6eac38fbcfda5d1
|
|
4
|
+
data.tar.gz: dae70a2acb6d3a363ed3f597986dc05336a3707f81ebd06fc2b859eb51c34aad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: baca203a5bffd8bfcec36f9308c8bafb34420756290a61adad7e74b6e5652bec2d5a3b1e439407598ed9f24f69a9d835b641a343e344f560290793df12a5da9f
|
|
7
|
+
data.tar.gz: da388afd9815b8d535ff9f57a6d7cf61f48849e4538360e84e390e523fff88fa2aed340a82f43a154ea486449a167feaed335ef919a0f0cc39a262eb15d8c111
|
data/Gemfile.lock
CHANGED
|
@@ -5,6 +5,7 @@ module Usps
|
|
|
5
5
|
# Controller helpers for handling JWT authentication
|
|
6
6
|
#
|
|
7
7
|
module Concern
|
|
8
|
+
# Gem rspec skips this block
|
|
8
9
|
if defined?(ActiveSupport::Concern)
|
|
9
10
|
extend ActiveSupport::Concern
|
|
10
11
|
|
|
@@ -41,7 +42,7 @@ module Usps
|
|
|
41
42
|
###############
|
|
42
43
|
|
|
43
44
|
def current_user_from_jwt
|
|
44
|
-
reset_session if params
|
|
45
|
+
reset_session if params.key?(:logout)
|
|
45
46
|
return if set_new_jwt
|
|
46
47
|
|
|
47
48
|
load_current_user if fetch_jwt.present?
|
|
@@ -67,11 +68,13 @@ module Usps
|
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
def set_new_jwt
|
|
70
|
-
return if params[:jwt].blank?
|
|
71
|
+
return if params[:jwt].blank? || @set_new_jwt
|
|
71
72
|
|
|
72
73
|
store_jwt(params[:jwt])
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
ensure_valid_jwt_has_valid_member!
|
|
75
|
+
|
|
76
|
+
redirect_to(params[:path] || root_path)
|
|
77
|
+
@set_new_jwt = true
|
|
75
78
|
end
|
|
76
79
|
|
|
77
80
|
def store_jwt(token)
|
|
@@ -101,6 +104,8 @@ module Usps
|
|
|
101
104
|
end
|
|
102
105
|
|
|
103
106
|
def redirect_to_login
|
|
107
|
+
return if @set_new_jwt
|
|
108
|
+
|
|
104
109
|
url = 'https://www.usps.org/jwt'
|
|
105
110
|
local = "#{url}?local&port=#{ENV.fetch('PORT', '3000')}"
|
|
106
111
|
production = "#{url}?application=#{JwtAuth.config.audience}"
|
|
@@ -110,6 +115,16 @@ module Usps
|
|
|
110
115
|
redirect_to(url, allow_other_host: true)
|
|
111
116
|
end
|
|
112
117
|
|
|
118
|
+
def ensure_valid_jwt_has_valid_member!
|
|
119
|
+
fetch_jwt
|
|
120
|
+
jwt_user
|
|
121
|
+
rescue ActiveRecord::RecordNotFound
|
|
122
|
+
reset_session
|
|
123
|
+
clear_jwt
|
|
124
|
+
@current_user = nil
|
|
125
|
+
raise IncorrectLogin, 'Valid login without valid member record'
|
|
126
|
+
end
|
|
127
|
+
|
|
113
128
|
def stub_jwt!
|
|
114
129
|
raise 'Cannot stub JWT outside of test environment!' unless JwtAuth.config.environment.test?
|
|
115
130
|
|
data/lib/usps/jwt_auth.rb
CHANGED
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: 1.0.0.pre.rc.
|
|
4
|
+
version: 1.0.0.pre.rc.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -86,6 +86,7 @@ files:
|
|
|
86
86
|
- lib/usps/jwt_auth/config.rb
|
|
87
87
|
- lib/usps/jwt_auth/decode.rb
|
|
88
88
|
- lib/usps/jwt_auth/encode.rb
|
|
89
|
+
- lib/usps/jwt_auth/incorrect_login.rb
|
|
89
90
|
- lib/usps/jwt_auth/railtie.rb
|
|
90
91
|
- lib/usps/jwt_auth/version.rb
|
|
91
92
|
- sig/usps_jwt/auth.rbs
|