usps-support 0.2.60 → 0.2.61
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/app/controllers/usps/support/admins_controller.rb +1 -2
- data/app/controllers/usps/support/jwt_callbacks_controller.rb +42 -0
- data/config/routes.rb +2 -0
- data/lib/usps/support/helpers/badges_helper.rb +1 -2
- data/lib/usps/support/lib/simple_cov/uncovered_lines_formatter.rb +1 -2
- data/lib/usps/support/models/hq/shared_record.rb +1 -2
- data/lib/usps/support/version.rb +1 -1
- 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: c5df100f657cd2bf0ad1e32873c7e0cc6f2e24f828a72df32c8283e3c1fea987
|
|
4
|
+
data.tar.gz: 3d15f2808d6dfe420ad2d97897ddc4162b051d7c711e90b4e01a49865202bd13
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42c4e0226379f4960173c3000fef43c1d3a2d74c8b7087578ccb30e86ca52bc94236616be87d282895c28307cd195bd760bb2537d5dafdfacbd0e6aa23d5d5d4
|
|
7
|
+
data.tar.gz: '093a40a13f2ae5d14b99d843db8012e6bd4a96c44024aeafb855f1c00d361bbb6c43a0cae2a4b8104b25964df6bdbf956f90a84b3067462fd0ea27027e373191'
|
|
@@ -56,12 +56,11 @@ module Usps::Support
|
|
|
56
56
|
# Otherwise we render the minimal JSON shape the React admin menu expects.
|
|
57
57
|
#
|
|
58
58
|
# options is spread into the fallback render hash, so it must stay named.
|
|
59
|
-
# rubocop:disable Style/ArgumentsForwarding
|
|
59
|
+
# rubocop:disable-next Style/ArgumentsForwarding
|
|
60
60
|
def render_admin_response(status, **options)
|
|
61
61
|
return react_response!(status, **options) if respond_to?(:react_response!, true)
|
|
62
62
|
|
|
63
63
|
render(json: { status: status.to_s.upcase, toasts: [], reload: false, **options })
|
|
64
64
|
end
|
|
65
|
-
# rubocop:enable Style/ArgumentsForwarding
|
|
66
65
|
end
|
|
67
66
|
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support
|
|
4
|
+
# Receives a login token posted by an issuer's page, which keeps the token out of URLs and so out of
|
|
5
|
+
# the load balancer's access logs.
|
|
6
|
+
#
|
|
7
|
+
class JwtCallbacksController < ::ApplicationController
|
|
8
|
+
TRUSTED_ORIGINS = %w[https://www.usps.org https://admin.aws.usps.org].freeze
|
|
9
|
+
LOCAL_ORIGIN = %r{\Ahttp://localhost:\d+\z}
|
|
10
|
+
|
|
11
|
+
skip_forgery_protection # The issuer's page can't hold this application's CSRF token.
|
|
12
|
+
|
|
13
|
+
# `raise: false` because the engine also loads in applications without these filters, and this class
|
|
14
|
+
# is eager-loaded there too.
|
|
15
|
+
skip_before_action :authenticate_user_from_jwt!, raise: false
|
|
16
|
+
skip_after_action :verify_authorized, raise: false
|
|
17
|
+
|
|
18
|
+
# Prepended: the inherited filters reach `set_new_jwt`, which would log in a valid token before this ran.
|
|
19
|
+
prepend_before_action :require_trusted_origin
|
|
20
|
+
|
|
21
|
+
def create
|
|
22
|
+
token = params.expect(:jwt)
|
|
23
|
+
# Verified first, so a rejected token can't replace the session or the shared cookie. It gets a 401
|
|
24
|
+
# rather than a trip through login, which would loop on a token the login server keeps issuing.
|
|
25
|
+
return head(:unauthorized) unless ensure_valid_jwt_has_valid_member!(token)
|
|
26
|
+
|
|
27
|
+
store_jwt(token)
|
|
28
|
+
redirect_to_path!
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def require_trusted_origin
|
|
34
|
+
head(:forbidden) unless trusted_origin?
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def trusted_origin? = TRUSTED_ORIGINS.include?(request.origin) || local_origin?
|
|
38
|
+
|
|
39
|
+
# A local admin console posts from its own port.
|
|
40
|
+
def local_origin? = Usps::JwtAuth.config.environment.development? && LOCAL_ORIGIN.match?(request.origin.to_s)
|
|
41
|
+
end
|
|
42
|
+
end
|
data/config/routes.rb
CHANGED
|
@@ -13,6 +13,8 @@ Usps::Support::Engine.routes.draw do
|
|
|
13
13
|
mount sidekiq_dashboard, at: '/sidekiq', as: :sidekiq
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
post 'jwt/callback', to: 'usps/support/jwt_callbacks#create'
|
|
17
|
+
|
|
16
18
|
resource :admin, only: [], controller: 'usps/support/admins' do
|
|
17
19
|
collection do
|
|
18
20
|
post :impersonate
|
|
@@ -135,7 +135,7 @@ module Usps::Support::Helpers
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
# rubocop:disable Metrics/AbcSize
|
|
138
|
-
# rubocop:disable Style/EmptyElse
|
|
138
|
+
# rubocop:disable-next Style/EmptyElse
|
|
139
139
|
def timestamp_color(timestamp)
|
|
140
140
|
case Time.zone.at(timestamp.to_i)
|
|
141
141
|
when ...14.days.ago then '63a2c7' # faded :blue
|
|
@@ -150,7 +150,6 @@ module Usps::Support::Helpers
|
|
|
150
150
|
# :nocov:
|
|
151
151
|
end
|
|
152
152
|
end
|
|
153
|
-
# rubocop:enable Style/EmptyElse
|
|
154
153
|
# rubocop:enable Metrics/AbcSize
|
|
155
154
|
end
|
|
156
155
|
end
|
|
@@ -4,7 +4,7 @@ module Usps::Support::Lib::SimpleCov
|
|
|
4
4
|
# Intended to make it quicker to know what was uncovered, especially when
|
|
5
5
|
# running in GitHub Actions
|
|
6
6
|
#
|
|
7
|
-
# rubocop:disable Rails/Output
|
|
7
|
+
# rubocop:disable-next Rails/Output
|
|
8
8
|
class UncoveredLinesFormatter
|
|
9
9
|
attr_reader :uncovered_files
|
|
10
10
|
|
|
@@ -45,5 +45,4 @@ module Usps::Support::Lib::SimpleCov
|
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
|
-
# rubocop:enable Rails/Output
|
|
49
48
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Usps::Support::Models::Hq
|
|
4
4
|
# Base record for the HQ VHQAB database
|
|
5
5
|
#
|
|
6
|
-
# rubocop:disable Rails/ApplicationRecord
|
|
6
|
+
# rubocop:disable-next Rails/ApplicationRecord
|
|
7
7
|
class SharedRecord < ::ActiveRecord::Base
|
|
8
8
|
self.abstract_class = true
|
|
9
9
|
|
|
@@ -18,5 +18,4 @@ module Usps::Support::Models::Hq
|
|
|
18
18
|
#
|
|
19
19
|
def self.ignore_type_column_sti! = self.inheritance_column = nil
|
|
20
20
|
end
|
|
21
|
-
# rubocop:enable Rails/ApplicationRecord
|
|
22
21
|
end
|
data/lib/usps/support/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usps-support
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.61
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -89,6 +89,7 @@ files:
|
|
|
89
89
|
- app/controllers/concerns/usps/support/dependency_gate.rb
|
|
90
90
|
- app/controllers/usps/support/admins_controller.rb
|
|
91
91
|
- app/controllers/usps/support/health_controller.rb
|
|
92
|
+
- app/controllers/usps/support/jwt_callbacks_controller.rb
|
|
92
93
|
- app/models/usps/support/policy/admin_context.rb
|
|
93
94
|
- config/routes.rb
|
|
94
95
|
- db/hq/members_schema.rb
|