rails_base 0.53.1 → 0.54.0
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/rails_base/admin_controller.rb +2 -1
- data/app/services/rails_base/authentication/single_sign_on_send.rb +6 -3
- data/app/views/layouts/rails_base/application.html.erb +2 -2
- data/app/views/rails_base/shared/_appearance_mode_selector.html.erb +7 -3
- data/config/initializers/switch_user.rb +1 -1
- data/lib/rails_base/admin/default_index_tile.rb +0 -1
- data/lib/rails_base/configuration/admin.rb +10 -0
- data/lib/rails_base/configuration/appearance.rb +8 -2
- data/lib/rails_base/configuration/display/bg_light.rb +25 -0
- data/lib/rails_base/configuration/display/card.rb +24 -0
- data/lib/rails_base/configuration/display/text.rb +0 -1
- data/lib/rails_base/version.rb +2 -2
- data/lib/velocity_limiter.rb +6 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe27d75cdddcc15a030ab4fa65a259e47cf05f2213495291b29aca0b31ea1bbf
|
4
|
+
data.tar.gz: 88fa8e22d35ffaf1357341ce223873a86ea313f0a628fdc9b1710583df358126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b0b2c4d3685e8030655c05d294b25bc27740e547354eeb69400fbcb2383a84b515b3275493cea85315ddda0bd4417891098afd5620f0d1934e24f54b8f3d831
|
7
|
+
data.tar.gz: 2d1dab3b919b1b0b3534aa613b2aa40b79f6b34bc8f594602856d2266ba524f833616fee4f3a7fd474a7f7814e4dc5667ed455feaa11029a6f2365cfda3119bc
|
@@ -298,7 +298,8 @@ module RailsBase
|
|
298
298
|
session.delete(RailsBase::Authentication::Constants::ADMIN_REMEMBER_REASON)
|
299
299
|
|
300
300
|
flash[:notice] = 'You no longer have an identity crisis. You are back to normal.'
|
301
|
-
|
301
|
+
redirect_url = RailsBase.config.admin.admin_impersonate_return.call(request, params)
|
302
|
+
redirect_to redirect_url
|
302
303
|
end
|
303
304
|
|
304
305
|
private
|
@@ -9,6 +9,7 @@ module RailsBase::Authentication
|
|
9
9
|
delegate :reason, to: :context
|
10
10
|
delegate :token_type, to: :context
|
11
11
|
delegate :url_redirect, to: :context
|
12
|
+
delegate :msg_proc, to: :context
|
12
13
|
|
13
14
|
SSO_DECISION_TWILIO = :twilio
|
14
15
|
SSO_DECISION_EMAIL = :email
|
@@ -38,17 +39,19 @@ module RailsBase::Authentication
|
|
38
39
|
case sso_decision_type
|
39
40
|
when SSO_DECISION_TWILIO
|
40
41
|
context.sso_destination = :sms
|
41
|
-
send_to_twilio!(message: message(url: url))
|
42
|
+
send_to_twilio!(message: message(url: url, full_name: user.full_name))
|
42
43
|
when SSO_DECISION_EMAIL
|
43
44
|
context.sso_destination = :email
|
44
|
-
send_to_email!(message: message(url: url))
|
45
|
+
send_to_email!(message: message(url: url, full_name: user.full_name))
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
49
|
# This method is expected to be overridden by the main app
|
49
50
|
# This is the default message
|
50
51
|
# Might consider shipping this to a locales that can be easily overridden in downstream app
|
51
|
-
def message(url:)
|
52
|
+
def message(url:, full_name:)
|
53
|
+
return msg_proc.call(url, full_name) if msg_proc.is_a?(Proc)
|
54
|
+
|
52
55
|
"Hello #{user.full_name}. This is your SSO link to your favorite site.\n#{url}"
|
53
56
|
end
|
54
57
|
|
@@ -32,7 +32,7 @@
|
|
32
32
|
<body>
|
33
33
|
<script type="text/javascript">
|
34
34
|
// Load at top so available for rest of body oddy
|
35
|
-
function set_cookie(name, value, path
|
35
|
+
function set_cookie(name, value, path) {
|
36
36
|
path ||= '/'
|
37
37
|
document.cookie = `${name}=${value}; path=${path}`
|
38
38
|
}
|
@@ -126,7 +126,7 @@
|
|
126
126
|
</footer>
|
127
127
|
<% end %>
|
128
128
|
</div>
|
129
|
-
|
129
|
+
|
130
130
|
<% if RailsBase.appearance.back_to_top.enable? %>
|
131
131
|
<a id="rails-base-back-to-top" class="btn btn-light btn-lg back-to-top" role="button"><i class="fas fa-chevron-up"></i></a>
|
132
132
|
<script type="text/javascript">
|
@@ -111,6 +111,11 @@
|
|
111
111
|
'<%= dark %>': '<%= RailsBase.appearance.text.dark_mode %>',
|
112
112
|
'<%= light %>': '<%= RailsBase.appearance.text.light_mode %>'
|
113
113
|
},
|
114
|
+
{
|
115
|
+
'descriptor': '.card',
|
116
|
+
'<%= dark %>': '<%= RailsBase.appearance.card.dark_mode %>',
|
117
|
+
'<%= light %>': '<%= RailsBase.appearance.card.light_mode %>'
|
118
|
+
},
|
114
119
|
// buttons
|
115
120
|
<% RailsBase.appearance.class::BUTTONS.each do |klass| %>
|
116
121
|
{
|
@@ -119,7 +124,6 @@
|
|
119
124
|
'<%= light %>': '<%= RailsBase.appearance.dig(klass, :light_mode) %>'
|
120
125
|
},
|
121
126
|
<% end %>
|
122
|
-
|
123
127
|
]
|
124
128
|
|
125
129
|
function toggle_dark_mode(set_key){
|
@@ -146,7 +150,7 @@
|
|
146
150
|
set_and_toggle_mode(value)
|
147
151
|
})
|
148
152
|
// This function MUST be called outside of document ready
|
149
|
-
// to ensure dark mode does not activate after
|
153
|
+
// to ensure dark mode does not activate after document is loaded
|
150
154
|
set_and_toggle_mode( `<%= cookies[RailsBase::ApplicationController::APPEARANCE_MODE_COOKIE] || RailsBase.appearance.default_mode %>`)
|
151
155
|
$('#appearance_mode_selector').appendTo('body');
|
152
156
|
$(document).ready(function(){
|
@@ -180,4 +184,4 @@
|
|
180
184
|
set_and_toggle_mode(get_cookie(cookie_name))
|
181
185
|
});
|
182
186
|
</script>
|
183
|
-
<% end %>
|
187
|
+
<% end %>
|
@@ -41,7 +41,7 @@ SwitchUser.setup do |config|
|
|
41
41
|
|
42
42
|
# redirect_path is a block, it returns which page will be redirected
|
43
43
|
# after switching a user.
|
44
|
-
config.redirect_path = ->(
|
44
|
+
config.redirect_path = ->(request, params) { RailsBase.config.admin.admin_impersonate_redirect.call(request, params) }
|
45
45
|
|
46
46
|
# helper_with_guest is a boolean value, if it set to false
|
47
47
|
# the guest item in the helper won't be shown
|
@@ -190,6 +190,16 @@ module RailsBase
|
|
190
190
|
default: ENV.fetch('ADMIN_VELOCITY_FRAME', 5).to_i.hours,
|
191
191
|
description: 'Debug purposes. How long to keep admin_velocity_max attempts',
|
192
192
|
},
|
193
|
+
admin_impersonate_redirect:{
|
194
|
+
type: :proc,
|
195
|
+
default: ->(_request, _params) { RailsBase.url_routes.authenticated_root_path },
|
196
|
+
description: 'Redirection to impersonation -- Landing page when having an identity cris',
|
197
|
+
},
|
198
|
+
admin_impersonate_return:{
|
199
|
+
type: :proc,
|
200
|
+
default: ->(_request, _params) { RailsBase.url_routes.admin_base_path },
|
201
|
+
description: 'Redirection from impersonation -- Page to return from when you have found yourself',
|
202
|
+
}
|
193
203
|
}
|
194
204
|
|
195
205
|
attr_accessor *DEFAULT_VALUES.keys
|
@@ -14,6 +14,9 @@ require 'rails_base/configuration/display/navbar'
|
|
14
14
|
require 'rails_base/configuration/display/table_body'
|
15
15
|
require 'rails_base/configuration/display/table_header'
|
16
16
|
require 'rails_base/configuration/display/text'
|
17
|
+
require 'rails_base/configuration/display/card'
|
18
|
+
require 'rails_base/configuration/display/card'
|
19
|
+
require 'rails_base/configuration/display/bg_light'
|
17
20
|
|
18
21
|
module RailsBase
|
19
22
|
module Configuration
|
@@ -27,6 +30,8 @@ module RailsBase
|
|
27
30
|
:btn_info,
|
28
31
|
:btn_light,
|
29
32
|
:btn_dark,
|
33
|
+
:bg_light,
|
34
|
+
|
30
35
|
]
|
31
36
|
|
32
37
|
DOWNSTREAM_CLASSES = [
|
@@ -35,9 +40,9 @@ module RailsBase
|
|
35
40
|
:bg_color,
|
36
41
|
:navbar,
|
37
42
|
:text,
|
43
|
+
:card,
|
38
44
|
:footer,
|
39
45
|
:back_to_top,
|
40
|
-
|
41
46
|
] + BUTTONS
|
42
47
|
|
43
48
|
SKIP_DOWNSTREAM_CLASSES = [:footer, :back_to_top]
|
@@ -85,9 +90,10 @@ module RailsBase
|
|
85
90
|
@bg_color = Configuration::Display::BackgroundColor.new
|
86
91
|
@navbar = Configuration::Display::Navbar.new
|
87
92
|
@text = Configuration::Display::Text.new
|
88
|
-
|
93
|
+
@card = Configuration::Display::Card.new
|
89
94
|
@footer = Configuration::Display::Footer.new
|
90
95
|
@back_to_top = Configuration::Display::BackTotop.new
|
96
|
+
@bg_light = Configuration::Display::BgLight.new
|
91
97
|
|
92
98
|
@btn_primary = Configuration::Display::BtnPrimary.new
|
93
99
|
@btn_secondary = Configuration::Display::BtnSecondary.new
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails_base/configuration/base'
|
2
|
+
|
3
|
+
module RailsBase
|
4
|
+
module Configuration
|
5
|
+
module Display
|
6
|
+
class BgLight < Base
|
7
|
+
|
8
|
+
DEFAULT_VALUES = {
|
9
|
+
dark_mode: {
|
10
|
+
type: :string_nil,
|
11
|
+
default: 'bg-secondary',
|
12
|
+
description: 'Background to use in Dark mode'
|
13
|
+
},
|
14
|
+
light_mode: {
|
15
|
+
type: :string_nil,
|
16
|
+
default: 'bg-light',
|
17
|
+
description: 'Background to use in light mode'
|
18
|
+
},
|
19
|
+
}
|
20
|
+
|
21
|
+
attr_accessor *DEFAULT_VALUES.keys
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails_base/configuration/base'
|
2
|
+
|
3
|
+
module RailsBase
|
4
|
+
module Configuration
|
5
|
+
module Display
|
6
|
+
class Card < Base
|
7
|
+
DEFAULT_VALUES = {
|
8
|
+
dark_mode: {
|
9
|
+
type: :string_nil,
|
10
|
+
default: 'bg-dark',
|
11
|
+
description: 'Color of card for dark mode: https://getbootstrap.com/docs/4.0/utilities/colors/'
|
12
|
+
},
|
13
|
+
light_mode: {
|
14
|
+
type: :string_nil,
|
15
|
+
default: '',
|
16
|
+
description: 'Color of card for light mode : https://getbootstrap.com/docs/4.0/utilities/colors/'
|
17
|
+
},
|
18
|
+
}
|
19
|
+
|
20
|
+
attr_accessor *DEFAULT_VALUES.keys
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/rails_base/version.rb
CHANGED
data/lib/velocity_limiter.rb
CHANGED
@@ -9,7 +9,7 @@ module VelocityLimiter
|
|
9
9
|
if metadata[:velocity_reached]
|
10
10
|
log(level: :warn, msg: "#{cache_key} has been velocity limited. #{metadata[:within_attempts_count]} attempts since #{metadata[:threshold]}. MAX allowed is #{velocity_max}")
|
11
11
|
log(level: :warn, msg: "#{cache_key} may try again in #{metadata[:to_words]} :: #{metadata[:attempt_again_at]}. Will fully reset at #{metadata[:fully_reset_time]}")
|
12
|
-
msg =
|
12
|
+
msg = velocity_limit_message(metadata: metadata)
|
13
13
|
return {reached: true, msg: msg}
|
14
14
|
end
|
15
15
|
|
@@ -35,6 +35,10 @@ module VelocityLimiter
|
|
35
35
|
def velocity_frame
|
36
36
|
end
|
37
37
|
|
38
|
+
def velocity_limit_message(metadata:)
|
39
|
+
"Velocity limit reached for SMS verification. You may try again in #{metadata[:to_words]}"
|
40
|
+
end
|
41
|
+
|
38
42
|
def cache_delineator
|
39
43
|
','
|
40
44
|
end
|
@@ -57,6 +61,7 @@ module VelocityLimiter
|
|
57
61
|
obj[:velocity_reached] = within_attempts.count >= velocity_max
|
58
62
|
obj[:within_attempts_arr] = within_attempts
|
59
63
|
obj[:within_attempts_count] = within_attempts.count
|
64
|
+
obj[:attempts_remaining] = velocity_max - obj[:vl_write].count
|
60
65
|
obj[:threshold] = threshold
|
61
66
|
obj[:velocity_max] = velocity_max
|
62
67
|
obj[:velocity_frame] = velocity_frame
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.54.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -569,6 +569,7 @@ files:
|
|
569
569
|
- lib/rails_base/configuration/base.rb
|
570
570
|
- lib/rails_base/configuration/display/back_to_top.rb
|
571
571
|
- lib/rails_base/configuration/display/background_color.rb
|
572
|
+
- lib/rails_base/configuration/display/bg_light.rb
|
572
573
|
- lib/rails_base/configuration/display/btn_danger.rb
|
573
574
|
- lib/rails_base/configuration/display/btn_dark.rb
|
574
575
|
- lib/rails_base/configuration/display/btn_info.rb
|
@@ -577,6 +578,7 @@ files:
|
|
577
578
|
- lib/rails_base/configuration/display/btn_secondary.rb
|
578
579
|
- lib/rails_base/configuration/display/btn_success.rb
|
579
580
|
- lib/rails_base/configuration/display/btn_warning.rb
|
581
|
+
- lib/rails_base/configuration/display/card.rb
|
580
582
|
- lib/rails_base/configuration/display/footer.rb
|
581
583
|
- lib/rails_base/configuration/display/navbar.rb
|
582
584
|
- lib/rails_base/configuration/display/table_body.rb
|