Compare commits

...

18 Commits
0.1 ... main

Author SHA1 Message Date
pfm 750014e588 Merge pull request 'Add identity table' (#11) from identity-table into main
Reviewed-on: #11
2023-12-02 18:56:00 +00:00
Piotr F. Mieszkowski ca8bda5a83 Update README: link to backend repository, reformat instructions 2023-12-02 18:55:41 +01:00
Piotr F. Mieszkowski ce20926ce6 Rename project from gpg-mailgate to lacre 2023-12-02 18:53:28 +01:00
Piotr F. Mieszkowski fe92f6c081 Change table prefix from 'gpgmw' to 'lacre', part 2 2023-12-02 17:56:07 +01:00
Piotr F. Mieszkowski a564da49f2 Change table prefix from 'gpgmw' to 'lacre' 2023-12-02 17:53:56 +01:00
Piotr F. Mieszkowski e2e81288a1 Rename README to README.md 2023-11-26 12:04:19 +01:00
Piotr F. Mieszkowski 8b3dc4555d Add identity table 2023-11-26 10:31:08 +01:00
muppeth 6fecb95182 Merge pull request '0.2' (#10) from 0.2 into main
Reviewed-on: #10
2023-09-02 18:29:53 +00:00
muppeth e711b24de7
remove test disroot theme; 2023-09-01 19:05:40 +02:00
muppeth 197152b807
add all to theme gitignore 2023-09-01 19:04:41 +02:00
muppeth db45dbc1ae
using info template for confirm page 2023-09-01 16:31:36 +02:00
muppeth 2b5642a66b
as discussed in https://git.disroot.org/Lacre/lacre-webgate 2023-08-19 09:43:02 +02:00
muppeth dac5087f22
fixed missing last changes in lacre theme 2023-08-17 09:37:14 +02:00
muppeth 90b07d381f
fixed missing last changes in lacre theme 2023-08-17 09:33:51 +02:00
muppeth 3abfad3b06
added possibility to change themes 2023-08-16 10:01:54 +02:00
muppeth 6622c46f1a added menu with links to top of the page; some improvements to css
Signed-off-by: muppeth <muppeth@disroot.org>
2023-08-14 17:40:34 +02:00
muppeth eef76f4e86
added info template;split out result message to seperate page to avoid confusion; 2023-04-13 01:19:54 +02:00
muppeth 302c7a7107
added info template;split out result message to seperate page to avoid confusion; 2023-04-13 01:12:44 +02:00
26 changed files with 517 additions and 374 deletions

View File

@ -1,12 +1,14 @@
Lacre Web
Lacre Webgate
--------------
This is Lacre's simple php based frontend. It has been forked from [gpg-mailgate](https://github.com/fkrone/gpg-mailgate) project and it is a continuation of the original work. Special thanks to all those who have contributed to amazing work of gpg-mailgate-web and those who are willing to contribute to Lacre to improve security of email storage.
Lacre-Web is a simple web interface designed to allow any web user to upload their PGP public key and then have all mail sent via your mail server be encrypted. (Note: this is not meant for email authentication, only encryption.)
For the backend, see [lacre](https://git.disroot.org/Disroot/gpg-lacre).
Lacre-Webgate is a simple web interface designed to allow any web user to upload their PGP public key and then have all mail sent via your mail server be encrypted. (Note: this is not meant for email authentication, only encryption.)
After submitting their key to a web form, the user will be required to confirm their email address. A cron script will register the public key with gpg-lacre (keyhome_only must be set to no currently, which is the default) after email confirmation. From then on, email to the specified address will be encrypted with the public key.
Lacre-Web frontend is useful for two purposes:
Lacre-Webgate frontend is useful for two purposes:
- for a transparent PGP encryption layer in front of any web application
- as a web interface for gpg-lacre so that users on your mail server can easily upload and change their PGP keys.
@ -15,14 +17,16 @@ Note that all processing relating to the mail server is done via the cron script
1. Installation instructions:
Below instructions assume working gpg-Lacre setup (backend) as well as working web-server (eg. nginx+php8) and sql database (eg. mariadb).
1) Create a MySQL database for Lacre-Web.
1) Create a MySQL database for Lacre-Web.
a) Schema file is located in schema.sql
b) Database name and account goes in /etc/gpg-lacre.conf (and set enabled = yes)
3) Copy the contents of public_html to your web directory.
4) Move config.sample.php to config.php and edit the configuration file.
5) Copy cron.py to /usr/local/bin/Lacre-web-cron.py and set up a cron job
```
2) Copy the contents of public_html to your web directory.
3) Move config.sample.php to config.php and edit the configuration file.
4) Copy cron.py to /usr/local/bin/Lacre-web-cron.py and set up a cron job
```
*/3 * * * * lacre /usr/bin/python /usr/local/bin/Lacre-web-cron.py > /dev/null
```
6) Ensure that cron is working and test your new Lacre-web installation!
5) Ensure that cron is working and test your new Lacre-web installation!
2. Customization:
Lacre-Webgate allows for customization of css as well as templates. You can add your custom theme to `/themes/`. You can switch theme by adjusting `$config['site_theme']` in config.php` where the name is the theme's directory name.

12
cron.py
View File

@ -1,22 +1,22 @@
#!/usr/bin/python
#
# gpg-mailgate
# lacre
#
# This file is part of the gpg-mailgate source code.
# This file is part of the lacre source code.
#
# gpg-mailgate is free software: you can redistribute it and/or modify
# lacre is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# gpg-mailgate source code is distributed in the hope that it will be useful,
# lacre source code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
# along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
#
from configparser import RawConfigParser
@ -88,7 +88,7 @@ def define_db_schema():
return (gpgmw_keys)
# Read configuration from /etc/gpg-mailgate.conf
# Read configuration from /etc/lacre.conf
conf.load_config()
lacre.init_logging(conf.get_item('logging', 'config'))

1
public_html/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
config.php

View File

@ -1,54 +1,132 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DO NOT EDIT THIS FILE!
Instead, copy over "config.sample.php" to "config.php" and edit settings there.
*/
//
// GENERAL SITE SETTINGS
//
$config = array();
//web team contact
// this email address will be displayed if there is a database error
$config['email_web'] = 'admin@example.com';
$config['email_from'] = 'gpg-mailgate-web@example.com';
//address to send emails from
$config['email_from'] = 'lacre-web@example.com';
//this will be used as the subject when a user requests to add a PGP key
$config['email_subject_requestpgp'] = 'Confirm your email address';
//site theme
$config['site_theme'] = 'lacre';
//site URL, without trailing slash
$config['site_url'] = 'http://example.com/gpgmw';
//title of the website (displayed on home page)
$config['site_title'] = 'PGP key management';
//site logo
$config['site_logo'] = 'img/logo.png';
//link to FAQ page
$config['site_faqurl'] = 'https://lacre.io/faq';
//link to tutorial website
$config['site_howurl'] = 'https://learn.lacre.io';
//link to contact page
$config['site_contacturl'] = 'https://lacre.io/contact';
//language file to use (see language subdirectory)
$config['language'] = 'english';
//whether debug mode should be enabled
$config['debug'] = false;
//
// MAIL SETTINGS
//
//whether to send mail through SMTP (instead of PHP mail function)
$config['mail_smtp'] = false;
//SMTP settings, if mail_smtp is enabled
//this requires Net_SMTP from http://pear.php.net/package/Net_SMTP/ to be installed
$config['mail_smtp_host'] = 'localhost';
$config['mail_smtp_port'] = 25;
$config['mail_smtp_username'] = 'gpgmw';
$config['mail_smtp_password'] = '';
//
// DATABASE SETTINGS
//
//database name (MySQL only); or see include/dbconnect.php
$config['db_name'] = 'gpgmw';
//database host
$config['db_host'] = 'localhost';
//database username
$config['db_username'] = 'gpgmw';
//database password
$config['db_password'] = '';
//
// PGP VERIFICATION SETTINGS
//
//whether to enable immediate verification of PGP keys
// keys will always be verified with the email address in our cron job
// but this will enable verification from the web interface before email confirmation
//for this to work, Crypt_GPG from http://pear.php.net/Crypt_GPG must be installed
// (as well as any of its dependencies), and pgpverify_tmpdir must be set
$config['pgpverify_enable'] = false;
//a temporary directory to use for PGP verification, without trailing slash
// gpgmw will create subdirectories from here to use as temporary gpg home directories
// these directories will (should) be deleted immediately after use
$config['pgpverify_tmpdir'] = '/tmp';
//whether to allow blank "keys"
// this is useful to allow users to delete their key from the keystore
// if they no longer want encryption
$config['pgpverify_allowblank'] = true;
//
// LOCK SETTINGS
//
//the time in seconds a user must wait before trying again; otherwise they get locked out (count not increased)
$config['lock_time_initial'] = array('requestpgp' => 10);
//the number of tries a user has (that passes the lock_time_initial test) before being locked by overload (extended duration)
$config['lock_count_overload'] = array('requestpgp' => 3);
//the time that overloads last
$config['lock_time_overload'] = array('requestpgp' => 900);
//time after which locks no longer apply, assuming the lock isn't active
$config['lock_time_reset'] = 300;
//max time to store locks in the database; this way we can clear old locks with one function
$config['lock_time_max'] = 3600;
?>

View File

@ -1,119 +0,0 @@
<?php
/*
gpg-mailgate
This file is part of the gpg-mailgate source code.
gpg-mailgate is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
*/
//
// GENERAL SITE SETTINGS
//
//web team contact
// this email address will be displayed if there is a database error
$config['email_web'] = 'admin@example.com';
//address to send emails from
$config['email_from'] = 'gpg-mailgate-web@example.com';
//this will be used as the subject when a user requests to add a PGP key
$config['email_subject_requestpgp'] = 'Confirm your email address';
//site URL, without trailing slash
$config['site_url'] = 'http://example.com/gpgmw';
//title of the website (displayed on home page)
$config['site_title'] = 'PGP key management';
//language file to use (see language subdirectory)
$config['language'] = 'english';
//whether debug mode should be enabled
$config['debug'] = false;
//
// MAIL SETTINGS
//
//whether to send mail through SMTP (instead of PHP mail function)
$config['mail_smtp'] = false;
//SMTP settings, if mail_smtp is enabled
//this requires Net_SMTP from http://pear.php.net/package/Net_SMTP/ to be installed
$config['mail_smtp_host'] = 'localhost';
$config['mail_smtp_port'] = 25;
$config['mail_smtp_username'] = 'gpgmw';
$config['mail_smtp_password'] = '';
//
// DATABASE SETTINGS
//
//database name (MySQL only); or see include/dbconnect.php
$config['db_name'] = 'gpgmw';
//database host
$config['db_host'] = 'localhost';
//database username
$config['db_username'] = 'gpgmw';
//database password
$config['db_password'] = '';
//
// PGP VERIFICATION SETTINGS
//
//whether to enable immediate verification of PGP keys
// keys will always be verified with the email address in our cron job
// but this will enable verification from the web interface before email confirmation
//for this to work, Crypt_GPG from http://pear.php.net/Crypt_GPG must be installed
// (as well as any of its dependencies), and pgpverify_tmpdir must be set
$config['pgpverify_enable'] = false;
//a temporary directory to use for PGP verification, without trailing slash
// gpgmw will create subdirectories from here to use as temporary gpg home directories
// these directories will (should) be deleted immediately after use
$config['pgpverify_tmpdir'] = '/tmp';
//whether to allow blank "keys"
// this is useful to allow users to delete their key from the keystore
// if they no longer want encryption
$config['pgpverify_allowblank'] = true;
//
// LOCK SETTINGS
//
//the time in seconds a user must wait before trying again; otherwise they get locked out (count not increased)
$config['lock_time_initial'] = array('requestpgp' => 10);
//the number of tries a user has (that passes the lock_time_initial test) before being locked by overload (extended duration)
$config['lock_count_overload'] = array('requestpgp' => 3);
//the time that overloads last
$config['lock_time_overload'] = array('requestpgp' => 900);
//time after which locks no longer apply, assuming the lock isn't active
$config['lock_time_reset'] = 300;
//max time to store locks in the database; this way we can clear old locks with one function
$config['lock_time_max'] = 3600;
?>

View File

@ -1,22 +1,22 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/
@ -30,9 +30,9 @@ if(isset($_REQUEST['email']) && isset($_REQUEST['confirm'])) {
$result = confirmPGP($_REQUEST['email'], $_REQUEST['confirm']);
if($result === true) {
get_page("home", array('message' => $lang['confirm_success']));
get_page("info", array('message' => $lang['confirm_success']));
} else {
get_page("home", array('message' => $lang['confirm_fail_general']));
get_page("info", array('message' => $lang['confirm_fail_general']));
}
} else {
get_page("home");

View File

@ -1,22 +1,22 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/
@ -36,7 +36,7 @@ function includePath() {
return substr($self, 0, $lastSlash + 1);
}
//returns a relative path to the gpg-mailgate-web web root directory, without trailing slash
//returns a relative path to the lacre-web web root directory, without trailing slash
function basePath() {
$commonPath = __FILE__;
$requestPath = $_SERVER['SCRIPT_FILENAME'];
@ -75,19 +75,19 @@ function get_page($page, $args = array()) {
$basePath = basePath();
$themePath = $basePath . "/theme";
$themePageInclude = "$themePath/$page.php";
$templatePath = $basePath . "/themes/" . $config['site_theme'] . "/templates/";
$templatePageInclude = "$templatePath/$page.php";
if(file_exists("$themePath/header.php")) {
include("$themePath/header.php");
if(file_exists("$templatePath/header.php")) {
include("$templatePath/header.php");
}
if(file_exists($themePageInclude)) {
include($themePageInclude);
if(file_exists($templatePageInclude)) {
include($templatePageInclude);
}
if(file_exists("$themePath/footer.php")) {
include("$themePath/footer.php");
if(file_exists("$templatePath/footer.php")) {
include("$templatePath/footer.php");
}
}

View File

@ -1,22 +1,22 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@ -1,22 +1,22 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@ -1,22 +1,22 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@ -1,22 +1,22 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/
@ -39,7 +39,7 @@ function checkLock($action) {
$ip = $_SERVER['REMOTE_ADDR'];
$result = databaseQuery("SELECT id, time, num FROM gpgmw_locks WHERE ip = ? AND action = ?", array($ip, $action), true);
$result = databaseQuery("SELECT id, time, num FROM lacre_locks WHERE ip = ? AND action = ?", array($ip, $action), true);
if($row = $result->fetch()) {
$id = $row['id'];
$time = $row['time'];
@ -76,7 +76,7 @@ function lockAction($action) {
$replace_id = -1;
//first find records with ip/action
$result = databaseQuery("SELECT id, time, num FROM gpgmw_locks WHERE ip = ? AND action = ?", array($ip, $action), true);
$result = databaseQuery("SELECT id, time, num FROM lacre_locks WHERE ip = ? AND action = ?", array($ip, $action), true);
if($row = $result->fetch()) {
$id = $row['id'];
$time = $row['time'];
@ -92,10 +92,10 @@ function lockAction($action) {
//increase the count; maybe initiate an OVERLOAD
$count = $count + 1;
if($count >= $lock_count_overload[$action]) {
databaseQuery("UPDATE gpgmw_locks SET num = '-1', time = ? WHERE ip = ?", array(time(), $ip));
databaseQuery("UPDATE lacre_locks SET num = '-1', time = ? WHERE ip = ?", array(time(), $ip));
return false;
} else {
databaseQuery("UPDATE gpgmw_locks SET num = ?, time = ? WHERE ip = ?", array($count, time(), $ip));
databaseQuery("UPDATE lacre_locks SET num = ?, time = ? WHERE ip = ?", array($count, time(), $ip));
}
}
} else {
@ -107,16 +107,16 @@ function lockAction($action) {
}
}
} else {
databaseQuery("INSERT INTO gpgmw_locks (ip, time, action, num) VALUES (?, ?, ?, '1')", array($ip, time(), $action));
databaseQuery("INSERT INTO lacre_locks (ip, time, action, num) VALUES (?, ?, ?, '1')", array($ip, time(), $action));
}
if($replace_id != -1) {
databaseQuery("UPDATE gpgmw_locks SET num = '1', time = ? WHERE id = ?", array(time(), $replace_id));
databaseQuery("UPDATE lacre_locks SET num = '1', time = ? WHERE id = ?", array(time(), $replace_id));
}
//some housekeeping
$delete_time = time() - $lock_time_max;
databaseQuery("DELETE FROM gpgmw_locks WHERE time <= ?", array($delete_time));
databaseQuery("DELETE FROM lacre_locks WHERE time <= ?", array($delete_time));
return true;
}

View File

@ -1,22 +1,22 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/
@ -42,17 +42,17 @@ function requestPGP($email, $key) {
}
//housekeeping
databaseQuery("DELETE FROM gpgmw_keys WHERE time < DATE_SUB(NOW(), INTERVAL 48 HOUR) AND confirm != '' AND status = 0");
databaseQuery("DELETE FROM lacre_keys WHERE time < DATE_SUB(NOW(), INTERVAL 48 HOUR) AND confirm != '' AND status = 0");
//if we already have an unaccepted key for this user, only replace if one day has elapsed since the last request
// this may prevent spam
$result = databaseQuery("SELECT HOUR(TIMEDIFF(time, NOW())), id FROM gpgmw_keys WHERE email = ? AND status = 0", array($email));
$result = databaseQuery("SELECT HOUR(TIMEDIFF(time, NOW())), id FROM lacre_keys WHERE email = ? AND status = 0", array($email));
if($row = $result->fetch()) {
if($row[0] < 24) {
return $lang['submit_error_alreadyqueue'];
} else {
databaseQuery('DELETE FROM gpgmw_keys WHERE id = ?', array($row[1]));
databaseQuery('DELETE FROM lacre_keys WHERE id = ?', array($row[1]));
}
}
@ -75,7 +75,7 @@ function requestPGP($email, $key) {
return $lang['submit_error_emailfail'];
}
databaseQuery("INSERT INTO gpgmw_keys (email, publickey, confirm) VALUES (?, ?, ?)", array($email, $key, $confirm));
databaseQuery("INSERT INTO lacre_keys (email, publickey, confirm) VALUES (?, ?, ?)", array($email, $key, $confirm));
return true;
}
@ -87,10 +87,10 @@ function confirmPGP($email, $confirm) {
return false;
}
$result = databaseQuery("SELECT id FROM gpgmw_keys WHERE confirm = ? AND email = ?", array($confirm, $email));
$result = databaseQuery("SELECT id FROM lacre_keys WHERE confirm = ? AND email = ?", array($confirm, $email));
if($row = $result->fetch()) {
databaseQuery("UPDATE gpgmw_keys SET confirm = '' WHERE id = ?", array($row[0]));
databaseQuery("UPDATE lacre_keys SET confirm = '' WHERE id = ?", array($row[0]));
return true;
}

View File

@ -1,22 +1,22 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/
@ -31,9 +31,9 @@ if(isset($_POST['email']) && isset($_POST['key'])) {
$result = requestPGP($_POST['email'], $_POST['key']);
if($result === true) {
get_page("home", array('message' => $lang['submit_success']));
get_page("info", array('message' => $lang['submit_success']));
} else {
get_page("home", array('message' => $result));
get_page("info", array('message' => $result));
}
} else {
get_page("home");

View File

@ -1,31 +1,31 @@
<?php
/*
gpg-mailgate
lacre
This file is part of the gpg-mailgate source code.
This file is part of the lacre source code.
gpg-mailgate is free software: you can redistribute it and/or modify
lacre is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
lacre source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
along with lacre source code. If not, see <http://www.gnu.org/licenses/>.
*/
$lang = array();
$lang['home_text'] = 'Use the form below to submit an ASCII-armored PGP public key. After submission, you will receive an email asking you to confirm your email address. Once confirmation is completed, mail sent to your email address via our mail server will be encrypted with your PGP public key.';
$lang['home_footer'] = '<a href="https://github.com/uakfdotb/gpg-mailgate">gpg-mailgate and gpg-mailgate-web</a> are released under the <a href="https://www.gnu.org/licenses/lgpl-3.0.txt">GNU LGPL</a>.';
$lang['home_text'] = 'Use the form below to submit your PGP public key. After submission, you will receive an email asking you to confirm your email address. Once confirmation is completed, mail sent to your email address via our mail server will be encrypted with your PGP public key.';
$lang['home_footer'] = '<a href="https://git.disroot.org/Lacre/lacre-webgate">gpg-lacre</a> and <a href="https://git.disroot.org/Lacre/lacre-webgate">lacre-webgate</a> are released under the <a href="https://www.gnu.org/licenses/lgpl-3.0.txt">GNU LGPL</a>.';
$lang['home_emaildesc'] = 'Your email address (must match key)';
$lang['home_keydesc'] = 'ASCII-armored PGP public key';
$lang['home_keydesc'] = 'PGP public key';
$lang['home_submitkey'] = 'Submit key';
$lang['submit_success'] = 'Key submission successful. Please check your email to confirm your email address.';
@ -44,4 +44,5 @@ $lang['confirm_fail_general'] = 'Error: failed to confirm any email address. You
$lang['mail_confirm'] = "Please confirm your email address to complete the submission process. You can do so by clicking the link below\n\n%s\n\nThanks,\ngpg-mailgate-web";
$lang['info_back'] = 'Go back';
?>

View File

@ -1,133 +0,0 @@
:root {
--main-bg-color: #203040;
--main-dark: darken(var(--main-bg-color), 90%);
--main-font: Tahoma, Verdana, Arial, sans-serif;
--main-font-color: #E3DEDB;
--main-linkcolor: #BB2244;
--main-hovercolor: #2C4359;
/* --bg-color: #203040 ;
--logo-color: #BB2244;
--highlight-color: #DD4466;
--txt-color: #E3DEDB;
--select-color: #2C4359;
*/
/* background colors */
--bg-hs: 210, 33%;
--bg-l:19%;
--bg: hsl(var(--bg-hs),var(--bg-l));
--bg-darker: hsl(var(--bg-hs),calc(var(--bg-l) - 5%));
--bg-darkest: hsl(var(--bg-hs),calc(var(--bg-l) - 10%));
/* main color */
--main-hs: 347, 69%;
--main-l: 43%;
--main: hsl(var(--main-hs),var(--main-l));
--main-darker: hsl(var(--main-hs),calc(var(--main-l) - 5%));
--main-darkest: hsl(var(--main-hs),calc(var(--main-l) - 10%));
/* font color */
--font-hs: 23, 12%;
--font-l: 87%;
--font: hsl(var(--font-hs),var(--font-l));
--font-darker: hsl(var(--font-hs),calc(var(--font-l) - 5%));
--font-darkest: hsl(var(--font-hs),calc(var(--font-l) - 70%));
}
html {
background-color: var(--bg-darkest);
}
body {
width: 70%;
margin: 0 auto;
background-color: var(--bg);
color: var(--font);
font-family: var(--main-font);
line-height: 1.2;
text-align: center;
}
.wrapper {
margin: 0 20%;
}
.padding {
padding: 3rem 1rem;
}
img.logo {
width: 70%;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
.cover {
width: 100%;
margin-left: 0;
object-fit: cover;
}
.hide {
display:none;
}
a {
color: var(--main);
text-decoration:none;
}
a:hover {
color: var(--main-darker);
}
.txtinfo {
padding: 2rem;
}
.key {
width: 80%;
margin: 1rem auto;
height: 150px;
padding: 12px 20px;
border-radius: 10px;
border: 1px solid var(--main);
background-color: var(--font);
color: var(--bg);
font-family: var(--main-font);
resize: none;
}
.email {
width: 50%;
margin: 1rem auto;
padding: 12px 20px;
border-radius: 10px;
border: 1px solid var(--main);
background-color: var(--font);
color: var(--bg);
font-family: var(--main-font);
resize: none;
}
input[type=submit] {
background-color: var(--main-darker);
border-radius: 4px;
border: 0px;
color: var(--font);
padding: 16px 32px;
margin: 4px 2px;
cursor: pointer;
}
input:hover[type=submit] {
background-color: var(--main-darkest);
}
.infomsg {
width: 70%;
margin: 0 auto;
border-radius: 4px;
border: 2px;
border-color: var(--main);
background-color: var(--bg); /*shold be bg-darker but hidden when empty*/
color: var(--main);
font-family: var(--main-font);
resize: none;
}
#infomsg p:empty {
display: none;
}
#infomsg p {
padding: 12px 24px;
}

3
public_html/themes/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*
!lacre
!lacre/*

View File

@ -0,0 +1,180 @@
:root {
/* background colors */
--bg-color-hs: 210, 33%;
--bg-color-l:19%;
--bg-color: hsl(var(--bg-color-hs),var(--bg-color-l));
--bg-color-darker: hsl(var(--bg-color-hs),calc(var(--bg-color-l) - 5%));
--bg-color-darkest: hsl(var(--bg-color-hs),calc(var(--bg-color-l) - 10%));
--bg-color-select: hsl(var(--bg-color-hs),calc(var(--bg-color-l) + 10%));
/* main color */
--main-color-hs: 347, 69%;
--main-color-l: 43%;
--main-color: hsl(var(--main-color-hs),var(--main-color-l));
--main-color-darker: hsl(var(--main-color-hs),calc(var(--main-color-l) - 5%));
--main-color-darkest: hsl(var(--main-color-hs),calc(var(--main-color-l) - 10%));
/* font color */
--text-color-hs: 23, 12%;
--text-color-l: 87%;
--text-color: hsl(var(--text-color-hs),var(--text-color-l));
--text-color-darker: hsl(var(--text-color-hs),calc(var(--text-color-l) - 5%));
--text-color-darkest: hsl(var(--text-color-hs),calc(var(--text-color-l) - 70%));
/* font family */
font-family: 'comfortaa', 'opensans-regular', sans-serif;
}
html {
background-color: var(--bg-color-darkest);
}
body {
width: 60%;
margin: 0 auto;
background-color: var(--bg-color);
color: var(--text-color);
font-family: var(--main-font);
line-height: 1.2;
text-align: center;
}
.wrapper {
margin: 0 10%;
}
.padding {
padding: .5rem 1rem;
}
.header {
background-color: var(--text-color);
color: var(--bg-color);
position: relative;
top: -2rem;
z-index: 99;
}
.header a {
color: var(--bg-color);
}
.header .logo {
font-size: 1.7rem;
text-transform: uppercase;
}
.narrow .row { max-width: 980px; }
.banner {
position: relative;
overflow:hidden;
z-index: 999;
pointer-events: none;
}
.banner img {
width: 70%;
margin: 0 15%;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
.cover {
width: 100%;
margin-left: 0;
object-fit: cover;
}
.hide {
display:none;
}
a {
color: var(--main-color);
text-decoration:none;
}
a:hover {
color: var(--main-color-darker);
}
.txtinfo {
padding: 2rem;
}
.key {
width: 70%;
margin: 1rem auto;
height: 600px;
padding: 12px 20px;
border-radius: 10px;
border: 1px solid var(--main-color);
background-color: var(--text-color);
color: var(--bg-color);
font-family: var(--main-font);
resize: none;
}
.email {
width: 50%;
margin: 1rem auto;
padding: 12px 20px;
border-radius: 10px;
border: 1px solid var(--main-color);
background-color: var(--text-color);
color: var(--bg-color);
font-family: var(--main-font);
resize: none;
}
input[type=submit] {
background-color: var(--main-color-darker);
border-radius: 4px;
border: 0px;
color: var(--text-color);
padding: 16px 32px;
margin: 4px 2px;
cursor: pointer;
}
input:hover[type=submit] {
background-color: var(--main-color-darkest);
}
#infomsg p:empty {
display: none;
}
#infomsg p {
padding: 2em;
width: 80%;
margin: 0 auto;
border-radius: 4px;
background-color: var(--bg-color-darker); /*shold be bg-darker but hidden when empty*/
color: var(--main-font-color);
font-family: var(--main-font);
resize: none;
}
.main-nav {
width: 80%;
margin: 0 auto;
}
.main-nav ul {
text-align: left;
letter-spacing: -1em;
margin: 0;
padding: 0;
}
.main-nav ul li {
display: inline-block;
letter-spacing: normal;
}
.main-nav ul li a {
position: relative;
display: block;
line-height: 45px;
color: var(--bg);
padding: 0 20px;
white-space: nowrap;
}
.main-nav > ul > li > a {
border-radius: 2px;
}
.main-nav ul li:hover > a {
background-color: var(--bg-color-select);
color: var(--text-color);
}
.main-nav ul li.selected > a {
background-color: #fff;
color: var(--bg-color-darker);
}
.main-nav ul li ul li {
display: block;
}
.main-nav li:hover > ul {
display: block;
}

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View File

@ -21,5 +21,9 @@
*/
?>
<div id=footer>
<img src="themes/<?= $config['site_theme'] ?>/img/bottom_ribbon.png" class="cover">
<p><?= $lang['home_footer'] ?></p>
</div>
</body>
</html>

View File

@ -0,0 +1,41 @@
<?php
/*
gpg-mailgate
This file is part of the gpg-mailgate source code.
gpg-mailgate is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
*/
?>
<form id="keyform" method="POST">
<p>
<label for="email"><?= $lang['home_emaildesc'] ?></label>
<br>
<input type="text" class="email" name="email" required>
</p>
<p>
<label for="key"><?= $lang['home_keydesc'] ?></label>
<br>
<!--input type="text" class="key" name="key" required-->
<textarea rows="5" cols="80" name="key" id="key" class="key"></textarea>
</p>
<p>
<input type="submit" value="<?= $lang['home_submitkey'] ?>" />
</p>
</form>

View File

@ -0,0 +1,45 @@
<?php
/*
gpg-mailgate
This file is part of the gpg-mailgate source code.
gpg-mailgate is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
gpg-mailgate source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
*/
?>
<html>
<head>
<title>Lacre - PGP key management</title>
</head>
<body>
<div id=header>
<div class="banner narrow">
<a href <?= $config['site_url'] ?>><img src="themes/<?= $config['site_theme'] ?>/<?= $config['site_logo'] ?>" class="center banner"></a>
</div>
<div class="header">
<nav class="main-nav">
<ul>
<li class="selected"><a href="/">Home</a></li>
<li class=""><a href="<?= $config['site_faqurl'] ?>">FAQ</a></li>
<li class=""><a href="<?= $config['site_howurl'] ?>">Help</a></li>
<li class=""><a href="<?= $config['site_contacturl'] ?>">Contact</a></li>
</ul>
</nav>
</div>
</div>
<h1><?= $config['site_title'] ?></h1>

View File

@ -19,20 +19,14 @@
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
*/
echo "<link rel='stylesheet' href='theme/style.css' type='text/css'>";
echo '<link rel="stylesheet" href="themes/'.$config['site_theme'].'/css/style.css" type="text/css">';
?>
<div id=header>
<a href <?= $config['site_url'] ?>><img src="theme/branding/logo.png" class="center logo"></a>
<h1><?= $config['site_title'] ?></h1>
</div>
<div class="wrapper padding">
<? if(!empty($message)) { ?>
<div id=infomsg><p><b><i><?= htmlspecialchars($message) ?></i></b></p></div>
<? } ?>
<? if(!empty($fullform)) { ?>
<p><?= $lang['home_text'] ?></p>
<? if($result === false) { ?>
<form id="keyform" method="POST">
<p>
<label for="email"><?= $lang['home_emaildesc'] ?></label>
@ -49,10 +43,7 @@ echo "<link rel='stylesheet' href='theme/style.css' type='text/css'>";
<input type="submit" value="<?= $lang['home_submitkey'] ?>" />
</p>
</form>
<? } ?>
<? } ?>
</div>
<div id=footer>
<img src="theme/branding/bottom_ribbon.png" class="cover">
<p><?= $lang['home_footer'] ?></p>
</div>

View File

@ -1,3 +1,4 @@
<?php
/*
@ -18,11 +19,17 @@
You should have received a copy of the GNU General Public License
along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
*/
*/
echo '<link rel="stylesheet" href="themes/'.$config['site_theme'].'/css/style.css" type="text/css">';
?>
<html>
<head>
<title>Lacre - PGP key management</title>
</head>
<body>
<div class="wrapper padding">
<? if(!empty($message)) { ?>
<div id=infomsg><p><?= htmlspecialchars($message) ?></p></div>
<? } ?>
<p>
<input type="submit" value="<?= $lang['info_back'] ?>" onclick="parent.location='index.php'">
</p>
</div>

View File

@ -1,10 +1,50 @@
-- confirm is empty once an email address has been confirmed, and otherwise is the confirmation key
-- status
-- lacre
--
-- This file is part of the lacre source code.
--
-- lacre is free software: you can redistribute it and/or modify it under the
-- terms of the GNU General Public License as published by the Free Software
-- Foundation, either version 3 of the License, or (at your option) any later
-- version.
--
-- lacre source code is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-- more details.
--
-- You should have received a copy of the GNU General Public License along
-- with lacre source code. If not, see <http://www.gnu.org/licenses/>.
-- confirm is empty once an email address has been confirmed, and otherwise is
-- the confirmation key status
-- initializes to 0
-- is set to 1 after a public key with (confirm='', status=0) has been imported
-- is set to 2 if a key should be deleted (will be deleted based on email address)
-- publickey is the ASCII-armored PGP public key; can be cleared to save space if status > 0
CREATE TABLE gpgmw_keys (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, email VARCHAR(256), publickey TEXT, confirm VARCHAR(32), status INT NOT NULL DEFAULT 0, time TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
CREATE TABLE lacre_keys (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
email VARCHAR(256),
publickey TEXT,
confirm VARCHAR(32),
status INT NOT NULL DEFAULT 0,
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- see include/lock.php for documentation
CREATE TABLE gpgmw_locks (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, ip VARCHAR(16), time INT, action VARCHAR(16), num INT);
CREATE TABLE lacre_locks (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
ip VARCHAR(16),
time INT,
action VARCHAR(16),
num INT
);
-- GnuPG identities known to lacre.
--
-- This table can be used instead of the file-based key store (pubring.kbx).
-- Set lacre configuration option [keyring]type to 'database' to use this
-- table.
CREATE TABLE lacre_identities (
email VARCHAR (256) NOT NULL PRIMARY KEY,
fingerprint VARCHAR (64) NOT NULL
);