Class: ManageIQ::ApplianceConsole::SamlAuthentication

Inherits:
Object
  • Object
show all
Includes:
AuthUtilities
Defined in:
lib/manageiq/appliance_console/saml_authentication.rb

Constant Summary collapse

MELLON_CREATE_METADATA_COMMAND =
Pathname.new("/usr/libexec/mod_auth_mellon/mellon_create_metadata.sh")
SAML2_CONFIG_DIRECTORY =
Pathname.new("/etc/httpd/saml2")
IDP_METADATA_FILE =
SAML2_CONFIG_DIRECTORY.join("idp-metadata.xml")

Constants included from AuthUtilities

AuthUtilities::HTTPD_CONFIG_DIRECTORY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AuthUtilities

#configure_auth_settings, #configure_auth_settings_database, #copy_template, #debug_msg, #log_command_error, #path_is_file?, #path_is_url?, #relative_from_root, #remove_file, #restart_httpd, #template_directory

Constructor Details

#initialize(options) ⇒ SamlAuthentication

Returns a new instance of SamlAuthentication.



13
14
15
# File 'lib/manageiq/appliance_console/saml_authentication.rb', line 13

def initialize(options)
  @options = options
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



11
12
13
# File 'lib/manageiq/appliance_console/saml_authentication.rb', line 11

def host
  @host
end

#optionsObject

Returns the value of attribute options.



11
12
13
# File 'lib/manageiq/appliance_console/saml_authentication.rb', line 11

def options
  @options
end

Instance Method Details

#configure(host) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/manageiq/appliance_console/saml_authentication.rb', line 17

def configure(host)
  @host = host
  

  say("Configuring SAML Authentication for https://#{host} ...")
  copy_apache_saml_configfiles
  FileUtils.mkdir_p(SAML2_CONFIG_DIRECTORY)
  AwesomeSpawn.run!(MELLON_CREATE_METADATA_COMMAND,
                    :chdir  => SAML2_CONFIG_DIRECTORY,
                    :params => ["https://#{host}", "https://#{host}/saml2"])
  rename_mellon_configfiles
  
  configure_auth_settings_saml
  restart_httpd
  true
rescue AwesomeSpawn::CommandResultError => e
  log_command_error(e)
  say("Failed to Configure SAML Authentication - #{e}")
  false
rescue => e
  say("Failed to Configure SAML Authentication - #{e}")
  false
end

#unconfigureObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/manageiq/appliance_console/saml_authentication.rb', line 41

def unconfigure
  raise "Appliance is not currently configured for SAML" unless configured?

  say("Unconfiguring SAML Authentication ...")
  remove_apache_saml_configfiles
  configure_auth_settings_database
  restart_httpd
  true
rescue AwesomeSpawn::CommandResultError => e
  log_command_error(e)
  say("Failed to Unconfigure SAML Authentication - #{e}")
  false
rescue => e
  say("Failed to Unconfigure SAML Authentication - #{e}")
  false
end