sudo_rails 0.7.0 → 0.8.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/LICENSE +1 -1
- data/README.md +11 -3
- data/Rakefile +0 -5
- data/app/views/sudo_rails/confirm_form.html.erb +1 -1
- data/lib/generators/sudo_rails/config_generator.rb +28 -0
- data/lib/generators/sudo_rails/view_generator.rb +7 -0
- data/lib/sudo_rails/engine.rb +2 -2
- data/lib/sudo_rails/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13a5abdefd6191deed91535f4401bf0def14a6e502b6d4b191d7129e7fb2c754
|
|
4
|
+
data.tar.gz: 1166792b0ff651665d8dba513e56af064decf4b97c6d68c5302eddc3a194ac04
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb284469c871a0f3bd17213d2c316835b4a1c3ea2ed82d3fda416066e1a89128f0d2b0c4848b3068eb1298109993ece6fec8941b119ca8cb1cf591d32998d2c8
|
|
7
|
+
data.tar.gz: 6154b8cdda0c06b4c6afc7d19d751131fb1cfe33d93e6e090afd8f8070c52197c62d0f65d0928001281f5f489d6965dd9c2f229232308ae1d297af378ab3821a
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Sudo Rails
|
|
2
2
|
|
|
3
3
|
[](https://rubygems.org/gems/sudo_rails)
|
|
4
|
-
[](https://github.com/markets/sudo_rails/actions)
|
|
5
5
|
[](https://codeclimate.com/github/markets/sudo_rails/maintainability)
|
|
6
6
|
|
|
7
7
|
> Sudo mode for your Rails controllers
|
|
@@ -16,6 +16,8 @@ end
|
|
|
16
16
|
|
|
17
17
|
*Inspired by [Unix `sudo` command](https://en.wikipedia.org/wiki/Sudo) and [GitHub Sudo mode](https://help.github.com/en/articles/sudo-mode).*
|
|
18
18
|
|
|
19
|
+

|
|
20
|
+
|
|
19
21
|
## Installation
|
|
20
22
|
|
|
21
23
|
Add this line to your Gemfile and then execute `bundle install`:
|
|
@@ -71,6 +73,8 @@ SudoRails.setup do |config|
|
|
|
71
73
|
end
|
|
72
74
|
```
|
|
73
75
|
|
|
76
|
+
Use the provided `sudo_rails:config` generator to create a default config file under your *initializers* folder.
|
|
77
|
+
|
|
74
78
|
### Sudo sessions
|
|
75
79
|
|
|
76
80
|
Using the `sudo_session_duration` option you are able to configure the `sudo` session duration (30 minutes by default).
|
|
@@ -81,9 +85,11 @@ If you set it to `nil`, your `sudo` session won't expire automatically and you w
|
|
|
81
85
|
|
|
82
86
|
Using the `custom_logo`, `primary_color` and `background_color` options, you can customize the confirmation page. In case you want full control of the styles, you can use your own layout (and consequently your own styles too) using the `layout` option.
|
|
83
87
|
|
|
84
|
-
See some :camera: [examples here](support/images/).
|
|
88
|
+
See some :camera: [examples here](support/images/examples/).
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
> ℹ️ If you are using your own layout, don't forget to render the flash messages in that layout. You can do something [like this](app/views/sudo_rails/_flash_alert.html.erb).
|
|
91
|
+
|
|
92
|
+
You can also override the view by calling the `sudo_rails:view` generator. This will create a copy of the view file at `app/views/sudo_rails/confirm_form.html.erb` which can be later modified as per your requirements.
|
|
87
93
|
|
|
88
94
|
### Confirmation strategy
|
|
89
95
|
|
|
@@ -91,6 +97,8 @@ You should define how to validate the password using the `confirm_strategy` opti
|
|
|
91
97
|
|
|
92
98
|
By default, the gem ships with `Devise` and `Clearance` integration. Check it [here](lib/sudo_rails/integrations/).
|
|
93
99
|
|
|
100
|
+
> ℹ️ In order to autoload `Devise` or `Clearance` strategy properly, you should place the `sudo_rails` gem after them in the Gemfile.
|
|
101
|
+
|
|
94
102
|
Implementation examples:
|
|
95
103
|
|
|
96
104
|
```ruby
|
data/Rakefile
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
9
|
<div class='sudo-form'>
|
|
10
|
-
<%= form_tag
|
|
10
|
+
<%= form_tag sudo_rails_confirm_path do |f| %>
|
|
11
11
|
<%= hidden_field_tag :locale, I18n.locale %>
|
|
12
12
|
<%= hidden_field_tag :target_path, params[:target_path] || request.url %>
|
|
13
13
|
<%= password_field_tag :password, nil, required: true, placeholder: t('sudo_rails.password') %>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class SudoRails::ConfigGenerator < Rails::Generators::Base
|
|
2
|
+
def create_config_file
|
|
3
|
+
create_file "config/initializers/sudo_rails.rb", <<~RUBY
|
|
4
|
+
SudoRails.setup do |config|
|
|
5
|
+
### On/off engine
|
|
6
|
+
# config.enabled = true
|
|
7
|
+
|
|
8
|
+
### Sudo mode sessions duration, default is 30 minutes
|
|
9
|
+
# config.sudo_session_duration = 10.minutes
|
|
10
|
+
|
|
11
|
+
### Confirmation page styling
|
|
12
|
+
# config.custom_logo = '/images/logo_medium.png'
|
|
13
|
+
# config.primary_color = '#1a7191'
|
|
14
|
+
# config.background_color = '#1a1a1a'
|
|
15
|
+
# config.layout = 'admin'
|
|
16
|
+
|
|
17
|
+
### Confirmation strategy implementation
|
|
18
|
+
# config.confirm_strategy = -> (context, password) {
|
|
19
|
+
# user = context.current_user
|
|
20
|
+
# user.valid_password?(password)
|
|
21
|
+
# }
|
|
22
|
+
|
|
23
|
+
### Reset password link
|
|
24
|
+
# config.reset_pass_link = '/users/password/new'
|
|
25
|
+
end
|
|
26
|
+
RUBY
|
|
27
|
+
end
|
|
28
|
+
end
|
data/lib/sudo_rails/engine.rb
CHANGED
|
@@ -3,14 +3,14 @@ module SudoRails
|
|
|
3
3
|
isolate_namespace SudoRails
|
|
4
4
|
|
|
5
5
|
initializer "sudo_rails.controller_ext" do
|
|
6
|
-
ActiveSupport.on_load(:
|
|
6
|
+
ActiveSupport.on_load(:action_controller_base) do
|
|
7
7
|
include SudoRails::ControllerExt
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
initializer 'sudo_rails.routes' do |app|
|
|
12
12
|
app.routes.append do
|
|
13
|
-
post '/sudo_rails/confirm' => 'sudo_rails/application#confirm'
|
|
13
|
+
post '/sudo_rails/confirm' => 'sudo_rails/application#confirm', as: :sudo_rails_confirm
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
data/lib/sudo_rails/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sudo_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- markets
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-02-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '5'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '5'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rspec-rails
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -54,6 +54,8 @@ files:
|
|
|
54
54
|
- app/views/sudo_rails/_stylesheet.html.erb
|
|
55
55
|
- app/views/sudo_rails/confirm_form.html.erb
|
|
56
56
|
- config/locales/en.yml
|
|
57
|
+
- lib/generators/sudo_rails/config_generator.rb
|
|
58
|
+
- lib/generators/sudo_rails/view_generator.rb
|
|
57
59
|
- lib/sudo_rails.rb
|
|
58
60
|
- lib/sudo_rails/controller_ext.rb
|
|
59
61
|
- lib/sudo_rails/engine.rb
|
|
@@ -65,7 +67,7 @@ homepage: https://github.com/markets/sudo_rails
|
|
|
65
67
|
licenses:
|
|
66
68
|
- MIT
|
|
67
69
|
metadata: {}
|
|
68
|
-
post_install_message:
|
|
70
|
+
post_install_message:
|
|
69
71
|
rdoc_options: []
|
|
70
72
|
require_paths:
|
|
71
73
|
- lib
|
|
@@ -80,8 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
80
82
|
- !ruby/object:Gem::Version
|
|
81
83
|
version: '0'
|
|
82
84
|
requirements: []
|
|
83
|
-
rubygems_version: 3.
|
|
84
|
-
signing_key:
|
|
85
|
+
rubygems_version: 3.4.10
|
|
86
|
+
signing_key:
|
|
85
87
|
specification_version: 4
|
|
86
88
|
summary: Sudo mode for Rails
|
|
87
89
|
test_files: []
|