railspress-engine 1.3.0 → 1.3.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: 24a6b9398ebd465a15fd0d1346127c45d2264c1f479cc9d866ebd52565ed6a7e
4
- data.tar.gz: 6b410cc6ee303f2c2ef33f438517f1bab2850a695ca31c82e1ec035acbcd2e5b
3
+ metadata.gz: 82835798c2b73d8f15e76d9883b911bfb7c7130c2ec54ca94b7c3b306112dc33
4
+ data.tar.gz: 526d5a4c65204b09337e44265e0d7bfcab0aff08cbfd9e99f3094e7fec32647d
5
5
  SHA512:
6
- metadata.gz: cd5cb3183c073a9b35234add1862126b62c8055faf799ff28209cb896d563c020ccf0ed6dc06e2ba8ce65a30f727e3627c237cabebae13b717630a7403ddfd73
7
- data.tar.gz: dd7e0c8a24cb6b1bc7d9f32c184c3b1806b19bd68a51010c63789b639baef1b99abed3de8306ff380445bca9c3287772a749d64aa3f90cb440642881c747a42e
6
+ metadata.gz: 9d78ecf917f7bb2550b8dda4eda224120c53297f345f9432b6a83705d2df97461f8caf2ea5eadc06a1396fcd59bd8a8d6c9578fb9f86caeffce295792f752866
7
+ data.tar.gz: ebcde5bf787af266bf0439ad6a684fcad2484e5f6f800f31a1a2c0c4b09a52c0f503b419bd6648ff1a444a725ea50c88ef907e8fb6bd66f719c7eccd8d9bb343
@@ -8,6 +8,7 @@ Railspress.configure do |config|
8
8
  # config.enable_authors
9
9
  # config.author_class_name = "User"
10
10
  # config.current_author_method = :current_user
11
+ # config.current_author_proc = -> { Current.user }
11
12
 
12
13
  # === CMS Content Elements (opt-in) ===
13
14
  # Adds content groups, content elements, and the cms_element/cms_value
@@ -32,8 +33,12 @@ Railspress.configure do |config|
32
33
  # Requires Active Record Encryption keys in your host app config.
33
34
  # Uncomment to enable:
34
35
  # config.enable_api
36
+ # Optional: include a host auth concern into Railspress::Admin::BaseController.
37
+ # Define your concern in app/controllers/concerns/railspress_admin_auth.rb
38
+ # and set this to its constant name (String or Symbol).
39
+ # config.admin_auth_concern = "RailspressAdminAuth"
35
40
  # config.current_api_actor_method = :current_user
36
- # config.current_api_actor_proc = -> { Current.user }
41
+ # config.current_api_actor_proc = -> { Current.user if Current.user&.admin? }
37
42
  # Optional: force a canonical public base URL in generated API instructions.
38
43
  # Falls back to Rails.application.routes.default_url_options, then request host.
39
44
  # config.public_base_url = "https://blog.example.com"
@@ -41,6 +41,18 @@ module Railspress
41
41
  end
42
42
  end
43
43
 
44
+ # Allow host apps to inject their auth concern into the admin base controller.
45
+ # This keeps host auth logic in app/controllers concerns while Railspress handles reload-safe wiring.
46
+ initializer "railspress.admin_auth_concern" do |app|
47
+ app.config.to_prepare do
48
+ concern = Railspress.resolved_admin_auth_concern
49
+ next unless concern
50
+ next if Railspress::Admin::BaseController < concern
51
+
52
+ Railspress::Admin::BaseController.include(concern)
53
+ end
54
+ end
55
+
44
56
  # Configure importmap for Stimulus controllers
45
57
  initializer "railspress.importmap", before: "importmap" do |app|
46
58
  if app.respond_to?(:importmap)
@@ -1,3 +1,3 @@
1
1
  module Railspress
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.2"
3
3
  end
data/lib/railspress.rb CHANGED
@@ -12,6 +12,7 @@ module Railspress
12
12
  :current_author_proc,
13
13
  :current_api_actor_method,
14
14
  :current_api_actor_proc,
15
+ :admin_auth_concern,
15
16
  :public_base_url,
16
17
  :author_scope,
17
18
  :author_display_method,
@@ -37,6 +38,7 @@ module Railspress
37
38
  @current_author_proc = nil
38
39
  @current_api_actor_method = :current_user
39
40
  @current_api_actor_proc = nil
41
+ @admin_auth_concern = nil
40
42
  @public_base_url = nil
41
43
  @author_scope = nil
42
44
  @author_display_method = :name
@@ -283,6 +285,28 @@ module Railspress
283
285
  configuration.current_api_actor_proc
284
286
  end
285
287
 
288
+ def admin_auth_concern
289
+ configuration.admin_auth_concern
290
+ end
291
+
292
+ def resolved_admin_auth_concern
293
+ concern = admin_auth_concern
294
+ return nil if concern.blank?
295
+
296
+ module_value = case concern
297
+ when Module then concern
298
+ when String, Symbol
299
+ concern_name = concern.to_s
300
+ concern_name.safe_constantize || concern_name.camelize.safe_constantize
301
+ end
302
+
303
+ unless module_value.is_a?(Module)
304
+ raise ConfigurationError, "admin_auth_concern must resolve to a Module. Got: #{concern.inspect}"
305
+ end
306
+
307
+ module_value
308
+ end
309
+
286
310
  def public_base_url
287
311
  configuration.public_base_url
288
312
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railspress-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avi Flombaum