Brian Lycett 57af7c4e9c
Next release (#151)
* Custom email body (#51)

* get email body from ENV

* read subject from env

* html mail

* replace special string with username and password

* missing ;

* more str_replace

* utf8 in mail

* typo

* docs

* fix var

* count accounts

* fix print

* Add the ability to set the server path.  Get directed to the appropriate module when you log in.

* Fixes to allow overriding attribute labels properly

* Fix server_path in various places, update to cookies use 'samesite', include boostrap and queryjs files so LUM can run without internet access.

* Add support for consuming docker / kubernetes secrets passed as _FILE environment variables (#136)

* mod: condense Dockerfile

* add: _FILE feature
add: list of sensitive env_vars

* mod: sorted env_var list

* add: complete current env_var list

* fix: formatting

* mod: revert Dockerfile to prev. version

* mod: updated comment to be more descriptive
mod: rename variables to be more descriptive

* rem: list of env_var; no longer needed.
mod: env_file_replace function
^ search for all <env_var>_FILE variables and replace
^ <env_var> if the file exists and is not empty
mod: env_file_replace comment

Co-authored-by: pyunramura <jeremy.cummings@live.com>

* Update the README with information on using _FILE

* Change username regex variables

* Named server certs, as suggested by @huzvar

* Update LDAP filter method as suggested by @xgaia

* Feature/http header username (#120)

* Implement Remote Headers Auth

* Hide Logout on Remote Sessions

* Add Explanation for REMOTRE_HTTP_HEADERS_LOGIN settiing

Co-authored-by: Damian Galli <damian.galli@galli.site>

* Updated Readme, fixed random number generation for ARM systems, fixed JS to generate the username

* Fix issues #124 and #126

* Change badges to buttons for list counts

* Don't secretly set displayName

* Add Group Additional (#113)

* Add doku Group additional.

* Read Group additional configuration.

* New group add Additional objectclasses

* Allow for attributes that take multiple values.

* Updated README

* Formatting fixes, fix parsing params from account requests, initial code for the simple interface flag.

* Add attribute fields for groups and allow user-defined attributes to be displayed.  Move alert banner JS to a function.

* Update entries with any missing additional objectclasses when updating entries.  Update README to describe changes. Initial work to allow file uploads for attributes.

* Functionality to upload binary files and display them in the form it's a JPEG.  Added a new page to download existing binary content.

* Bugfixes for compatibility with older osixia/openldap versions.  Change SIMPLE_INTERFACE to SHOW_POSIX_ATTRIBUTES.

* Update version number in README.

Co-authored-by: Monsieur X <xgaia@gmx.com>
Co-authored-by: pyunramura <35285259+pyunramura@users.noreply.github.com>
Co-authored-by: pyunramura <jeremy.cummings@live.com>
Co-authored-by: Damian Galli <da.ga@live.de>
Co-authored-by: Damian Galli <damian.galli@galli.site>
Co-authored-by: huzvar <89766648+huzvar@users.noreply.github.com>
2022-04-12 15:43:21 +01:00

185 lines
5.8 KiB
PHP

<?php
set_include_path( ".:" . __DIR__ . "/../includes/");
session_start();
include_once "web_functions.inc.php";
render_header("$ORGANISATION_NAME - request an account");
if ($ACCOUNT_REQUESTS_ENABLED == FALSE) {
?><div class='alert alert-warning'><p class='text-center'>Account requesting is disabled.</p></div><?php
render_footer();
exit(0);
}
if($_POST) {
$error_messages = array();
if(! isset($_POST['validate']) or strcasecmp($_POST['validate'], $_SESSION['proof_of_humanity']) != 0) {
array_push($error_messages, "The validation text didn't match the image.");
}
if (! isset($_POST['firstname']) or $_POST['firstname'] == "") {
array_push($error_messages, "You didn't enter your first name.");
}
else {
$firstname=filter_var($_POST['firstname'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
}
if (! isset($_POST['lastname']) or $_POST['lastname'] == "") {
array_push($error_messages, "You didn't enter your first name.");
}
else {
$lastname=filter_var($_POST['lastname'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
}
if (isset($_POST['email']) and $_POST['email'] != "") {
$email=filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
}
if (isset($_POST['notes']) and $_POST['notes'] != "") {
$notes=filter_var($_POST['notes'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
}
if (count($error_messages) > 0) { ?>
<div class="alert alert-danger" role="alert">
The request couldn't be sent because:
<p>
<ul>
<?php
foreach($error_messages as $message) {
print "<li>$message</li>\n";
}
?>
</ul>
</div>
<?php
}
else {
$mail_subject = "$firstname $lastname has requested an account for $ORGANISATION_NAME.";
$link_url="${SITE_PROTOCOL}${SERVER_HOSTNAME}${SERVER_PATH}account_manager/new_user.php?account_request&first_name=$firstname&last_name=$lastname&email=$email";
if (!isset($email)) { $email = "n/a"; }
if (!isset($notes)) { $notes = "n/a"; }
$mail_body = <<<EoT
A request for an $ORGANISATION_NAME account has been sent:
<p>
First name: <b>$firstname</b><br>
Last name: <b>$lastname</b><br>
Email: <b>$email</b><br>
Notes: <pre>$notes</pre><br>
<p>
<a href="$link_url">Create this account.</a>
EoT;
include_once "mail_functions.inc.php";
$sent_email = send_email($ACCOUNT_REQUESTS_EMAIL,"$ORGANISATION_NAME account requests",$mail_subject,$mail_body);
if ($sent_email) { ?>
<div class="container">
<div class="col-sm-6 col-sm-offset-3">
<div class="panel panel-success">
<div class="panel-heading">Thank you</div>
<div class="panel-body">
The request was sent and the administrator will process it as soon as possible.
</div>
</div>
</div>
</div>
<?php }
else { ?>
<div class="container">
<div class="col-sm-6 col-sm-offset-3">
<div class="panel panel-danger">
<div class="panel-heading">Error</div>
<div class="panel-body">
Unfortunately the account request wasn't sent because of a technical issue.
</div>
</div>
</div>
</div>
<?php
}
render_footer();
exit(0);
}
}
?>
<div class="container">
<div class="col-sm-8 col-sm-offset-2">
<div class="panel panel-default">
<div class="panel-body">
Use this form to send a request for an account to an administrator at <?php print $ORGANISATION_NAME; ?>.
If the administrator approves your request they'll get in touch with you to give you your new credentials.
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading text-center">Request an account for <?php print $ORGANISATION_NAME; ?></div>
<div class="panel-body text-center">
<form class="form-horizontal" action='' method='post'>
<div class="form-group">
<label for="firstname" class="col-sm-4 control-label">First name</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="firstname" name="firstname" placeholder="Required" <?php if (isset($firstname)) { print "value='$firstname'"; } ?>>
</div>
</div>
<div class="form-group">
<label for="lastname" class="col-sm-4 control-label">Last name</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="lastname" name="lastname" placeholder="Required" <?php if (isset($lastname)) { print "value='$lastname'"; } ?>>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-4 control-label">Email</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="email" name="email" <?php if (isset($email)) { print "value='$email'"; } ?>>
</div>
</div>
<div class="form-group">
<label for="Notes" class="col-sm-4 control-label">Notes</label>
<div class="col-sm-6">
<textarea class="form-control" id="notes" name="notes" placeholder="Enter any extra information you think the administrator might need to know."><?php if (isset($notes)) { print $notes; } ?></textarea>
</div>
</div>
<div class="form-group">
<label for="validate" class="col-sm-4 control-label">Validation</label>
<div class="col-sm-6">
<span class="center-block">
<img src="human.php" class="human-check" alt="Non-human detection">
<button type="button" class="btn btn-default btn-sm" onclick="document.querySelector('.human-check').src = 'human.php?' + Date.now()">
<span class="glyphicon glyphicon-refresh"></span> Refresh
</button>
</span>
<input type="text" class="form-control center-block" id="validate" name="validate" placeholder="Enter the characters from the image">
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default">Send request</button>
</div>
</form>
</div>
</div>
</div>
<?php
render_footer();
?>