Sha256: 7db9c668434fdddae400791900bed6ba4719f9b4074f2b5907a239d3d78d7c3b

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require 'devise'
require 'devise_remote_user/engine'
require 'devise_remote_user/controller_behavior'

module DeviseRemoteUser

  # 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 = {}

  # Settings for redirecting to the remote user logout URL
  # Enable by including DeviseRemoteUser::Controllers::Helpers in ApplicationController
  # (it overrides Devise's after_sign_out_path_for method).
  mattr_accessor :logout_url
  @@logout_url = '/'

  def self.configure
    yield self
  end
  
  def self.remote_user_id env
    case env_key
    when Proc
      env_key.call(env)
    else
      env[env_key]
    end
  end

end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise-remote-user-0.4.1 lib/devise_remote_user.rb
devise-remote-user-0.4.0 lib/devise_remote_user.rb