Class: UcbRailsUser::Configuration::Cas

Inherits:
Object
  • Object
show all
Defined in:
app/models/ucb_rails_user/configuration/cas.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Cas

Returns a new instance of Cas.



7
8
9
# File 'app/models/ucb_rails_user/configuration/cas.rb', line 7

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

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'app/models/ucb_rails_user/configuration/cas.rb', line 5

def config
  @config
end

Class Method Details

.configure(config) ⇒ Object



46
47
48
# File 'app/models/ucb_rails_user/configuration/cas.rb', line 46

def configure(config)
  new(config).configure
end

Instance Method Details

#configureObject



11
12
13
14
# File 'app/models/ucb_rails_user/configuration/cas.rb', line 11

def configure
  configure_omniauth
  set_ucb_rails_cas_host
end

#configure_omniauthObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/ucb_rails_user/configuration/cas.rb', line 16

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

#set_ucb_rails_cas_hostObject



31
32
33
# File 'app/models/ucb_rails_user/configuration/cas.rb', line 31

def set_ucb_rails_cas_host
  UcbRailsUser.config.cas_host = host
end