Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions manifests/auth/ldap.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
class metrix::auth::ldap {
# We use LDAP auth instead of SAML2 auth, so we can remove all
# code and dependencies related to SAML2
file_line { 'remove_saml2_urls':
ensure => absent,
path => '/var/www/metrix/userportal/urls.py',
match => 'saml2',
match_for_absence => true,
multiple => true,
require => Archive['metrix'],
before => Uv::Venv['metrix_venv'],
}
file_line { 'remove_saml2_10-base':
ensure => absent,
path => '/var/www/metrix/userportal/settings/10-base.py',
match => 'saml2',
match_for_absence => true,
multiple => true,
before => Uv::Venv['metrix_venv'],
}
file { 'remove_40-saml':
ensure => absent,
path => '/var/www/metrix/userportal/settings/40-saml.py',
before => Uv::Venv['metrix_venv'],
}
file_line { 'cffi':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^cffi',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'cryptography':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^cryptography',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'defusedxml':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^defusedxml',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'djangosaml2':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^djangosaml2',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'elementpath':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^elementpath',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'pycparser':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^pycparser',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'pyparsing':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^pyparsing',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'pysaml2':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^pysaml2',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'pyOpenSSL':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^pyOpenSSL',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'xmlschema':
ensure => absent,
path => '/var/www/metrix/requirements.txt',
match => '^xmlschema',
match_for_absence => true,
before => Uv::Venv['metrix_venv'],
}
file_line { 'django-auth-ldap':
line => 'django-auth-ldap',
path => '/var/www/metrix/requirements.txt',
before => Uv::Venv['metrix_venv'],
}

file { '/var/www/metrix/userportal/settings/92-local_ldap.py':
show_diff => false,
content => epp('metrix/92-local_ldap.py',
{
}
),
owner => 'apache',
group => 'apache',
mode => '0600',
require => Class['metrix::install'],
}
}
47 changes: 47 additions & 0 deletions manifests/auth/saml2.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class metrix::auth::saml2 (
String $ssl_private_key,
String $ssl_public_cert,
String $idp_metadata,
Array[String] $extra_required_attributes = [],
Array[Hash[String, String]] $staff_attributes = [],
Array[Hash[String, String]] $required_access_attributes = [],
) {
ensure_packages(['libffi-devel', 'xmlsec1', 'xmlsec1-openssl'])

file { '/var/www/metrix/saml2-private.key':
content => $ssl_private_key,
mode => '0400',
owner => 'apache',
group => 'apache',
require => File['/var/www/metrix'],
}
file { '/var/www/metrix/saml2-public.pem':
content => $ssl_public_cert,
mode => '0422',
owner => 'apache',
group => 'apache',
require => File['/var/www/metrix'],
}
file { '/var/www/metrix/idp_metadata.xml':
content => $idp_metadata,
mode => '0422',
owner => 'apache',
group => 'apache',
require => File['/var/www/metrix'],
}

file { '/var/www/metrix/userportal/settings/92-local_saml2.py':
show_diff => false,
content => epp('metrix/92-local_saml2.py',
{
'extra_required_attributes' => $extra_required_attributes,
'staff_attributes' => $staff_attributes,
'required_access_attributes' => $required_access_attributes
}
),
owner => 'apache',
group => 'apache',
mode => '0600',
require => Class['metrix::install'],
}
}
60 changes: 40 additions & 20 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,51 @@
String $cluster_name,
String $subdomain,
String $slurm_user = 'slurm',
String $ssl_private_key_file = '/etc/ssl/metrix.private.key',
String $ssl_public_cert_file = '/etc/ssl/metrix.public.cert',
Enum['ldap', 'saml2'] $auth_type = 'ldap',
Array[Hash[String, String]] $staff_attributes = [],
Array[Hash[String, String]] $required_access_attributes = [],
Optional[String] $slurm_db_ip = undef,
Optional[Integer] $slurm_db_port = undef,
Optional[String] $ssl_private_key = undef,
Optional[String] $ssl_public_cert = undef,
Optional[String] $idp_metadata = undef,
) {
include metrix::install
case $auth_type {
'ldap': {
include metrix::auth::ldap
}
'saml2': {
include metrix::auth::saml2
}
default: {
fail('Unsupported auth_type')
}
}

file { '/var/www/metrix/userportal/settings/99-local.py':
file { '/var/www/metrix/userportal/settings/91-local.py':
show_diff => false,
content => epp('metrix/99-local.py',
content => epp('metrix/91-local.py',
{
'password' => $password,
'slurm_user' => $slurm_user,
'slurm_password' => $slurm_password,
'cluster_name' => $cluster_name,
'secret_key' => stdlib::seeded_rand_string(32, $password),
'domain_name' => $domain_name,
'subdomain' => $subdomain,
'logins' => $logins,
'prometheus_ip' => $prometheus_ip,
'prometheus_port' => $prometheus_port,
'db_ip' => $db_ip,
'db_port' => $db_port,
'slurm_db_ip' => pick($slurm_db_ip, $db_ip),
'slurm_db_port' => pick($slurm_db_port, $db_port),
'base_dn' => $base_dn,
'ldap_password' => $ldap_password,
'password' => $password,
'slurm_password' => $slurm_password,
'cluster_name' => $cluster_name,
'secret_key' => seeded_rand_string(32, $password),
'domain_name' => $domain_name,
'subdomain' => $subdomain,
'logins' => $logins,
'prometheus_ip' => $prometheus_ip,
'prometheus_port' => $prometheus_port,
'db_ip' => $db_ip,
'db_port' => $db_port,
'slurm_db_ip' => pick($slurm_db_ip, $db_ip),
'slurm_db_port' => pick($slurm_db_port, $db_port),
'base_dn' => $base_dn,
'ldap_password' => $ldap_password,
'staff_attributes' => $staff_attributes,
'required_access_attributes' => $required_access_attributes,
}
),
owner => 'apache',
Expand Down Expand Up @@ -85,7 +105,7 @@
subscribe => [
Mysql::Db['metrix'],
Class['metrix::install'],
File['/var/www/metrix/userportal/settings/99-local.py'],
File['/var/www/metrix/userportal/settings/91-local.py'],
File['/var/www/metrix/userportal/local.py'],
],
notify => Service['metrix'],
Expand All @@ -98,7 +118,7 @@
'/opt/software/metrix-env/bin',
],
require => [
File['/var/www/metrix/userportal/settings/99-local.py'],
File['/var/www/metrix/userportal/settings/91-local.py'],
File['/var/www/metrix/userportal/local.py'],
Class['metrix::install'],
],
Expand Down
Loading