Skip to content

Commit 8afd7ac

Browse files
authored
Merge pull request #57 from hakasapl/main
Release 1.1.0 Preparation
2 parents 7ba4bba + 077a76f commit 8afd7ac

File tree

16 files changed

+165
-49
lines changed

16 files changed

+165
-49
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ resources/custom_user_mappings/*.csv
1010

1111
# don't track vendor files from composer
1212
vendor
13-
composer.lock
13+
composer.lock
14+
15+
# don't track site configs
16+
config/**/*.ini

CHANGELOG.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1-
## 1.0.0-RC2
1+
# 1.1.0
2+
3+
2023-3-13
4+
5+
* [Feature] Added alternate config email for PI emails (#35)
6+
* [Feature] Pasted and Uploaded SSH Keys are now validated (#17)
7+
* [Feature] Added request date for requests on admin/pi pages (#40)
8+
* [Feature] Added conf options and login selector to user accounts page (#15)
9+
* [Feature] Added PIGroups in User for view for admins (#29)
10+
* [Feature] It is now possible to override mail templates
11+
* [Frontend] Removed borders in between footer logos (#46)
12+
* [Frontend] Added a new content management field for home page (#45)
13+
* [Bug] Admin pages are now sorted alphabetically by UID (#52)
14+
* [Bug] Fixed footer lookup PHP error for sending emails
15+
* [Bug] Fixed changelog format
16+
* [Bug] Fixed styling on content management page (#20)
17+
* [Project] Footers in the project are now generic
18+
* [Project] Default configs do not reference UMA labels anymore
19+
20+
# 1.0.0-RC2
21+
22+
2022-10-03
23+
224
* [BugFix] Fixed Unity Branding where Array were not being merged
325
* [Project] Bumped phpopenldaper version from composer
426

5-
## 1.0.0-RC1
27+
# 1.0.0-RC1
28+
629
* [Feature] Admins can now access the web portal as a separate user
730
* [Feature] Added account details to account settings page
831
* [Feature] Added branding configuration
@@ -21,7 +44,8 @@
2144
* [Project] Project now adheres to PHP PSR-12 standards
2245

2346

24-
## 0.6.0-BETA
47+
# 0.6.0-BETA
48+
2549
* [Feature] Added cluster notices - hakan
2650
* [Feature] Added development environment features - hakan
2751
* [Feature] Added universal logging support - hakan
@@ -31,7 +55,8 @@
3155
* [Bug] Fixed issue which caused PI already exists message to not display correctly - calvin
3256
* [UI] Added URI branding - hakan
3357

34-
## 0.5.0-BETA
58+
# 0.5.0-BETA
59+
3560
* [Feature] Added notices for inactive account
3661
* [Locale] New XML based locale for easier dynamic lang switching
3762
* [Feature] Added VAST storage and Truenas Core storage integration for automatic storage creation
@@ -41,9 +66,11 @@
4166
* [Style] General style changes
4267
* [Feature] Added unityfs service, which is a socket service responsible for provisioning storage on Unity
4368

44-
## 0.4.0HF1-BETA
69+
# 0.4.0HF1-BETA
70+
4571
* [Bug] Fixed issue where some users account wasn't activating
4672

47-
## 0.4.0-BETA
73+
# 0.4.0-BETA
74+
4875
* [Feature] Added Multiple PI Support
4976
* [Backend] Users and PI Groups are treated as different entities

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,45 @@ Unity Web Portal is a PHP application built in top of MariaDB and LDAP which act
2222
1. Composer (`apt install composer` on Ubuntu)
2323
1. PHP Extensions
2424
1. `php-ldap`
25-
1. Composer packages
25+
2. `php-curl`
26+
2. Composer packages
2627
1. `cd` to this repository
27-
1. Install packages `composer update`
28-
1. Setup config file `config/config.ini` according to your site deployment
29-
1. Point your web server's document root to `webroot` in this repo
28+
2. Install packages `composer update`
29+
3. Setup config file `config/config.ini` according to your site deployment
30+
4. Setup branding file `config/branding/config.ini` according to your site deployment
31+
5. Point your web server's document root to `webroot` in this repo
3032

3133
The scope of this project ends at being responsible for the LDAP user database. We recommend production deployments to set up scripts which detect changes in LDAP and then perform further actions. For example, a script can be used to create Slurm scheduler accounting roles based on the LDAP information created by this website.
3234

3335
## Web Server Setup
3436
External to this codebase, you must configure authentication using your web server. You must retrict the following:
3537
* `/panel` - users who are signed in
3638
* `/admin` - admins who are signed in
39+
40+
## Updating
41+
The update process is similar to the installation process:
42+
43+
1. Clone the release and follow installation instructions 1 and 2 from above.
44+
2. Copy the following folders from the old installation to the new one:
45+
1. `config`
46+
2. `webroot/res/footer_logos`
47+
48+
We recommend a deployment where each version of the portal is its own clone, then just change a symlink to point to the new version. This way a rollback is much easier.
49+
50+
Example folder structure, where `->` indicates a symlink:
51+
```
52+
unity-web-portal
53+
unity-web-portal -> unity-web-portal-1.1.0
54+
unity-web-portal-1.0.0-RC1
55+
unity-web-portal-1.0.0-RC2
56+
unity-web-portal-1.1.0
57+
```
58+
59+
Below you will find specific instructions for moving between version:
60+
61+
### 1.0.0-RC2 > 1.1.0
62+
63+
1. `config/branding/config.ini.default` has some new fields that will need to be overriden by the site config if needed:
64+
1. `pi_approve*` in the `mail` section
65+
2. `home` in the `page` section
66+
3. The entire `loginshell` section

config/branding/config.ini renamed to config/branding/config.ini.default

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
; Branding Defaults
2+
; DO NOT EDIT THIS FILE. Instead make a config.ini in the same location as this file
3+
;
14
[site]
25
name = "Unity Cluster" ; Name of the website
36
url = "https://127.0.0.1:8000/" ; URL of the website
@@ -19,8 +22,8 @@ accent_3 = "#a92323" ; Active element color for element using accent color
1922
accent_disabled = "#e48181" ; Disabled element color for element using accent color
2023
accent_foreground = "#ffffff" ; Text color when accent color is background
2124

22-
[footer]
23-
logos[] = "testLongFooter.png" ; Footer logos (add new lines for each)
25+
[footer] ; Footer logos (add new lines for each)
26+
logos[] = "testLongFooter.png"
2427
links[] = "https://github.com/"
2528
title[] = "Test Long Footer"
2629
logos[] = "testMedFooter.png"
@@ -33,7 +36,7 @@ logos[] = "testMedFooter.png"
3336
links[] = "https://github.com/"
3437
title[] = "Test Medium Footer"
3538

36-
[loginshell] ; menu items, Login Shells
39+
[loginshell] ; Login shells that show up as options in the account settings page
3740
shell[] = "/bin/bash"
3841
shell[] = "/bin/zsh"
3942

@@ -46,13 +49,13 @@ labels[] = "Secure Menuitem 1"
4649
links[] = "https://github.com/"
4750

4851
[mail] ; mail addresses
49-
support = "[email protected]"
52+
support = "[email protected]" ; Email for user support
5053
support_name = "Unity Support"
51-
54+
admin = "[email protected]" ; Email that goes to admins about site messages
5255
admin_name = "Unity Admins"
53-
56+
sender = "[email protected]" ; The "from" email for all messages sent from the portal
5457
sender_name = "Unity Sender"
55-
pi_approve = "[email protected]"
58+
pi_approve = "[email protected]" ; Only PI approval messages will go to this email
5659
pi_approve_name = "Unity PI Approval"
5760

5861
[page] ; which sql objects to use for the content on these pages

config/config.ini renamed to config/config.ini.default

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
; Main Site Config
2+
; DO NOT EDIT THIS FILE. Instead make a config.ini file in the same folder.
3+
;
14
[upstream]
2-
version = "1.0.0-RC2" ; Current upstream version of the web portal
3-
repo = "https://github.com/hakasapl/unity-web-portal" ; Upstream URL for the web portal
5+
version = "1.1.0" ; Current upstream version of the web portal
6+
repo = "https://github.com/UnityHPC/unity-web-portal" ; Upstream URL for the web portal
47

58
[site]
69
prefix = "" ; prefix of website, no ending / should be included

config/mail_overrides/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Mail Overrides
2+
3+
In this location, you can copy any file in the resources/mail folder into here and modify it. **The filename must remain the same**

resources/init.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//
2323
// Config INIT
2424
//
25-
$CONFIG = UnitySite::getConfig(__DIR__ . "/../config/config.ini");
25+
$CONFIG = UnitySite::getConfig(__DIR__ . "/../config");
2626
$BRANDING = UnityBranding::getBranding(__DIR__ . "/../config/branding");
2727

2828
//
@@ -54,6 +54,7 @@
5454
// Creates SMTP service
5555
$MAILER = new UnityMailer(
5656
__DIR__ . "/mail",
57+
__DIR__ . "/../config/mail_overrides",
5758
$CONFIG["smtp"]["host"],
5859
$CONFIG["smtp"]["port"],
5960
$CONFIG["smtp"]["security"],

resources/lib/UnityBranding.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ class UnityBranding
77
public static function getBranding($branding_loc)
88
{
99
// Loading branding
10-
$BRANDING = parse_ini_file($branding_loc . "/config.ini", true);
10+
$BRANDING = parse_ini_file($branding_loc . "/config.ini.default", true);
11+
$branding_main_override = $branding_loc . "/config.ini";
12+
if (file_exists($branding_main_override)) {
13+
$override_config_main = parse_ini_file($branding_main_override, true);
14+
$BRANDING = array_replace_recursive($BRANDING, $override_config_main);
15+
}
1116

1217
$branding_override = $branding_loc . "/overrides/" . $_SERVER['HTTP_HOST'] . ".ini";
1318
if (file_exists($branding_override)) {

resources/lib/UnityMailer.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
class UnityMailer extends PHPMailer
1212
{
1313
private $template_dir; // location of all email templates
14+
private $override_template_dir;
1415

1516
private $MSG_LINKREF;
1617
private $MSG_SENDER_EMAIL;
@@ -24,6 +25,7 @@ class UnityMailer extends PHPMailer
2425

2526
public function __construct(
2627
$template_dir,
28+
$override_template_dir,
2729
$hostname,
2830
$port,
2931
$security,
@@ -83,6 +85,7 @@ public function __construct(
8385
}
8486

8587
$this->template_dir = $template_dir;
88+
$this->override_template_dir = $override_template_dir;
8689

8790
$this->MSG_LINKREF = $msg_linkref;
8891
$this->MSG_SENDER_EMAIL = $msg_sender_email;
@@ -102,10 +105,24 @@ public function sendMail($recipients, $template = null, $data = null)
102105
$this->setFrom($this->MSG_SENDER_EMAIL, $this->MSG_SENDER_NAME);
103106
$this->addReplyTo($this->MSG_SUPPORT_EMAIL, $this->MSG_SUPPORT_NAME);
104107

108+
// find mail template
109+
$template_filename = $template . ".php";
110+
if (file_exists($this->override_template_dir . "/" . $template_filename)) {
111+
$template_path = $this->override_template_dir . "/" . $template_filename;
112+
} else {
113+
$template_path = $this->template_dir . "/" . $template_filename;
114+
}
115+
116+
// find footer template
117+
if (file_exists($this->override_template_dir . "/footer.php")) {
118+
$footer_template_path = $this->override_template_dir . "/footer.php";
119+
} else {
120+
$footer_template_path = $this->template_dir . "/footer.php";
121+
}
105122

106123
ob_start();
107-
include $this->template_dir . "/" . $template . ".php";
108-
include $this->template_dir . "/footer.php";
124+
include $template_path;
125+
include $footer_template_path;
109126
$mes_html = ob_get_clean();
110127
$this->msgHTML($mes_html);
111128

resources/lib/UnitySite.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ public static function getGithubKeys($username)
4949

5050
public static function getConfig($conf_path)
5151
{
52-
$arr = parse_ini_file($conf_path, true);
52+
// load default conf values
53+
$arr = parse_ini_file($conf_path . "/config.ini.default", true);
54+
55+
if (file_exists($conf_path . "/config.ini")) {
56+
// check if there is an override
57+
$arr_override = parse_ini_file($conf_path . "/config.ini", true);
58+
array_replace_recursive($arr, $arr_override);
59+
}
60+
5361
return $arr;
5462
}
5563

tools/docker-dev/sql/bootstrap.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ CREATE TABLE `pages` (
7575

7676
INSERT INTO `pages` (`id`, `page`, `content`) VALUES
7777
(1, 'support', '<h3>Docmentation and FAQ</h3>\r\n<p>You can find our documentation <a href=\"https://esdconfluence.it.umass.edu/confluence/display/UNITY/Unity+Cluster+Documentation+Home\" target=\"_blank\">here</a>. We also have an <a target=\"_blank\" href=\"https://esdconfluence.it.umass.edu/confluence/display/UNITY/Frequently+Asked+Questions\">FAQ</a> page which could help answer quick questions.\r\n\r\n<h3>Office Hours</h3>\r\n<p>We offer office hours every week on <strong>Tuesdays 2-4 PM</strong> in-person at <strong>W.E.B. DuBois Library 786</strong> or remote on <strong><a target=\"_blank\" href=\"https://umass-amherst.zoom.us/j/95663998309\">Zoom</a></strong>. Be sure to check the <a href=\"<?php echo $CONFIG[\"site\"][\"prefix\"]; ?>/index.php\">cluster notes</a> page for up-to-date information on any canceled/delayed office hours.</p>\r\n\r\n<h3>Support Email</h3>\r\n<p>You can create a support ticket by emailing <a target=\"_blank\" href=\"mailto:[email protected]\">[email protected]</a>. We will do our best to reply as fast as possible!</p>'),
78-
(2, 'policy', '<p>By using resources associated with Unity, you agree to comply with the following conditions of use. This is an extension of the University of Massachussetts Amherst Information Technology Acceptable Use Policy, which can be found <a target=\"_blank\" href=\"https://www.umass.edu/it/security/acceptable-use-policy\">here</a>.</p>\r\n\r\n<ol>\r\n <li>You will not use Unity resources for illicit financial gain, such as virtual currency mining, or any unlawful purpose, nor attempt to breach or circumvent any Unity administrative or security controls. You will comply with all applicable laws, working with your home institution and the specific Unity service providers utilized to determine what constraints may be placed on you by any relevant regulations such as export control law or HIPAA.</li>\r\n <li>You will respect intellectual property rights and observe confidentiality agreements.</li>\r\n <li>You will protect the access credentials (e.g., passwords, private keys, and/or tokens) issued to you or generated to access Unity resources; these are issued to you for your sole use.</li>\r\n <li>You will immediately report any known or suspected security breach or loss or misuse of Unity access credentials to <a href=\"mailto:[email protected]\">[email protected]</a>.</li>\r\n <li>You will have only one Unity User account and will keep your profile information up-to-date.</li>\r\n <li>Use of resources and services through Unity is at your own risk. There are no guarantees that resources and services will be available, that they will suit every purpose, or that data will never be lost or corrupted. Users are responsible for backing up critical data.</li>\r\n <li>Logged information, including information provided by you for registration purposes, is used for administrative, operational, accounting, monitoring and security purposes. This information may be disclosed, via secured mechanisms, only for the same purposes and only as far as necessary to other organizations cooperating with Unity .</li>\r\n</ol>\r\n\r\n<p>The Unity team reserves the right to restrict access to any individual/group found to be in breach of the above.</p>');
78+
(2, 'policy', '<p>By using resources associated with Unity, you agree to comply with the following conditions of use. This is an extension of the University of Massachussetts Amherst Information Technology Acceptable Use Policy, which can be found <a target=\"_blank\" href=\"https://www.umass.edu/it/security/acceptable-use-policy\">here</a>.</p>\r\n\r\n<ol>\r\n <li>You will not use Unity resources for illicit financial gain, such as virtual currency mining, or any unlawful purpose, nor attempt to breach or circumvent any Unity administrative or security controls. You will comply with all applicable laws, working with your home institution and the specific Unity service providers utilized to determine what constraints may be placed on you by any relevant regulations such as export control law or HIPAA.</li>\r\n <li>You will respect intellectual property rights and observe confidentiality agreements.</li>\r\n <li>You will protect the access credentials (e.g., passwords, private keys, and/or tokens) issued to you or generated to access Unity resources; these are issued to you for your sole use.</li>\r\n <li>You will immediately report any known or suspected security breach or loss or misuse of Unity access credentials to <a href=\"mailto:[email protected]\">[email protected]</a>.</li>\r\n <li>You will have only one Unity User account and will keep your profile information up-to-date.</li>\r\n <li>Use of resources and services through Unity is at your own risk. There are no guarantees that resources and services will be available, that they will suit every purpose, or that data will never be lost or corrupted. Users are responsible for backing up critical data.</li>\r\n <li>Logged information, including information provided by you for registration purposes, is used for administrative, operational, accounting, monitoring and security purposes. This information may be disclosed, via secured mechanisms, only for the same purposes and only as far as necessary to other organizations cooperating with Unity .</li>\r\n</ol>\r\n\r\n<p>The Unity team reserves the right to restrict access to any individual/group found to be in breach of the above.</p>'),
79+
(3, 'home', '<p>Home page content</p><p>Other line</p>');
7980

8081
-- --------------------------------------------------------
8182

webroot/admin/content.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@
3030
?>
3131
</select>
3232

33+
<br><br>
34+
3335
<textarea name="content" id="editor" form="pageForm"></textarea>
3436

37+
<br><br>
38+
3539
<input type="submit" value="Edit Page">
3640
</form>
3741

42+
3843
<script>
3944
ClassicEditor
4045
.create(document.querySelector('#editor'), {})

webroot/admin/pi-mgmt.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,30 @@
115115
<?php
116116
$accounts = $LDAP->getAllPIGroups($SQL, $MAILER);
117117

118-
foreach ($accounts as $pi_group) {
119-
$pi_user = $pi_group->getOwner();
120-
121-
echo "<tr class='expandable'>";
122-
echo "<td><button class='btnExpand'>&#9654;</button>" . $pi_user->getFirstname() .
123-
" " . $pi_user->getLastname() . "</td>";
124-
echo "<td>" . $pi_group->getPIUID() . "</td>";
125-
echo "<td><a href='mailto:" . $pi_user->getMail() . "'>" . $pi_user->getMail() . "</a></td>";
126-
echo "<td>";
127-
echo
128-
"<form action='' method='POST'
118+
usort($accounts, function ($a, $b) {
119+
return strcmp($a->getPIUID(), $b->getPIUID());
120+
});
121+
122+
foreach ($accounts as $pi_group) {
123+
$pi_user = $pi_group->getOwner();
124+
125+
echo "<tr class='expandable'>";
126+
echo "<td><button class='btnExpand'>&#9654;</button>" . $pi_user->getFirstname() .
127+
" " . $pi_user->getLastname() . "</td>";
128+
echo "<td>" . $pi_group->getPIUID() . "</td>";
129+
echo "<td><a href='mailto:" . $pi_user->getMail() . "'>" . $pi_user->getMail() . "</a></td>";
130+
echo "<td>";
131+
echo
132+
"<form action='' method='POST'
129133
onsubmit='return confirm(\"Are you sure you want to remove " . $pi_group->getPIUID() . "?\")'>
130134
<input type='hidden' name='form_name' value='remGroup'>
131135
<input type='hidden' name='pi' value='" . $pi_group->getPIUID() . "'>
132136
<input type='submit' value='Remove'>
133137
</form>";
134-
echo "</td>";
135-
echo "</tr>";
136-
}
137-
?>
138+
echo "</td>";
139+
echo "</tr>";
140+
}
141+
?>
138142
</table>
139143

140144
<script>

webroot/admin/user-mgmt.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
<?php
3939
$users = $LDAP->getAllUsers($SQL, $MAILER);
4040

41+
usort($users, function ($a, $b) {
42+
return strcmp($a->getUID(), $b->getUID());
43+
});
44+
4145
foreach ($users as $user) {
4246
echo "<tr>";
4347
echo "<td>" . $user->getFirstname() . " " . $user->getLastname() . "</td>";

0 commit comments

Comments
 (0)