Compare commits
1 Commits
main
...
move-to-po
| Author | SHA1 | Date | |
|---|---|---|---|
|
ecdb89c096
|
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# this is a development container, not hardened for hosting
|
||||||
|
FROM php:7.4-cli
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y \
|
||||||
|
sqlite3 \
|
||||||
|
unzip \
|
||||||
|
git
|
||||||
32
README.md
32
README.md
@@ -4,8 +4,36 @@
|
|||||||
A website created with the latest and greatest web technologies.
|
A website created with the latest and greatest web technologies.
|
||||||
May contain blackjack and other things one tends to include in awesome projects.
|
May contain blackjack and other things one tends to include in awesome projects.
|
||||||
|
|
||||||
See [Getting Started](./docs/getting-started.md) for help to hack on the project.
|
## Installation
|
||||||
|
|
||||||
|
git clone --recursive https://github.com/Programvareverkstedet/nettsiden.git
|
||||||
|
|
||||||
|
Put it in a folder your webserver can find.
|
||||||
|
|
||||||
|
## Development setup
|
||||||
|
|
||||||
|
The development environment can be setup with:
|
||||||
|
|
||||||
|
nix develop
|
||||||
|
|
||||||
|
For this you will need to install the nix package manager and possibly set the experimental features in your nix config, likely located at /etc/nix/nix.conf or $HOME/.config/nix/nix.conf.
|
||||||
|
|
||||||
|
Installing nix with your package manager might not work without some tweaking, but the upstream script should just work which you can find [here](https://nixos.org/download/).
|
||||||
|
|
||||||
|
experimental-features = flakes nix-command
|
||||||
|
|
||||||
|
You can then run the server with:
|
||||||
|
|
||||||
|
runDev
|
||||||
|
|
||||||
|
### Admin account
|
||||||
|
|
||||||
|
Login goes through `idp.pvv.ntnu.no` via SAML, so you have to use your PVV account.
|
||||||
|
(This only works if you use access the local development site via the the hostname `localhost`)
|
||||||
|
To make your account into an admin account, run:
|
||||||
|
|
||||||
|
sqlite3 pvv.sqlite "INSERT INTO users (uname, groups) VALUES ('YOUR_USERNAME', 1);"
|
||||||
|
|
||||||
## Hosting
|
## Hosting
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
6
dist/sql/pvv_mysql.sql → dist/pvv_mysql.sql
vendored
6
dist/sql/pvv_mysql.sql → dist/pvv_mysql.sql
vendored
@@ -12,7 +12,7 @@ CREATE TABLE projects (
|
|||||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||||
`name` TEXT,
|
`name` TEXT,
|
||||||
`description` TEXT,
|
`description` TEXT,
|
||||||
`active` BOOLEAN DEFAULT TRUE
|
`active` BOOLEAN
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE projectmembers (
|
CREATE TABLE projectmembers (
|
||||||
@@ -21,8 +21,8 @@ CREATE TABLE projectmembers (
|
|||||||
`uname` TEXT,
|
`uname` TEXT,
|
||||||
`mail` TEXT,
|
`mail` TEXT,
|
||||||
`role` TEXT,
|
`role` TEXT,
|
||||||
`lead` BOOLEAN DEFAULT FALSE,
|
`lead` BOOLEAN DEFAULT 0,
|
||||||
`owner` BOOLEAN DEFAULT FALSE
|
`owner` BOOLEAN DEFAULT 0
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE users (`uname` TEXT, `groups` INT DEFAULT 0);
|
CREATE TABLE users (`uname` TEXT, `groups` INT DEFAULT 0);
|
||||||
49
dist/pvv_postgresql.sql
vendored
Normal file
49
dist/pvv_postgresql.sql
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
CREATE TABLE events (
|
||||||
|
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||||
|
name TEXT,
|
||||||
|
start TEXT,
|
||||||
|
stop TEXT,
|
||||||
|
organiser TEXT,
|
||||||
|
location TEXT,
|
||||||
|
description TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE projects (
|
||||||
|
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||||
|
name TEXT,
|
||||||
|
description TEXT,
|
||||||
|
active BOOLEAN
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE projectmembers (
|
||||||
|
projectid INTEGER,
|
||||||
|
name TEXT,
|
||||||
|
uname TEXT,
|
||||||
|
mail TEXT,
|
||||||
|
role TEXT,
|
||||||
|
lead BOOLEAN DEFAULT FALSE,
|
||||||
|
owner BOOLEAN DEFAULT FALSE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE users (
|
||||||
|
uname TEXT,
|
||||||
|
groups INT DEFAULT 0
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE motd (
|
||||||
|
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||||
|
title TEXT,
|
||||||
|
content TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
-- INSERT example
|
||||||
|
-- INSERT INTO motd (title, content)
|
||||||
|
-- VALUES ('MOTD ./dev.sh', 'du kan endre motd i admin panelet');
|
||||||
|
|
||||||
|
CREATE TABLE door (
|
||||||
|
time INTEGER PRIMARY KEY,
|
||||||
|
open BOOLEAN
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO door (time, open)
|
||||||
|
VALUES (0, FALSE);
|
||||||
@@ -12,7 +12,7 @@ CREATE TABLE "projects" (
|
|||||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
"name" TEXT,
|
"name" TEXT,
|
||||||
"description" TEXT,
|
"description" TEXT,
|
||||||
"active" BOOLEAN DEFAULT TRUE
|
"active" BOOLEAN
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE "projectmembers" (
|
CREATE TABLE "projectmembers" (
|
||||||
@@ -21,8 +21,8 @@ CREATE TABLE "projectmembers" (
|
|||||||
"uname" TEXT,
|
"uname" TEXT,
|
||||||
"mail" TEXT,
|
"mail" TEXT,
|
||||||
"role" TEXT,
|
"role" TEXT,
|
||||||
"lead" BOOLEAN DEFAULT FALSE,
|
"lead" BOOLEAN DEFAULT 0,
|
||||||
"owner" BOOLEAN DEFAULT FALSE
|
"owner" BOOLEAN DEFAULT 0
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE "users" ("uname" TEXT, "groups" INT DEFAULT 0);
|
CREATE TABLE "users" ("uname" TEXT, "groups" INT DEFAULT 0);
|
||||||
36
dist/simplesaml-dev/authsources.php
vendored
36
dist/simplesaml-dev/authsources.php
vendored
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
$config = [
|
|
||||||
// This is used by the service provider to contact the identity provider
|
|
||||||
'default-sp' => [
|
|
||||||
'saml:SP',
|
|
||||||
'entityID' => 'http://localhost:1080/simplesaml/sp',
|
|
||||||
'idp' => 'http://localhost:1080/simplesaml/idp',
|
|
||||||
],
|
|
||||||
|
|
||||||
// This is used by the identity provider to authenticate users
|
|
||||||
'example-userpass' => [
|
|
||||||
'exampleauth:UserPass',
|
|
||||||
'users' => [
|
|
||||||
'user:user' => [
|
|
||||||
'uid' => ['user'],
|
|
||||||
'group' => ['users'],
|
|
||||||
'cn' => 'Ole Petter',
|
|
||||||
'mail' => 'user+test@pvv.ntnu.no',
|
|
||||||
],
|
|
||||||
'admin:admin' => [
|
|
||||||
'uid' => ['admin'],
|
|
||||||
'group' => ['admin'],
|
|
||||||
'cn' => 'Admin Adminsson',
|
|
||||||
'mail' => 'admin+test@pvv.ntnu.no',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
// This is also used by the identity provider to authenticate IDP admins
|
|
||||||
// See http://localhost:1080/simplesaml/admin/
|
|
||||||
'admin' => [
|
|
||||||
'core:AdminPassword',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
1416
dist/simplesaml-dev/config.php
vendored
1416
dist/simplesaml-dev/config.php
vendored
File diff suppressed because it is too large
Load Diff
10
dist/simplesaml-dev/saml20-idp-hosted.php
vendored
10
dist/simplesaml-dev/saml20-idp-hosted.php
vendored
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
$metadata['http://localhost:1080/simplesaml/idp'] = [
|
|
||||||
'host' => '__DEFAULT__',
|
|
||||||
'privatekey' => 'localhost.pem',
|
|
||||||
'certificate' => 'localhost.crt',
|
|
||||||
'auth' => 'example-userpass',
|
|
||||||
];
|
|
||||||
50
dist/simplesaml-dev/saml20-idp-remote.php
vendored
50
dist/simplesaml-dev/saml20-idp-remote.php
vendored
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
$metadata['https://idp.pvv.ntnu.no/'] = [
|
|
||||||
'metadata-set' => 'saml20-idp-remote',
|
|
||||||
'entityid' => 'https://idp.pvv.ntnu.no/',
|
|
||||||
'SingleSignOnService' => [
|
|
||||||
0 => [
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
|
||||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'SingleLogoutService' => [
|
|
||||||
0 => [
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
|
||||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SingleLogoutService.php',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'certData' => 'MIIDpTCCAo2gAwIBAgIJAJIgibrB7NvsMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNVBAYTAk5PMR4wHAYDVQQKDBVQcm9ncmFtdmFyZXZlcmtzdGVkZXQxGDAWBgNVBAMMD2lkcC5wdnYubnRudS5ubzEgMB4GCSqGSIb3DQEJARYRZHJpZnRAcHZ2Lm50bnUubm8wHhcNMTcxMTEzMjI0NTQyWhcNMjcxMTEzMjI0NTQyWjBpMQswCQYDVQQGEwJOTzEeMBwGA1UECgwVUHJvZ3JhbXZhcmV2ZXJrc3RlZGV0MRgwFgYDVQQDDA9pZHAucHZ2Lm50bnUubm8xIDAeBgkqhkiG9w0BCQEWEWRyaWZ0QHB2di5udG51Lm5vMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAveLujCsgVCRA360y5yezy8FcSPhaqodggDqY12UTkYOMQLBFaph6uUL4oCUlXZqxScrAYVRt9yw+7BYpcm0p51VZzVCsfMxRVkn+O1eUvsaXq3f13f87QHKYP2f0uqkGf5PvnKIdSaI/ix8WJhD8XT+h0OkHEcaBvUtSG7zbEhvG21WPHwgw2rvZSneArQ8tOitZC0u8VXSfdhtf6ynRseo0xC95634UwQAZivhQ2v4A6Tp57QG5DCXIJ9/z3PkINx3KB/hOeh0EP6Dpbp+7V0/t9778E3whpm4llrH144kzROhA7EgUgkZOjAVjxGCYlcj3xQPnnItihVOZ5B5qLwIDAQABo1AwTjAdBgNVHQ4EFgQUPLhrB+Qb/Kzz7Car9GJkKmEkz6swHwYDVR0jBBgwFoAUPLhrB+Qb/Kzz7Car9GJkKmEkz6swDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAd+4E6t0j8/p8rbZE8y/gZ9GsiRhxkR4l6JbMRUfEpqHKi415qstChRcP2Lo3Yd5qdmj9tLDWoPsqet1QgyTTmQTgUmPhhMOQDqSh90LuqEJseKWafXGS/SfWLH6MWVmzDV5YofJEw2ThPiU58GiS06OLS2poq1eAesa2LQ22J8yYisXM4sxImIFte+LYQ1+1evfBWcvU1vrGsQ0VLJHdef9WoXp1swUFhq4Zk0c7gjHiB1CFVlExAAlk9L6W3CVXmKIYlf4eUnEBGkC061Ir42+uhAMWO9Y/L1NEuboTyd2KAI/6JdKdzpmfk7zPVxWlNxNCZ7OPNuvOKp6VlpB2EA==',
|
|
||||||
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
|
|
||||||
];
|
|
||||||
|
|
||||||
function getCertData(string $path): string
|
|
||||||
{
|
|
||||||
$cert = file_get_contents($path);
|
|
||||||
$cert = str_replace("-----BEGIN CERTIFICATE-----", "", $cert);
|
|
||||||
$cert = str_replace("-----END CERTIFICATE-----", "", $cert);
|
|
||||||
$cert = str_replace(["\r", "\n"], "", $cert);
|
|
||||||
return $cert;
|
|
||||||
}
|
|
||||||
|
|
||||||
$metadata['http://localhost:1080/simplesaml/idp'] = [
|
|
||||||
'metadata-set' => 'saml20-idp-remote',
|
|
||||||
'entityid' => 'https://localhost:1080/simplesaml/idp',
|
|
||||||
'SingleSignOnService' => [
|
|
||||||
0 => [
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
|
||||||
'Location' => 'http://localhost:1080/simplesaml/saml2/idp/SSOService.php',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'SingleLogoutService' => [
|
|
||||||
0 => [
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
|
||||||
'Location' => 'http://localhost:1080/simplesaml/saml2/idp/SingleLogoutService.php',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'certData' => getCertData(__DIR__ . '/../cert/localhost.crt'),
|
|
||||||
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
|
|
||||||
];
|
|
||||||
16
dist/simplesaml-dev/saml20-sp-remote.php
vendored
16
dist/simplesaml-dev/saml20-sp-remote.php
vendored
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$metadata['http://localhost:1080/simplesaml/sp'] = [
|
|
||||||
'AssertionConsumerService' => [
|
|
||||||
[
|
|
||||||
'Location' => 'http://localhost:1080/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'SingleLogoutService' => [
|
|
||||||
[
|
|
||||||
'Location' => 'http://localhost:1080/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp',
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
7
dist/sql/test_data_sqlite.sql
vendored
7
dist/sql/test_data_sqlite.sql
vendored
@@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
-- See users in ../authsources.php
|
|
||||||
INSERT INTO
|
|
||||||
users (uname, groups)
|
|
||||||
VALUES
|
|
||||||
('admin', 1 | 2 | 4),
|
|
||||||
('user', 0);
|
|
||||||
21
docker-compose.yaml
Normal file
21
docker-compose.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
# cleanup:
|
||||||
|
|
||||||
|
# docker container prune -f && docker volume prune -f
|
||||||
|
# docker system prune -a
|
||||||
|
|
||||||
|
services:
|
||||||
|
nettside: # https://hub.docker.com/_/php
|
||||||
|
#image: php:7.4-cli
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
- .:/usr/src/nettside
|
||||||
|
working_dir: /usr/src/nettside
|
||||||
|
command: ./dev.sh
|
||||||
|
environment:
|
||||||
|
- DOCKER_HOST=0.0.0.0
|
||||||
|
- DOCKER_PORT=1080
|
||||||
|
ports:
|
||||||
|
- 1080:1080
|
||||||
|
user: "${DOCKER_USER}"
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
# Getting started
|
|
||||||
|
|
||||||
Let's get you up and running.
|
|
||||||
|
|
||||||
## List of dependencies
|
|
||||||
|
|
||||||
You will need to install the following pieces of software:
|
|
||||||
|
|
||||||
- Git
|
|
||||||
- SQLite3
|
|
||||||
- PHP
|
|
||||||
- Composer
|
|
||||||
- OpenSSL
|
|
||||||
|
|
||||||
If you are running Ubuntu or Debian, you can install these dependencies with:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install git sqlite3 php composer openssl
|
|
||||||
```
|
|
||||||
|
|
||||||
## Automatic setup
|
|
||||||
|
|
||||||
You can use the scripts in the `scripts/` directory to quickly set up a development environment.
|
|
||||||
|
|
||||||
By running the `./scripts/setup.sh`, all dependencies will be installed, in addition to other miscellaneous setup tasks. You can then run `./scripts/run.sh` to start the webserver.
|
|
||||||
|
|
||||||
You should now be able to access the site at [http://localhost:1080](http://localhost:1080).
|
|
||||||
|
|
||||||
Sometimes it is useful to completely reset the state of the project, deleting the data, redownloading dependencies, etc. You can do this by running `./scripts/reset.sh`. Be careful, as this will delete all data in the database!
|
|
||||||
|
|
||||||
> [!WARN]
|
|
||||||
> Even when resetting the project with the reset script, there are some situation where you need to clear your cookies or your browser cache to get a clean state.
|
|
||||||
> How to do this varies between browsers, so please refer to your browser's documentation for instructions.
|
|
||||||
|
|
||||||
## Setup with nix
|
|
||||||
|
|
||||||
We provide a devshell with all dependencies included. We do recommend still using the scripts for setup tasks.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
nix develop
|
|
||||||
./scripts/setup.sh
|
|
||||||
./scripts/run.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
## Logging in
|
|
||||||
|
|
||||||
We have a development configuration for SimpleSAMLphp (which we use as our authentication system), that lets you log in with dummy users while developing.
|
|
||||||
|
|
||||||
The available users are:
|
|
||||||
|
|
||||||
- `admin` (password: `admin`) - An admin user
|
|
||||||
- `user` (password: `user`) - A normal user
|
|
||||||
|
|
||||||
In addition, if you need to look into the SAML setup, you can log into the SimpleSAMLphp admin interface at [http://localhost:1080/simplesaml/admin](http://localhost:1080/simplesaml/admin) with username `admin` and password `123`.
|
|
||||||
|
|
||||||
## The codebase
|
|
||||||
|
|
||||||
In the codebase, you will find the following directories:
|
|
||||||
|
|
||||||
- `dist`: Contains files related to deployment, hosting and packaging.
|
|
||||||
- `docs`: Documentation for the project.
|
|
||||||
- `inc`: PHP include files, containing a base set of useful classes, functions and constants.
|
|
||||||
- `nix`: Nix config for packaging, devshells, NixOS modules, etc.
|
|
||||||
- `scripts`: Helper scripts for setting up development environments, running the server, etc.
|
|
||||||
- `src`: The main library code for the project. This contains raw PHP code with business logic and database access.
|
|
||||||
- `vendor`: Third-party dependencies installed with composer.
|
|
||||||
- `www`: The webroot for the project. This contains public assets, styling, javascript and PHP code concerned with routing and rendering webpages.
|
|
||||||
|
|
||||||
## How SimpleSAMLphp is set up in the development environment
|
|
||||||
|
|
||||||
It used to be the case that we would connect to our production instance of SimpleSAMLphp for authentication even in development environments. This is no longer the case, as we now use our local SimpleSAMLphp instance both as a service provider and as an identity provider in development. The `config.php` and `authsources.php` files are written in a way where one single instance of SimpleSAMLphp acts as both parts. It will send authentication requests to itself. See `dist/simplesaml-dev` for implementation details.
|
|
||||||
|
Before Width: | Height: | Size: 477 KiB After Width: | Height: | Size: 477 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
@@ -4,22 +4,7 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
php.buildComposerProject rec {
|
php.buildComposerProject rec {
|
||||||
src = lib.fileset.toSource {
|
src = ./..;
|
||||||
root = ./..;
|
|
||||||
fileset = lib.fileset.difference
|
|
||||||
(lib.fileset.unions [
|
|
||||||
../dist
|
|
||||||
../inc
|
|
||||||
../src
|
|
||||||
../www
|
|
||||||
../composer.json
|
|
||||||
../composer.lock
|
|
||||||
])
|
|
||||||
(lib.fileset.unions [
|
|
||||||
(lib.fileset.maybeMissing ../www/simplesaml)
|
|
||||||
(lib.fileset.maybeMissing ../www/simplesaml-idp)
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
pname = "pvv-nettsiden";
|
pname = "pvv-nettsiden";
|
||||||
version = "0.0.1";
|
version = "0.0.1";
|
||||||
vendorHash = "sha256-7I7Fdp5DvCwCdYY66Mv0hZ+a8xRzQt+WMUKG544k7Fc=";
|
vendorHash = "sha256-7I7Fdp5DvCwCdYY66Mv0hZ+a8xRzQt+WMUKG544k7Fc=";
|
||||||
@@ -27,10 +12,10 @@ php.buildComposerProject rec {
|
|||||||
passthru.simplesamlphpPath = "share/php/pvv-nettsiden/vendor/simplesamlphp/simplesamlphp";
|
passthru.simplesamlphpPath = "share/php/pvv-nettsiden/vendor/simplesamlphp/simplesamlphp";
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
install -Dm644 dist/simplesaml-prod/config.php "$out"/${passthru.simplesamlphpPath}/config/config.php
|
install -Dm644 dist/simplesamlphp-config.php $out/${passthru.simplesamlphpPath}/config/config.php
|
||||||
install -Dm644 dist/simplesaml-prod/authsources.php "$$out/${passthru.simplesamlphpPath}/config/authsources.php
|
install -Dm644 dist/simplesamlphp-authsources.php $out/${passthru.simplesamlphpPath}/config/authsources.php
|
||||||
install -Dm644 dist/simplesaml-prod/saml20-idp-remote.php "$$out/${passthru.simplesamlphpPath}/metadata/saml20-idp-remote.php
|
install -Dm644 dist/simplesamlphp-idp.php $out/${passthru.simplesamlphpPath}/metadata/saml20-idp-remote.php
|
||||||
install -Dm644 dist/config.source-env.php "$$out/share/php/pvv-nettsiden/config.php
|
install -Dm644 dist/config.source-env.php $out/share/php/pvv-nettsiden/config.php
|
||||||
|
|
||||||
${lib.pipe extra_files [
|
${lib.pipe extra_files [
|
||||||
(lib.mapAttrsToList (target_path: source_path: ''
|
(lib.mapAttrsToList (target_path: source_path: ''
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ pkgs }:
|
{ pkgs, lib }:
|
||||||
let
|
let
|
||||||
phpEnv = pkgs.php84.buildEnv {
|
phpEnv = pkgs.php84.buildEnv {
|
||||||
extensions = { enabled, all }: enabled ++ (with all; [ iconv mbstring pdo_mysql pdo_sqlite ]);
|
extensions = { enabled, all }: enabled ++ (with all; [ iconv mbstring pdo_mysql pdo_sqlite ]);
|
||||||
@@ -12,6 +12,30 @@ pkgs.mkShellNoCC {
|
|||||||
php84Packages.php-cs-fixer
|
php84Packages.php-cs-fixer
|
||||||
sqlite-interactive
|
sqlite-interactive
|
||||||
sql-formatter
|
sql-formatter
|
||||||
openssl
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Prepare dev environment with sqlite and config files
|
||||||
|
shellHook = ''
|
||||||
|
alias runDev='php -S localhost:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/'
|
||||||
|
|
||||||
|
declare -a PROJECT_ROOT="$("${lib.getExe pkgs.git}" rev-parse --show-toplevel)"
|
||||||
|
|
||||||
|
mkdir -p "$PROJECT_ROOT/www/galleri/bilder/slideshow"
|
||||||
|
test -e "$PROJECT_ROOT/pvv.sqlite" || sqlite3 "$PROJECT_ROOT/pvv.sqlite" < "$PROJECT_ROOT/dist/pvv_sqlite.sql"
|
||||||
|
test -e "$PROJECT_ROOT/config.php" || cp -v "$PROJECT_ROOT/dist/config.local.php" "$PROJECT_ROOT/config.php"
|
||||||
|
|
||||||
|
if [ ! -d "$PROJECT_ROOT/vendor" ] ; then
|
||||||
|
pushd "$PROJECT_ROOT"
|
||||||
|
composer install || exit $?
|
||||||
|
|
||||||
|
cp dist/simplesamlphp-authsources.php vendor/simplesamlphp/simplesamlphp/config/authsources.php
|
||||||
|
cp dist/simplesamlphp-idp.php vendor/simplesamlphp/simplesamlphp/metadata/saml20-idp-remote.php
|
||||||
|
cp dist/simplesamlphp-config.php vendor/simplesamlphp/simplesamlphp/config/config.php
|
||||||
|
|
||||||
|
cp dist/config.local.php config.php
|
||||||
|
|
||||||
|
ln -s ../vendor/simplesamlphp/simplesamlphp/public/ www/simplesaml
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
REQUIRED_COMMANDS=(git grep)
|
|
||||||
MISSING_COMMANDS=false
|
|
||||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
|
||||||
if ! command -v "$cmd" &> /dev/null; then
|
|
||||||
echo "$cmd could not be found" >&2
|
|
||||||
MISSING_COMMANDS=true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ "$MISSING_COMMANDS" = true ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -r GIT_TREE_IS_DIRTY="$(
|
|
||||||
if ! git diff --quiet --ignore-submodules \
|
|
||||||
|| git ls-files --others --exclude-standard | grep -q .; then
|
|
||||||
echo 1
|
|
||||||
else
|
|
||||||
echo 0
|
|
||||||
fi
|
|
||||||
)"
|
|
||||||
|
|
||||||
if [ "$GIT_TREE_IS_DIRTY" == "1" ]; then
|
|
||||||
echo "Git working tree is dirty, refusing to reset" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
|
||||||
|
|
||||||
(
|
|
||||||
cd "$PROJECT_ROOT"
|
|
||||||
git clean -fdx
|
|
||||||
)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
REQUIRED_COMMANDS=(git)
|
|
||||||
MISSING_COMMANDS=false
|
|
||||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
|
||||||
if ! command -v "$cmd" &> /dev/null; then
|
|
||||||
echo "$cmd could not be found" >&2
|
|
||||||
MISSING_COMMANDS=true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ "$MISSING_COMMANDS" = true ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
|
||||||
|
|
||||||
"$PROJECT_ROOT/scripts/clean.sh"
|
|
||||||
"$PROJECT_ROOT/scripts/setup.sh"
|
|
||||||
"$PROJECT_ROOT/scripts/seed-test-data.sh"
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
REQUIRED_COMMANDS=(
|
|
||||||
php
|
|
||||||
)
|
|
||||||
MISSING_COMMANDS=false
|
|
||||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
|
||||||
if ! command -v "$cmd" &> /dev/null; then
|
|
||||||
echo "$cmd could not be found" >&2
|
|
||||||
MISSING_COMMANDS=true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ "$MISSING_COMMANDS" = true ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
|
||||||
|
|
||||||
# Check for hints that our project might not be correctly set up
|
|
||||||
if [ ! -d "$PROJECT_ROOT/vendor" ] \
|
|
||||||
|| [ ! -f "$PROJECT_ROOT/config.php" ] \
|
|
||||||
|| [ ! -d "$PROJECT_ROOT/www/simplesaml" ] \
|
|
||||||
|| [ ! -d "$PROJECT_ROOT/www/galleri/bilder" ]; then
|
|
||||||
echo "It looks like the project is not correctly set up." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -a PHP_ARGS=(
|
|
||||||
-S localhost:1080
|
|
||||||
-d error_reporting=E_ALL
|
|
||||||
-d display_errors=1
|
|
||||||
-t www/
|
|
||||||
)
|
|
||||||
|
|
||||||
(cd "$PROJECT_ROOT" && php "${PHP_ARGS[@]}")
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
REQUIRED_COMMANDS=(
|
|
||||||
sqlite3
|
|
||||||
)
|
|
||||||
MISSING_COMMANDS=false
|
|
||||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
|
||||||
if ! command -v "$cmd" &> /dev/null; then
|
|
||||||
echo "$cmd could not be found" >&2
|
|
||||||
MISSING_COMMANDS=true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ "$MISSING_COMMANDS" = true ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
|
||||||
|
|
||||||
if [ ! -f "$PROJECT_ROOT/pvv.sqlite" ] ; then
|
|
||||||
echo "Database file $PROJECT_ROOT/pvv.sqlite does not exist. Please run setup.sh first." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sqlite3 "$PROJECT_ROOT/pvv.sqlite" < "$PROJECT_ROOT/dist/sql/test_data_sqlite.sql"
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
REQUIRED_COMMANDS=(
|
|
||||||
git
|
|
||||||
composer
|
|
||||||
sqlite3
|
|
||||||
openssl
|
|
||||||
install
|
|
||||||
)
|
|
||||||
MISSING_COMMANDS=false
|
|
||||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
|
||||||
if ! command -v "$cmd" &> /dev/null; then
|
|
||||||
echo "$cmd could not be found" >&2
|
|
||||||
MISSING_COMMANDS=true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ "$MISSING_COMMANDS" = true ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
|
||||||
|
|
||||||
mkdir -p "$PROJECT_ROOT/www/galleri/bilder/slideshow"
|
|
||||||
test -e "$PROJECT_ROOT/pvv.sqlite" || sqlite3 "$PROJECT_ROOT/pvv.sqlite" < "$PROJECT_ROOT/dist/sql/pvv_sqlite.sql"
|
|
||||||
test -e "$PROJECT_ROOT/config.php" || cp -v "$PROJECT_ROOT/dist/config.local.php" "$PROJECT_ROOT/config.php"
|
|
||||||
|
|
||||||
if [ ! -d "$PROJECT_ROOT/vendor" ] ; then
|
|
||||||
pushd "$PROJECT_ROOT"
|
|
||||||
composer install || exit $?
|
|
||||||
|
|
||||||
# Set up SimpleSAMLphp identity provider (for local testing)
|
|
||||||
install -m644 dist/simplesaml-dev/authsources.php -t vendor/simplesamlphp/simplesamlphp/config/
|
|
||||||
install -m644 dist/simplesaml-dev/config.php -t vendor/simplesamlphp/simplesamlphp/config/
|
|
||||||
install -m644 dist/simplesaml-dev/saml20-idp-remote.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
|
||||||
install -m644 dist/simplesaml-dev/saml20-idp-hosted.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
|
||||||
install -m644 dist/simplesaml-dev/saml20-sp-remote.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
|
||||||
|
|
||||||
# See session.phpsession.savepath in config.php
|
|
||||||
mkdir -p vendor/simplesamlphp/simplesamlphp/sessions/
|
|
||||||
|
|
||||||
openssl req \
|
|
||||||
-newkey rsa:4096 \
|
|
||||||
-new \
|
|
||||||
-x509 \
|
|
||||||
-days 3652 \
|
|
||||||
-nodes \
|
|
||||||
-out vendor/simplesamlphp/simplesamlphp/cert/localhost.crt \
|
|
||||||
-keyout vendor/simplesamlphp/simplesamlphp/cert/localhost.pem \
|
|
||||||
-subj "/C=NO/ST=Trondheim/L=Trondheim/O=Programvareverkstedet/CN=localhost"
|
|
||||||
|
|
||||||
cp dist/config.local.php config.php
|
|
||||||
|
|
||||||
ln -s ../vendor/simplesamlphp/simplesamlphp/public/ www/simplesaml
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
@@ -78,7 +78,7 @@ class Door {
|
|||||||
$query = 'INSERT INTO door(time, open) VALUES (:time, :open)';
|
$query = 'INSERT INTO door(time, open) VALUES (:time, :open)';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(':time', $time, \PDO::PARAM_STR);
|
$statement->bindParam(':time', $time, \PDO::PARAM_STR);
|
||||||
$statement->bindParam(':open', $open, \PDO::PARAM_BOOL);
|
$statement->bindParam(':open', $open, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$this->removeOld();
|
$this->removeOld();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class ProjectManager {
|
|||||||
$dbProj['id'],
|
$dbProj['id'],
|
||||||
$dbProj['name'],
|
$dbProj['name'],
|
||||||
$dbProj['description'],
|
$dbProj['description'],
|
||||||
(bool) $dbProj['active'],
|
$dbProj['active'],
|
||||||
);
|
);
|
||||||
$projects[] = $project;
|
$projects[] = $project;
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ class ProjectManager {
|
|||||||
$dbProj['id'],
|
$dbProj['id'],
|
||||||
$dbProj['name'],
|
$dbProj['name'],
|
||||||
$dbProj['description'],
|
$dbProj['description'],
|
||||||
(bool) $dbProj['active'],
|
$dbProj['active'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class ProjectManager {
|
|||||||
$dbProj['id'],
|
$dbProj['id'],
|
||||||
$dbProj['name'],
|
$dbProj['name'],
|
||||||
$dbProj['description'],
|
$dbProj['description'],
|
||||||
(bool) $dbProj['active'],
|
$dbProj['active'],
|
||||||
);
|
);
|
||||||
$projects[] = $project;
|
$projects[] = $project;
|
||||||
}
|
}
|
||||||
@@ -101,8 +101,8 @@ class ProjectManager {
|
|||||||
'uname' => $dbUsr['uname'],
|
'uname' => $dbUsr['uname'],
|
||||||
'mail' => $dbUsr['mail'],
|
'mail' => $dbUsr['mail'],
|
||||||
'role' => $dbUsr['role'],
|
'role' => $dbUsr['role'],
|
||||||
'lead' => (bool) $dbUsr['lead'],
|
'lead' => $dbUsr['lead'],
|
||||||
'owner' => (bool) $dbUsr['owner'],
|
'owner' => $dbUsr['owner'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +125,8 @@ class ProjectManager {
|
|||||||
'uname' => $dbOwner['uname'],
|
'uname' => $dbOwner['uname'],
|
||||||
'mail' => $dbOwner['mail'],
|
'mail' => $dbOwner['mail'],
|
||||||
'role' => $dbOwner['role'],
|
'role' => $dbOwner['role'],
|
||||||
'lead' => (bool) $dbOwner['lead'],
|
'lead' => $dbOwner['lead'],
|
||||||
'owner' => (bool) $dbOwner['owner'],
|
'owner' => $dbOwner['owner'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ $mail = $attrs['mail'][0];
|
|||||||
|
|
||||||
|
|
||||||
if ($id == 0) {
|
if ($id == 0) {
|
||||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, TRUE)';
|
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, 1)';
|
||||||
$statement = $pdo->prepare($query);
|
$statement = $pdo->prepare($query);
|
||||||
|
|
||||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||||
@@ -39,7 +39,7 @@ if ($id == 0) {
|
|||||||
$statement->execute();
|
$statement->execute();
|
||||||
$new_id = $pdo->lastInsertId();
|
$new_id = $pdo->lastInsertId();
|
||||||
|
|
||||||
$ownerQuery = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :owner, :owneruname, :owneremail, 'Prosjektleder', TRUE, TRUE)";
|
$ownerQuery = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :owner, :owneruname, :owneremail, 'Prosjektleder', 1, 1)";
|
||||||
$statement = $pdo->prepare($ownerQuery);
|
$statement = $pdo->prepare($ownerQuery);
|
||||||
$statement->bindParam(':id', $new_id, PDO::PARAM_STR);
|
$statement->bindParam(':id', $new_id, PDO::PARAM_STR);
|
||||||
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
||||||
@@ -62,7 +62,7 @@ if ($id == 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($is_member) {// leave
|
if ($is_member) {// leave
|
||||||
$query = 'DELETE FROM projectmembers WHERE projectid=:id AND uname=:uname and lead=FALSE and owner=FALSE;';
|
$query = 'DELETE FROM projectmembers WHERE projectid=:id AND uname=:uname and lead=0 and owner=0;';
|
||||||
$statement = $pdo->prepare($query);
|
$statement = $pdo->prepare($query);
|
||||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||||
@@ -70,7 +70,7 @@ if ($id == 0) {
|
|||||||
$statement->execute();
|
$statement->execute();
|
||||||
echo 'leave';
|
echo 'leave';
|
||||||
} else {// join
|
} else {// join
|
||||||
$query = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :name, :uname, :mail, 'Medlem', FALSE, FALSE)";
|
$query = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :name, :uname, :mail, 'Medlem', 0, 0)";
|
||||||
$statement = $pdo->prepare($query);
|
$statement = $pdo->prepare($query);
|
||||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||||
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
||||||
|
|||||||
Reference in New Issue
Block a user