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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b83893c9eec976687c8c2025317dc0e3b0b3174cc128868a0d4cdb079c83bfc
4
- data.tar.gz: cf24b4e05521fc40d24e31e061c5fc71efb0b63af7eacfcff0164d35d60ac0e4
3
+ metadata.gz: 13a5abdefd6191deed91535f4401bf0def14a6e502b6d4b191d7129e7fb2c754
4
+ data.tar.gz: 1166792b0ff651665d8dba513e56af064decf4b97c6d68c5302eddc3a194ac04
5
5
  SHA512:
6
- metadata.gz: 650c2237a64d202041e45f50b3831362af5077d5f1b35e56482d7c93326482c1b022896cd39a215e199c8a52aaf638db7db0b6a90bf7d5bbbb3e37dddf8e32fb
7
- data.tar.gz: 25f83106ff3762ff132b442f186f2f82966595a82ee7390fef99a9b3a415b87a6cf882adadf14fb6e283a2f35c2b786673f0ff50bd8230cba7e329cff1bd803c
6
+ metadata.gz: cb284469c871a0f3bd17213d2c316835b4a1c3ea2ed82d3fda416066e1a89128f0d2b0c4848b3068eb1298109993ece6fec8941b119ca8cb1cf591d32998d2c8
7
+ data.tar.gz: 6154b8cdda0c06b4c6afc7d19d751131fb1cfe33d93e6e090afd8f8070c52197c62d0f65d0928001281f5f489d6965dd9c2f229232308ae1d297af378ab3821a
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2019-2020 Marc Anguera Insa @markets
1
+ Copyright 2019 Marc Anguera Insa @markets
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Sudo Rails
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/sudo_rails.svg?style=flat-square)](https://rubygems.org/gems/sudo_rails)
4
- [![Build Status](https://travis-ci.com/markets/sudo_rails.svg?branch=master)](https://travis-ci.com/markets/sudo_rails)
4
+ [![Build Status](https://github.com/markets/sudo_rails/workflows/CI/badge.svg)](https://github.com/markets/sudo_rails/actions)
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/322350adc7ab052beccb/maintainability)](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
+ ![](support/images/cover.png)
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
- **NOTE** 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).
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
@@ -1,6 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
3
- require 'rspec/core/rake_task'
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -7,7 +7,7 @@
7
7
  </div>
8
8
 
9
9
  <div class='sudo-form'>
10
- <%= form_tag '/sudo_rails/confirm' do |f| %>
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
@@ -0,0 +1,7 @@
1
+ class SudoRails::ViewGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../../../app/views/sudo_rails/", __dir__)
3
+
4
+ def copy_view_file
5
+ copy_file "confirm_form.html.erb", "app/views/sudo_rails/confirm_form.html.erb"
6
+ end
7
+ end
@@ -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(:action_controller) do
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
@@ -1,3 +1,3 @@
1
1
  module SudoRails
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
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.7.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: 2021-03-05 00:00:00.000000000 Z
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: '4.2'
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: '4.2'
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.0.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: []