Skip to content

Commit 61d4be9

Browse files
authored
Merge branch 'main' into delete-events
2 parents 6a0aedf + da85765 commit 61d4be9

File tree

13 files changed

+107
-80
lines changed

13 files changed

+107
-80
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Set up PHP
3030
uses: shivammathur/setup-php@v2
3131
with:
32-
php-version: "7.4"
32+
php-version: "8.3"
3333
coverage: none
3434
tools: phpcs
3535

CONTRIBUTING.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ When submitting pull requests, the pull request should be made to the version yo
88

99
## Conventions
1010

11-
This code base is currently using PHP version 7.4. All files are required to be linted with PSR-12 standard. This repository will automatically check PRs for linting compliance.
11+
This code base is currently using PHP version 8.3. All files are required to be linted with PSR-12 standard. This repository will automatically check PRs for linting compliance.
1212

1313
## Development Environment
1414

@@ -33,8 +33,6 @@ The test environment ships with a number of users that can be used for testing.
3333

3434
The following users are available for testing:
3535

36-
* `[email protected]` - admin user who is a member of pi_user1_domain_edu
37-
* `[email protected]` - admin user
3836
* `[email protected]` - user who is the owner of pi_user1_domain_edu
3937
* `[email protected]` - user who is the owner of pi_user2_domain_edu
4038
* `[email protected]` - user who is a member of pi_user1_domain_edu
@@ -51,4 +49,4 @@ The following users are available for testing:
5149

5250
### Changes to Dev Environment
5351

54-
Should the default schema of the web portal change, the `ldap/bootstrap.ldif` and `sql/bootstrap.sql` must be updated for the LDAP server and the MySQL server, respectively.
52+
Should the default schema of the web portal change, the `ldap/bootstrap.ldif` and `sql/bootstrap.sql` must be updated for the LDAP server and the MySQL server, respectively.

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ 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-
2. `php-curl`
26-
3. `php-redis`
27-
4. `php-cli`
28-
5. `php-mysql`
29-
6. `php-pdo`
30-
2. Composer packages
25+
1. `php-curl`
26+
1. `php-redis`
27+
1. `php-cli`
28+
1. `php-mysql`
29+
1. `php-pdo`
30+
1. Composer packages
3131
1. `cd` to this repository
32-
2. Install packages `composer update`
33-
3. Setup config file `config/config.ini` according to your site deployment
34-
4. Setup branding file `config/branding/config.ini` according to your site deployment
35-
5. Point your web server's document root to `webroot` in this repo
32+
1. Install packages `sudo composer update --no-plugins --no-scripts`
33+
1. Deployment:
34+
1. configure the files in `deployment/` according to their respective `README.md` files
35+
1. Point your web server's document root to `webroot` in this repo
3636

3737
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.
3838

@@ -46,7 +46,7 @@ The update process is similar to the installation process:
4646

4747
1. Clone the release and follow installation instructions 1 and 2 from above.
4848
2. Copy the following folders from the old installation to the new one:
49-
1. `config`
49+
1. `deployment`
5050
2. `webroot/assets/footer_logos`
5151

5252
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.

defaults/config.ini.default

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ user_ou = "ou=users,dc=unityhpc,dc=test" ; User organizational unit
2121
group_ou = "ou=groups,dc=unityhpc,dc=test" ; Group organizational unit
2222
pigroup_ou = "ou=pi_groups,dc=unityhpc,dc=test" ; PI Group organizational unit
2323
orggroup_ou = "ou=org_groups,dc=unityhpc,dc=test" ; ORG group organizational unit
24-
admin_group = "cn=sudo,dc=unityhpc,dc=test" ; admin dn (members of this group are admins on the web portal)
24+
admin_group = "cn=web_admins,dc=unityhpc,dc=test" ; admin dn (members of this group are admins on the web portal)
2525
def_user_shell = "/bin/bash" ; Default shell for new users
2626

2727
[sql]

resources/lib/UnityUser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ public function getHomeDir($ignorecache = false)
555555
}
556556

557557
/**
558-
* Checks if the current account is an admin (in the sudo group)
558+
* Checks if the current account is an admin (in the web_admins group)
559559
*
560560
* @return boolean true if admin, false if not
561561
*/
@@ -572,7 +572,7 @@ public function isAdmin()
572572
*/
573573
public function isPI()
574574
{
575-
return $this->getPIGroup()->exists();
575+
return @$this->getPIGroup()->exists();
576576
}
577577

578578
public function getPIGroup()

tools/docker-dev/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
2-
2+
set -e
33
cd "$(dirname "$0")"
44

55
docker-compose down
66
docker-compose build --no-cache
7-
docker image prune
7+
docker image prune

tools/docker-dev/identity/bootstrap.ldif

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ objectclass: top
1111
objectclass: simpleSecurityObject
1212
objectclass: organizationalRole
1313
userPassword: {SSHA}d6WBSm5wjlNpMwil1KQY+Uo4o/vc6PnR
14+
description: for LDAP server administration purposes, not a valid login to web portal
1415

15-
dn: cn=sudo,dc=unityhpc,dc=test
16-
cn: sudo
16+
dn: cn=web_admins,dc=unityhpc,dc=test
17+
cn: web_admins
1718
gidnumber: 500
1819
memberuid: user1_org1_test
1920
memberuid: user2_org1_test

tools/docker-dev/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
2+
set -e
33
cd "$(dirname "$0")"
44

5-
docker-compose up
5+
docker-compose up

tools/docker-dev/sql/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ RUN apt-get update && apt-get install -y \
55
mariadb-server \
66
mariadb-client \
77
apache2 \
8+
php8.3 \
89
phpmyadmin
910
RUN sed -i '/bind-address/c\bind-address = 0.0.0.0' /etc/mysql/mariadb.conf.d/50-server.cnf
1011
COPY bootstrap.sql /tmp/bootstrap.sql
1112

12-
RUN service mysql start; \
13+
RUN service mariadb start; \
1314
mariadb -e "CREATE DATABASE unity"; \
1415
mariadb -e "CREATE USER 'unity'@'%' IDENTIFIED BY 'password'"; \
1516
mariadb -e "GRANT ALL PRIVILEGES ON unity.* TO 'unity'@'%'"; \
@@ -28,4 +29,4 @@ RUN echo "ServerName 127.0.0.1" >> /etc/apache2/apache2.conf
2829
EXPOSE 80
2930
EXPOSE 3306
3031

31-
CMD apache2ctl -D FOREGROUND & mysqld
32+
CMD apache2ctl -D FOREGROUND & mysqld --user=root

tools/docker-dev/sql/bootstrap.sql

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,59 +24,64 @@ SET time_zone = "+00:00";
2424
CREATE TABLE `account_deletion_requests` (
2525
`id` int(11) NOT NULL,
2626
`timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
27-
`uid` varchar(1000) NOT NULL
27+
`uid` varchar(128) NOT NULL
2828
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
2929

3030
CREATE TABLE `audit_log` (
3131
`id` int(11) NOT NULL,
3232
`timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
33-
`operator` varchar(1000) NOT NULL,
34-
`operator_ip` varchar(1000) NOT NULL,
35-
`action_type` varchar(1000) NOT NULL,
36-
`recipient` varchar(1000) NOT NULL
33+
`operator` varchar(128) NOT NULL,
34+
`operator_ip` varchar(15) NOT NULL,
35+
`action_type` varchar(768) NOT NULL,
36+
`recipient` varchar(128) NOT NULL
37+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
38+
39+
CREATE TABLE user_last_logins (
40+
`operator` varchar(128) NOT NULL,
41+
`last_login` timestamp NOT NULL
3742
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
3843

3944
CREATE TABLE `groupJoinRequests` (
4045
`id` int(11) NOT NULL,
41-
`group_name` varchar(1000) NOT NULL,
42-
`requestor` varchar(1000) NOT NULL,
46+
`group_name` varchar(768) NOT NULL,
47+
`requestor` varchar(768) NOT NULL,
4348
`requested_on` timestamp NOT NULL DEFAULT current_timestamp()
4449
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
4550

4651
CREATE TABLE `groupRequests` (
4752
`id` int(11) NOT NULL,
48-
`group_type` varchar(1000) NOT NULL,
49-
`group_name` varchar(1000) NOT NULL,
50-
`requestor` varchar(1000) NOT NULL,
53+
`group_type` varchar(768) NOT NULL,
54+
`group_name` varchar(768) NOT NULL,
55+
`requestor` varchar(128) NOT NULL,
5156
`requested_on` timestamp NOT NULL DEFAULT current_timestamp(),
5257
`start_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
5358
`end_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
5459
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
5560

5661
CREATE TABLE `groupRoleAssignments` (
5762
`id` int(11) NOT NULL,
58-
`user` varchar(1000) NOT NULL,
59-
`role` varchar(1000) NOT NULL,
60-
`group` varchar(1000) NOT NULL
63+
`user` varchar(128) NOT NULL,
64+
`role` varchar(768) NOT NULL,
65+
`group` varchar(768) NOT NULL
6166
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
6267

6368
CREATE TABLE `groupRoles` (
6469
`id` int(11) NOT NULL,
65-
`name` varchar(1000) NOT NULL,
66-
`slug` varchar(1000) NOT NULL,
70+
`name` varchar(768) NOT NULL,
71+
`slug` varchar(768) NOT NULL,
6772
`priority` int(11) NOT NULL,
68-
`color` varchar(1000) NOT NULL,
69-
`perms` varchar(1000) NOT NULL
73+
`color` varchar(768) NOT NULL,
74+
`perms` varchar(768) NOT NULL
7075
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
7176

7277
CREATE TABLE `groupTypes` (
7378
`id` int(11) NOT NULL,
74-
`name` varchar(1000) NOT NULL,
75-
`slug` varchar(1000) NOT NULL,
76-
`color` varchar(1000) NOT NULL,
79+
`name` varchar(768) NOT NULL,
80+
`slug` varchar(768) NOT NULL,
81+
`color` varchar(768) NOT NULL,
7782
`time_limited` tinyint(1) NOT NULL,
78-
`def_role` varchar(1000) NOT NULL,
79-
`av_roles` varchar(1000) NOT NULL,
83+
`def_role` varchar(768) NOT NULL,
84+
`av_roles` varchar(768) NOT NULL,
8085
`can_request` tinyint(1) NOT NULL
8186
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
8287

@@ -98,20 +103,21 @@ CREATE TABLE `pages` (
98103
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
99104

100105
INSERT INTO `pages` (`id`, `page`, `content`) VALUES
101-
(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>'),
102-
(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>');
106+
(1, 'home', '<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>'),
107+
(2, '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>'),
108+
(3, '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>');
103109

104110
CREATE TABLE `requests` (
105111
`id` int(11) NOT NULL,
106-
`request_for` varchar(1000) NOT NULL,
107-
`uid` varchar(1000) NOT NULL,
112+
`request_for` varchar(131) NOT NULL,
113+
`uid` varchar(128) NOT NULL,
108114
`timestamp` timestamp NOT NULL DEFAULT current_timestamp()
109115
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
110116

111117
CREATE TABLE `sitevars` (
112118
`id` int(11) NOT NULL,
113-
`name` varchar(1000) NOT NULL,
114-
`value` varchar(1000) NOT NULL
119+
`name` varchar(768) NOT NULL,
120+
`value` varchar(768) NOT NULL
115121
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
116122

117123
CREATE TABLE `sso_log` (
@@ -129,6 +135,9 @@ ALTER TABLE `account_deletion_requests`
129135
ALTER TABLE `audit_log`
130136
ADD PRIMARY KEY (`id`);
131137

138+
ALTER TABLE `user_last_logins`
139+
ADD PRIMARY KEY (`operator`);
140+
132141
ALTER TABLE `groupJoinRequests`
133142
ADD PRIMARY KEY (`id`);
134143

@@ -196,6 +205,24 @@ ALTER TABLE `sso_log`
196205
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
197206
COMMIT;
198207

208+
-- --------------------------------------------------------
209+
210+
--
211+
-- automatically update `user_last_logins` from `audit_log`
212+
--
213+
DELIMITER //
214+
CREATE TRIGGER update_last_login
215+
AFTER INSERT ON audit_log
216+
FOR EACH ROW
217+
BEGIN
218+
IF NEW.action_type = 'user_login' THEN
219+
INSERT INTO user_last_logins (operator, last_login)
220+
VALUES (NEW.operator, NEW.timestamp)
221+
ON DUPLICATE KEY UPDATE last_login = NEW.timestamp;
222+
END IF;
223+
END;//
224+
DELIMITER ;
225+
199226
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
200227
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
201228
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

0 commit comments

Comments
 (0)