Building on the discussion in this thread…
Most of my users are remote. They don’t have VPN access to my network, and I don’t particularly want to give it to them. I also don’t want to make the server manager available to the entire Internet. Fortunately, on that thread, @dnutan pointed out Self-Service Password (SSP), a web app designed to do this very thing. So here are some notes on setting it up on Nethserver 7.6.
NOTE: At present, these instructions (and templates) work only with local OpenLDAP authentication–not with Active Directory, and not with remote OpenLDAP servers.
Install Self-Service Password
You’ll first need to add the LDAP Tool Box repository. To do that, using your favorite editor, create /etc/yum.repos.d/ltb-project.repo
with the following contents:
[ltb-project-noarch]
name=LTB project packages (noarch)
baseurl=https://ltb-project.org/rpm/$releasever/noarch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LTB-project
Then run the following commands:
rpm --import https://ltb-project.org/wiki/lib/RPM-GPG-KEY-LTB-project
yum update
yum install nethserver-rh-php71-php-fpm self-service-password
Create Templates
You’ll need to create three template fragments. For the first, do
nano /etc/e-smith/templates/etc/httpd/conf.d/default-virtualhost.inc/50selfservicepassword
…with the following contents:
{
my $path = $ssp{DefaultPath} || '/ssp';
my $status = $ssp{UseDefaultHost} || 'enabled';
$OUT .= <<EOF;
#
# 50selfservicepassword
#
EOF
if ( $status eq 'enabled' ) {
$OUT .= <<EOF
Alias $path /usr/share/self-service-password
<Directory /usr/share/self-service-password>
<FilesMatch \\.php\$>
SetHandler "proxy:fcgi://127.0.0.1:9001"
</FilesMatch>
AllowOverride None
Require all granted
DirectoryIndex index.php
AddDefaultCharset UTF-8
</Directory>
<Directory /usr/share/self-service-password/scripts>
AllowOverride None
Require all denied
</Directory>
EOF
}
}
For the second template, run
mkdir -p /etc/e-smith/templates/etc/httpd/conf.d/self-service-password.conf
nano /etc/e-smith/templates/etc/httpd/conf.d/self-service-password.conf/10main
…with the following contents:
{
my $status = $ssp{UseVhost} || 'disabled';
my $vhost = $ssp{VHostName} || 'ssp.'.$DomainName;
$OUT .= "\n";
if ( $status eq 'enabled' ) {
$OUT .= <<EOF
<VirtualHost *:80>
DocumentRoot "/usr/share/self-service-password"
ServerName $vhost
RewriteEngine on
RewriteRule ^/\\.well-known/ - [L]
RewriteRule (.*) https://$vhost\$1 [R,L]
Alias "/.well-known/acme-challenge/" "/var/www/html/.well-known/acme-challenge/"
<Directory "/var/www/html/.well-known/acme-challenge/">
Require all granted
Options -Indexes -FollowSymLinks
AllowOverride None
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName $vhost
DocumentRoot /usr/share/self-service-password
DirectoryIndex index.php
AddDefaultCharset UTF-8
SSLEngine on
<FilesMatch \\.php\$>
SetHandler "proxy:fcgi://127.0.0.1:9001"
</FilesMatch>
<Directory /usr/share/self-service-password>
AllowOverride None
Require all granted
</Directory>
<Directory /usr/share/self-service-password/scripts>
AllowOverride None
Require all denied
</Directory>
LogLevel warn
ErrorLog /var/log/httpd/ssp_error_log
CustomLog /var/log/httpd/ssp_access_log combined
</VirtualHost>
EOF
}
}
Finally, the third template. Run
mkdir -p /etc/e-smith/templates/usr/share/self-service-password/conf/config.inc.local.php
touch /etc/e-smith/templates/usr/share/self-service-password/conf/config.inc.local.php/template-begin
nano /etc/e-smith/templates/usr/share/self-service-password/conf/config.inc.local.php/10main
…with the following contents:
{
my @chars = ("A".."Z", "a".."z", "0".."9");
my $secret;
$secret .= $chars[rand @chars] for 1..12;
my $lang = ($ssp{lang} || 'en');
my $email = ($ssp{'UseEmail'} || 'false');
$OUT .= <<EOF;
<?php
/*
/usr/share/self-service-password/conf/config.inc.local.php
*/
\$lang = "$lang";
\$show_menu = true;
\$use_questions = false;
\$use_sms = false;
\$pwd_show_policy = "always";
\$pwd_show_policy_pos = "above";
\$keyphrase = "$secret";
\$use_tokens = $email;
EOF
if ( $email eq 'true') {
$OUT .= <<EOF;
\$mail_address_use_ldap = true;
\$mail_attribute = "mail";
\$crypt_tokens = true;
\$token_lifetime = "900";
\$mail_sendmailpath = '/usr/sbin/sendmail';
\$mail_protocol = 'sendmail';
\$mail_smtp_debug = 0;
\$mail_debug_format = 'html';
\$mail_contenttype = 'text/plain';
\$mail_wordwrap = 0;
\$mail_charset = 'utf-8';
\$mail_priority = 3;
\$mail_newline = PHP_EOL;
\$notify_on_change = true;
EOF
}
if ($passwordstrength{Users} eq 'none') {
$OUT .= <<EOF;
\$pwd_min_length = 7;
EOF
}
elsif ($passwordstrength{Users} eq 'strong') {
$OUT .= <<EOF;
\$pwd_min_length = 7;
\$pwd_min_lower = 1;
\$pwd_min_upper = 1;
\$pwd_min_digit = 1;
\$pwd_min_special = 1;
\$pwd_complexity = 4;
\$use_pwnedpasswords = true;
EOF
}
if ($sssd{Provider} eq 'ldap') {
$OUT .= <<EOF;
\$ldap_binddn = "";
\$ldap_bindpw = "";
\$ldap_base = "dc=directory,dc=nh";
\$ldap_filter = "(&(objectClass=person)(uid={login})(!(uid=admin)))";
\$who_change_password = "user";
EOF
}
elsif ($sssd{Provider} eq 'ad') {
$OUT .= <<EOF;
\$ad_mode = true;
\$ldap_starttls = false;
\$ldap_url = "$sssd{LdapURI}";
\$ldap_binddn = "$sssd{BindDN}";
\$ldap_bindpw = "$sssd{BindPassword}";
\$ldap_base = "dc=ad,dc=domain,dc=local";
\$ldap_login_attribute = "sAMAccountName";
\$ldap_fullname_attribute = "cn";
\$ldap_filter = "(&(objectClass=user)(sAMAccountName={login})(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
\$who_change_password = "manager";
EOF
}
}
Configure (if desired)
These templates will let you configure SSP to be accessible at a path under your main domain (e.g., www.yourdomain.com/ssp), a separate virtual host (e.g., ssp.yourdomain.com), or both. By default, SSP will be accessible at the path of /ssp under your default virtual host, but will not be available on its own virtual host. To change either of these, first run config set ssp configuration
. Then:
- To change the name of the path (for example, to make SSP available on www.yourdomain.com/password), run
config setprop ssp DefaultPath /password
. - To make SSP unavailable on the default virtual host, run
config setprop ssp UseDefaultHost disabled
. - To enable a separate virtual host for SSP, run
config setprop ssp UseVhost enabled
. By default, it will be available at ssp.yourdomain.com - To change the virtual host name, run
config setprop ssp VHostName password.yourdomain.com
(to set it to password.yourdomain.com).
NOTE: The SSP virtual host requires SSL, and there is no configuration option to remove that requirement. This means that whatever hostname you choose for that virtual host will need to appear on your certificate.
Also, there’s an option for SSP to use email. This will send users email notifications when their passwords are changed. The hope is for this to also allow users to reset their passwords using email tokens, but that isn’t currently implemented. To enable this, run config setprop ssp UseEmail true
.
Expand the templates
expand-template /etc/httpd/conf.d/default-virtualhost.inc
expand-template /etc/httpd/conf.d/self-service-password.conf
expand-template /usr/share/self-service-password/conf/config.inc.local.php
systemctl reload httpd
Change a password!
Browse to the appropriate URL, and you’ll see this page:
Pick a user and go. For security reasons, you can’t reset the admin user’s password using this system.