bro_hub 0.1.1 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c58315415147812aef646d84120a0b41873fcdc68c854103525495ae857e57be
4
- data.tar.gz: c2f5e8065183d9e69679f96927827dced7865c6f1a19ea3034a64eb54522244d
3
+ metadata.gz: b1fbd1cddc86bdf0bc203daff3dbe7eab88f49d7046c2f7444b215b8a24ddee1
4
+ data.tar.gz: 80a631c65cf8f57fca41e6c67b059a978aef763aa9fcdc1d386634b0bae43de7
5
5
  SHA512:
6
- metadata.gz: 6aefb62a9ac21abe8455c64da8b7d8b384e099a8d4c6a878ccb1cdbdb99939774f48727a4f95ff211997f1f70f17c7267f6571e6a9b0c5213a246b1c76e53390
7
- data.tar.gz: 336d8b3283433dbc9c30795fb6f974b62363f31479578c85f3a526d08fbec0794f6dd5294045b1cfc495bc61be2cca1459e92b4546880843e25c240797c63c3d
6
+ metadata.gz: 5fc326ddbfcb13bbb77adae1928de8a1cbbdff6ab454c1b8896ea81a3d8c0d08ff3ecea53ed75af1e47f5eecb0c9cbf8a2691066d6ffe66a76560234af9ac022
7
+ data.tar.gz: 3cc2551c4d6cdf13fce248f5b18991bdfd9c1c54cc39bfa4983e815898ddeb322da844880e469a760e094d47974357b11a9968ff8a99c2835f0db6c8945f18f2
data/README.md CHANGED
@@ -85,12 +85,12 @@ BroHub.register :safe_bro,
85
85
 
86
86
  ```ruby
87
87
  class SafeBro::ApplicationController < ::ApplicationController
88
- include BroHub::Layout
88
+ include BroHub::ControllerBase
89
89
  bro_hub_section :safe_bro
90
90
  end
91
91
  ```
92
92
 
93
- `BroHub::Layout` sets the layout and adds `bro_hub_user`. Override it if your gem has its own idea of who is signed in.
93
+ `BroHub::ControllerBase` includes `BroHub::Layout` (the layout, and `bro_hub_user`), turns on CSRF protection and opts out of the host app's Pundit `verify_authorized` checks, so every Bro controller behaves the same under any host `ApplicationController`. Override it if your gem has its own idea of who is signed in.
94
94
 
95
95
  **3. Give your gem an installer** that sets up BroHub first, then itself. Name it `<section key>:install` so
96
96
  `bro_hub:install` finds it:
@@ -1,8 +1,6 @@
1
1
  module BroHub
2
2
  class ApplicationController < BroHub.config.parent_controller.constantize
3
- include BroHub::Layout
4
-
5
- protect_from_forgery with: :exception
3
+ include BroHub::ControllerBase
6
4
 
7
5
  before_action :bro_hub_require_ssl
8
6
  before_action :bro_hub_no_store
@@ -0,0 +1,22 @@
1
+ module BroHub
2
+ # Include in every Bro controller base (BroHub's own, and each gem's ApplicationController). It holds
3
+ # what must be right for *any* host app, so a clash with the host's ApplicationController is fixed once, here:
4
+ #
5
+ # class SafeBro::ApplicationController < SafeBro.config.parent_controller.constantize
6
+ # include BroHub::ControllerBase
7
+ # bro_hub_section :safe_bro
8
+ module ControllerBase
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ include BroHub::Layout
13
+
14
+ protect_from_forgery with: :exception
15
+
16
+ # The host's Pundit checks (`after_action :verify_authorized`) don't apply: Bro controllers authorize
17
+ # people themselves and have no policy to ask. No-ops when Pundit isn't in use.
18
+ skip_after_action :verify_authorized, raise: false
19
+ skip_after_action :verify_policy_scoped, raise: false
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module BroHub
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/bro_hub.rb CHANGED
@@ -3,6 +3,7 @@ require "bro_hub/configuration"
3
3
  require "bro_hub/section"
4
4
  require "bro_hub/registry"
5
5
  require "bro_hub/layout"
6
+ require "bro_hub/controller_base"
6
7
  require "bro_hub/root_middleware"
7
8
  require "bro_hub/engine"
8
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bro_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruby Dev SRL
@@ -44,6 +44,7 @@ files:
44
44
  - config/routes.rb
45
45
  - lib/bro_hub.rb
46
46
  - lib/bro_hub/configuration.rb
47
+ - lib/bro_hub/controller_base.rb
47
48
  - lib/bro_hub/engine.rb
48
49
  - lib/bro_hub/layout.rb
49
50
  - lib/bro_hub/registry.rb