Sha256: 82bad6ea42df2bb36a689ffeacc722f0ee036071509f148aed8f4842061ca621

Contents?: true

Size: 1.12 KB

Versions: 30

Compression:

Stored size: 1.12 KB

Contents

module UcbRailsUser
  module Configuration

    class Cas
      attr_accessor :config

      def initialize(config)
        self.config = config.presence || {}
      end

      def configure
        configure_omniauth
        set_ucb_rails_cas_host
      end

      def configure_omniauth
        host_name = host
        Rails.application.config.middleware.use OmniAuth::Builder do

          unless Rails.env.production?
            provider(:developer, fields: [:uid], uid_field: :uid)
          end

          provider :cas,
            host: host_name,
            login_url: '/cas/login?renew=true', # renew=true forces the login screen to appear each time
            service_validate_url: '/cas/serviceValidate'
        end
      end

      def set_ucb_rails_cas_host
        UcbRailsUser.config.cas_host = host
      end

      private

      def host
        config.fetch('host', default_host)
      end

      def default_host
        Rails.env.production? ? 'auth.berkeley.edu' : 'auth-test.berkeley.edu'
      end

      class << self
        def configure(config)
          new(config).configure
        end
      end
    end

  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
ucb_rails_user-7.0.0 lib/ucb_rails_user/configuration/cas.rb
ucb_rails_user-6.2.2 lib/ucb_rails_user/configuration/cas.rb
ucb_rails_user-6.2.0 lib/ucb_rails_user/configuration/cas.rb
ucb_rails_user-6.1.1 lib/ucb_rails_user/configuration/cas.rb
ucb_rails_user-6.1.0 lib/ucb_rails_user/configuration/cas.rb
ucb_rails_user-6.0.0 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-5.0.0 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.1.2 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.1.1 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.1.0 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.0.7 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.0.6 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.0.5 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.0.4 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.0.3 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.0.2 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.0.1 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.0.0 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-3.0.2 app/models/ucb_rails_user/configuration/cas.rb
ucb_rails_user-4.0.0.beta1 app/models/ucb_rails_user/configuration/cas.rb