Sha256: 4cc8af4446453f6d9c06cd9b895216caf823e1a1d4f632f8ec5138557f53d6fa

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

module UcbRails
  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 RailsEnvironment.production?
            provider(:developer, fields: [:uid], uid_field: :uid)
          end
          
          provider :cas,
            host: host_name,
            login_url: '/cas/login',
            service_validate_url: '/cas/serviceValidate'
        end
      end
      
      def set_ucb_rails_cas_host
        UcbRails.config.cas_host = host
      end
      
      private

      def host
        config.fetch('host', default_host)
      end
      
      def default_host
        RailsEnvironment.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

8 entries across 8 versions & 1 rubygems

Version Path
ucb_rails-0.0.14 app/models/ucb_rails/configuration/cas.rb
ucb_rails-0.0.13 app/models/ucb_rails/configuration/cas.rb
ucb_rails-0.0.12 app/models/ucb_rails/configuration/cas.rb
ucb_rails-0.0.11 app/models/ucb_rails/configuration/cas.rb
ucb_rails-0.0.10 app/models/ucb_rails/configuration/cas.rb
ucb_rails-0.0.9 app/models/ucb_rails/configuration/cas.rb
ucb_rails-0.0.8 app/models/ucb_rails/configuration/cas.rb
ucb_rails-0.0.7 app/models/ucb_rails/configuration/cas.rb