Module: MatViews::Admin::AuthBridge
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationController
- Defined in:
- lib/mat_views/admin/auth_bridge.rb
Overview
MatViews::Admin::AuthBridge
Bridge module that wires the MatViews admin engine to a host-provided authentication/authorization layer, while providing safe defaults.
### How it works
-
Includes DefaultAuth first (fallback, no-op/hostable).
-
Then includes the **host auth module** returned by host_auth_module. Because Ruby searches the most recently included module first, the host module cleanly overrides any defaults from
DefaultAuth. -
Registers a before_action
authenticate_mat_views!. -
Exposes helpers:
mat_views_current_userand its alias #user.
### Host integration options (define one of these): 1) A top-level module:
```ruby
# app/lib/mat_views_admin.rb (or any autoloaded path)
module MatViewsAdmin
def authenticate_mat_views!; end
def authorize_mat_views!(*); end
def mat_views_current_user; end
end
```
2) A namespaced module:
```ruby
# app/lib/mat_views/admin/host_auth.rb
module MatViews
module Admin
module HostAuth
def authenticate_mat_views!; end
def authorize_mat_views!(*); end
def mat_views_current_user; end
end
end
end
```
If neither module is present, a blank Module.new is included and the defaults in DefaultAuth remain in effect.
Instance Method Summary collapse
-
#user ⇒ Object?
Convenience alias for
mat_views_current_userexposed to views.
Instance Method Details
#user ⇒ Object?
Convenience alias for mat_views_current_user exposed to views.
68 |
# File 'lib/mat_views/admin/auth_bridge.rb', line 68 def user = mat_views_current_user |