module Sorcery::Controller::Submodules::HttpBasicAuth

This submodule integrates HTTP Basic authentication into sorcery. You are provided with a before action, require_login_from_http_basic, which requests the browser for authentication. Then the rest of the submodule takes care of logging the user in into the session, so that the next requests will keep him logged in.

Attributes

controller_to_realm_map[RW]

Public Class Methods

included(base) click to toggle source
# File lib/sorcery/controller/submodules/http_basic_auth.rb, line 10
def self.included(base)
  base.send(:include, InstanceMethods)
  Config.module_eval do
    class << self
      attr_accessor :controller_to_realm_map # What realm to display for which controller name.

      def merge_http_basic_auth_defaults!
        @defaults.merge!(:@controller_to_realm_map => { 'application' => 'Application' })
      end
    end
    merge_http_basic_auth_defaults!
  end

  Config.login_sources << :login_from_basic_auth
end
merge_http_basic_auth_defaults!() click to toggle source
# File lib/sorcery/controller/submodules/http_basic_auth.rb, line 16
def merge_http_basic_auth_defaults!
  @defaults.merge!(:@controller_to_realm_map => { 'application' => 'Application' })
end