Module: Smriti::Admin::AuthBridge

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController
Defined in:
lib/smriti/admin/auth_bridge.rb

Overview

Smriti::Admin::AuthBridge

Bridge module that wires the Smriti 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_smriti!.
  • Exposes helpers: smriti_current_user and its alias #user.

Host integration options (define one of these):

  1. A top-level module:
    # app/lib/smriti_admin.rb (or any autoloaded path)
    module SmritiAdmin
      def authenticate_smriti!;  end
      def authorize_smriti!(*); end
      def smriti_current_user;  end
    end
    
  2. A namespaced module:
    # app/lib/smriti/admin/host_auth.rb
    module Smriti
      module Admin
        module HostAuth
          def authenticate_smriti!;  end
          def authorize_smriti!(*); end
          def smriti_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.

See Also:

Instance Method Summary collapse

Instance Method Details

#userObject?

Convenience alias for smriti_current_user exposed to views.

Returns:

  • (Object, nil)

    the current user object as defined by host auth



68
# File 'lib/smriti/admin/auth_bridge.rb', line 68

def user = smriti_current_user