Sha256: d02f3ce827a441178988a014a7b5f4c17184250332cdb5f71c6c2adc64b41f93

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require 'devise'

module DeviseRemoteUser
  
  class Engine < Rails::Engine; end

  # request.env key for remote user name
  # Set to 'HTTP_REMOTE_USER' in config/initializers/devise.rb if behind reverse proxy
  mattr_accessor :env_key
  @@env_key = 'REMOTE_USER'
  
  # Enable user auto-creation of user from remote user attributes
  mattr_accessor :auto_create
  @@auto_create = false

  # Enable user auto-update of user attributes from remote user attributes
  mattr_accessor :auto_update
  @@auto_update = false

  # User attribute used for lookup of remote user
  # Defaults to Devise.authentication_keys.first
  mattr_accessor :auth_key
  @@auth_key = nil

  # Map of User model attributes to request.env keys for updating a local user when auto-creation is enabled.
  mattr_accessor :attribute_map
  @@attribute_map = {}

  def self.configure
    yield self
  end

  def self.add_warden_callbacks
    if auto_update
      Warden::Manager.after_authentication do |user, auth, opts|
        manager = DeviseRemoteUser::Manager.new(auth.env)
        manager.update_user(user)
      end
    end
  end

end

Devise.add_module(:remote_user_authenticatable,
                  :strategy => true,
                  :controller => :sessions,
                  :model => 'devise_remote_user/model')

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise-remote-user-0.1.0 lib/devise_remote_user.rb