Rationalise the signature logs
rodzic
bc445fd7e6
commit
5a00070028
18
index.php
18
index.php
|
@ -600,7 +600,7 @@ HTML;
|
||||||
// Buttons to interact with a message.
|
// Buttons to interact with a message.
|
||||||
// By default, just shows a "Follow User" button.
|
// By default, just shows a "Follow User" button.
|
||||||
if ( "read" == $style ) {
|
if ( "read" == $style ) {
|
||||||
$interactHTML = "<a href=\"/users?account=$actorUsername\">➕</a> ";
|
$interactHTML = "<a href=\"/users?account=$actorUsername\">👤</a> ";
|
||||||
} else {
|
} else {
|
||||||
$interactHTML = "";
|
$interactHTML = "";
|
||||||
}
|
}
|
||||||
|
@ -1415,6 +1415,11 @@ HTML;
|
||||||
function verifyHTTPSignature() {
|
function verifyHTTPSignature() {
|
||||||
global $input, $body, $server, $directories;
|
global $input, $body, $server, $directories;
|
||||||
|
|
||||||
|
// What type of message is this? What's the time now?
|
||||||
|
// Used in the log filename.
|
||||||
|
$type = urlencode( $body["type"] );
|
||||||
|
$timestamp = ( new DateTime() )->format( DATE_RFC3339_EXTENDED );
|
||||||
|
|
||||||
// Get the headers send with the request
|
// Get the headers send with the request
|
||||||
$headers = getallheaders();
|
$headers = getallheaders();
|
||||||
// Ensure the header keys match the format expected by the signature
|
// Ensure the header keys match the format expected by the signature
|
||||||
|
@ -1430,9 +1435,8 @@ HTML;
|
||||||
$timeDifference = abs( $currentDatetime->getTimestamp() - $headerDatetime->getTimestamp() );
|
$timeDifference = abs( $currentDatetime->getTimestamp() - $headerDatetime->getTimestamp() );
|
||||||
if ( $timeDifference > 30 ) {
|
if ( $timeDifference > 30 ) {
|
||||||
// Write a log detailing the error
|
// Write a log detailing the error
|
||||||
$timestamp = ( new DateTime() )->format( DATE_RFC3339_EXTENDED );
|
|
||||||
// Filename for the log
|
// Filename for the log
|
||||||
$filename = "{$timestamp}.Signature.Time_Failure.txt";
|
$filename = "{$timestamp}.{$type}.Signature.Time_Failure.txt";
|
||||||
|
|
||||||
// Save headers and request data to the timestamped file in the logs directory
|
// Save headers and request data to the timestamped file in the logs directory
|
||||||
file_put_contents( $directories["logs"] . "/{$filename}",
|
file_put_contents( $directories["logs"] . "/{$filename}",
|
||||||
|
@ -1467,9 +1471,7 @@ HTML;
|
||||||
// Does our calculation match what was sent?
|
// Does our calculation match what was sent?
|
||||||
if ( !( $digestCalculated == $digestHash ) ) {
|
if ( !( $digestCalculated == $digestHash ) ) {
|
||||||
// Write a log detailing the error
|
// Write a log detailing the error
|
||||||
$timestamp = ( new DateTime() )->format( DATE_RFC3339_EXTENDED );
|
$filename = "{$timestamp}.{$type}.Signature.Digest_Failure.txt";
|
||||||
// Filename for the log
|
|
||||||
$filename = "{$timestamp}.Signature.Digest_Failure.txt";
|
|
||||||
|
|
||||||
// Save headers and request data to the timestamped file in the logs directory
|
// Save headers and request data to the timestamped file in the logs directory
|
||||||
file_put_contents( $directories["logs"] . "/{$filename}",
|
file_put_contents( $directories["logs"] . "/{$filename}",
|
||||||
|
@ -1551,10 +1553,8 @@ HTML;
|
||||||
$verified = null;
|
$verified = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write a log detailing the signature verification process
|
|
||||||
$timestamp = ( new DateTime() )->format( DATE_RFC3339_EXTENDED );
|
|
||||||
// Filename for the log
|
// Filename for the log
|
||||||
$filename = "{$timestamp}.Signature.". json_encode( $verified ) . ".txt";
|
$filename = "{$timestamp}.{$type}.Signature.". json_encode( $verified ) . ".txt";
|
||||||
|
|
||||||
// Save headers and request data to the timestamped file in the logs directory
|
// Save headers and request data to the timestamped file in the logs directory
|
||||||
file_put_contents( $directories["logs"] . "/{$filename}",
|
file_put_contents( $directories["logs"] . "/{$filename}",
|
||||||
|
|
Ładowanie…
Reference in New Issue