Sha256: 2fe07b2574aebaddf1547520d9147d5ada66354e2500c827c6803d39bd683348

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

require "wobauth/engine"

module Wobauth

  def self.setup
    yield self
  end

  # authorizable types
  #
  mattr_reader :authorizable_types, :authorizable_group_method
  @@authorizable_types = [ "Wobauth::User", "Wobauth::Group" ]
  @@authorizable_group_method = :all
  
  # authorized_for types
  # Objects on which Wobauth should set authorization
  #
  mattr_accessor :authorized_for_types, :authorized_for_group_method
  @@authorized_for_types = [ ]
  @@authorized_for_group_method = :all

  # is remote authentication possible using REMOTE_USER?
  # default: check devise settings
  mattr_writer :remote_authentication
  @@remote_authentication = nil

  def self.remote_authentication?
    if @@remote_authentication.nil?
      @@remote_authentication = User.devise_modules.include?(:remote_user_authenticatable)
    end
    @@remote_authentication
  end

  # config file for ldap settings
  #
  mattr_writer :ldap_config
  @@ldap_config = nil


  def self.ldap_options
    return {} if @@ldap_config.blank?
    if File.readable? @@ldap_config
      config = YAML.load_file(@@ldap_config)
    end
    config ||= Hash.new

    if config['ldap_options'].present?
      ldapopts = config['ldap_options']
      if ldapopts.kind_of? Hash
        ldapopts = [ldapopts]
      end
      ldapopts.each do |opts|
        opts.symbolize_keys!
        opts.each do |k,v|
          opts[k] = opts[k].symbolize_keys if opts[k].kind_of? Hash
        end
      end
    else
      nil
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wobauth-6.0.1 lib/wobauth.rb
wobauth-6.0.0 lib/wobauth.rb
wobauth-5.1.3 lib/wobauth.rb
wobauth-5.1.2 lib/wobauth.rb
wobauth-5.1.1 lib/wobauth.rb
wobauth-5.1.0 lib/wobauth.rb