Class: HttpdConfigmapGenerator::Saml

Inherits:
Base
  • Object
show all
Defined in:
lib/httpd_configmap_generator/saml.rb

Constant Summary collapse

MELLON_CREATE_METADATA_COMMAND =
"/usr/libexec/mod_auth_mellon/mellon_create_metadata.sh".freeze
SAML2_CONFIG_DIRECTORY =
"/etc/httpd/saml2".freeze
MIQSP_METADATA_FILE =
"#{SAML2_CONFIG_DIRECTORY}/miqsp-metadata.xml".freeze
IDP_METADATA_FILE =
"#{SAML2_CONFIG_DIRECTORY}/idp-metadata.xml".freeze
AUTH =
{
  :type    => "saml",
  :subtype => "saml"
}.freeze

Constants inherited from Base

Base::APACHE_USER, Base::HOSTNAME_COMMAND, Base::HTTP_KEYTAB, Base::IPA_COMMAND, Base::KERBEROS_CONFIG_FILE, Base::LDAP_ATTRS, Base::PAM_CONFIG, Base::SSSD_CONFIG, Base::TIMESTAMP_FORMAT

Instance Attribute Summary

Attributes inherited from Base

#opts

Instance Method Summary collapse

Methods inherited from Base

#command_run, #command_run!, #config_file_backup, #configure_pam, #cp_template, #create_target_directory, #debug_msg, #delete_target_file, #domain, #domain_from_host, #enable_kerberos_dns_lookups, #err_msg, #fetch_network_file, #file_binary?, #host_reachable?, #info_msg, #initialize, #log_command_error, #path_join, #realm, #rm_file, #run_configure, #template_directory, #update_hostname

Constructor Details

This class inherits a constructor from HttpdConfigmapGenerator::Base

Instance Method Details

#configure(opts) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/httpd_configmap_generator/saml.rb', line 35

def configure(opts)
  update_hostname(opts[:host])
  Dir.mkdir(SAML2_CONFIG_DIRECTORY)
  Dir.chdir(SAML2_CONFIG_DIRECTORY) do
    command_run!(,
                 :params => [
                   "https://#{opts[:host]}",
                   "https://#{opts[:host]}/saml2"
                 ])
    rename_mellon_configfiles
    
  end
  config_map = ConfigMap.new(opts)
  config_map.generate(AUTH[:type], realm, persistent_files)
  config_map.save(opts[:output])
rescue => err
  log_command_error(err)
  raise err
end

#configured?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/httpd_configmap_generator/saml.rb', line 55

def configured?
  File.exist?()
end

#optional_optionsObject



16
17
18
19
20
21
22
23
# File 'lib/httpd_configmap_generator/saml.rb', line 16

def optional_options
  super.merge(
    :keycloak_add_metadata => { :description => "Download and add the Keycloak metadata file",
                                :default     => false },
    :keycloak_server       => { :description => "Keycloak Server FQDN or IP" },
    :keycloak_realm        => { :description => "Keycloak Realm for this client"}
  )
end

#persistent_filesObject



25
26
27
28
29
30
31
32
33
# File 'lib/httpd_configmap_generator/saml.rb', line 25

def persistent_files
  file_list = %w(
    /etc/httpd/saml2/miqsp-key.key
    /etc/httpd/saml2/miqsp-cert.cert
    /etc/httpd/saml2/miqsp-metadata.xml
  )
  file_list += [] if opts[:keycloak_add_metadata]
  file_list
end

#required_optionsObject



12
13
14
# File 'lib/httpd_configmap_generator/saml.rb', line 12

def required_options
  super
end

#unconfigureObject



59
60
61
62
# File 'lib/httpd_configmap_generator/saml.rb', line 59

def unconfigure
  return unless configured?
  FileUtils.rm_rf(SAML2_CONFIG_DIRECTORY) if Dir.exist?(SAML2_CONFIG_DIRECTORY)
end