Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
introduced read-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
yahesh committed Oct 28, 2019
1 parent 36a2559 commit 8163c20
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
# 0.14b0 (2019-10-28)

* introduced a read-only mode to simplify the migration to the upcoming release

# 0.13b0 (2018-11-02)

* introduced `apache_bugfix_encode()` and `apache_bugfix_decode()` to prevent "(36) File name too long" errors
Expand Down
33 changes: 19 additions & 14 deletions actions/share.php
Expand Up @@ -6,25 +6,30 @@
function share_secret($secret) {
$result = null;

# only proceed when the secret is not empty
if (!empty($secret)) {
# only proceed when the secret is not too long
if (MAX_PARAM_SIZE >= strlen($secret)) {
if (GNUPG_PECL) {
$encrypted_secret = encrypt_pecl($secret, GPG_KEY_FINGERPRINT, GPG_HOME_DIR);
} else {
$encrypted_secret = encrypt($secret, GPG_KEY_FINGERPRINT, GPG_HOME_DIR);
}
# only proceed when the read-only mode is not set
if ((!defined("READ_ONLY")) || (!READ_ONLY)) {
# only proceed when the secret is not empty
if (!empty($secret)) {
# only proceed when the secret is not too long
if (MAX_PARAM_SIZE >= strlen($secret)) {
if (GNUPG_PECL) {
$encrypted_secret = encrypt_pecl($secret, GPG_KEY_FINGERPRINT, GPG_HOME_DIR);
} else {
$encrypted_secret = encrypt($secret, GPG_KEY_FINGERPRINT, GPG_HOME_DIR);
}

if (null !== $encrypted_secret) {
# return the secret sharing URL
$result = htmlentities(SECRET_SHARING_URL.apache_bugfix_encode(url_base64_encode(base64_encode($encrypted_secret))));
if (null !== $encrypted_secret) {
# return the secret sharing URL
$result = htmlentities(SECRET_SHARING_URL.apache_bugfix_encode(url_base64_encode(base64_encode($encrypted_secret))));
}
} else {
$result = "<strong>ERROR: THE SECRET MUST BE SMALLER THAN ".MAX_PARAM_SIZE." CHARACTERS.</strong>";
}
} else {
$result = "<strong>ERROR: THE SECRET MUST BE SMALLER THAN ".MAX_PARAM_SIZE." CHARACTERS.</strong>";
$result = "<strong>ERROR: THE SECRET MUST NOT BE EMPTY.</strong>";
}
} else {
$result = "<strong>ERROR: THE SECRET MUST NOT BE EMPTY.</strong>";
$result = "<strong>ERROR: THE CREATION OF SECRET URLS IS DISABLED.</strong>";
}

# set default result if non is given
Expand Down
5 changes: 5 additions & 0 deletions config.php.default
Expand Up @@ -53,4 +53,9 @@
# IP addresses
define("LOG_IP_ADDRESS", false);

# this is the configuration to either enable or disable the
# read-only mode of the instance, set this to simplify the
# migration to the new GPG-less version
define("READ_ONLY", false);

?>
4 changes: 2 additions & 2 deletions index.php
@@ -1,8 +1,8 @@
<?php

# Shared-Secrets v0.13b0
# Shared-Secrets v0.14b0
#
# Copyright (c) 2016-2018, SysEleven GmbH
# Copyright (c) 2016-2019, SysEleven GmbH
# All rights reserved.
#
# This page allows you to share a secret through a secret sharing link.
Expand Down

0 comments on commit 8163c20

Please sign in to comment.