Skip to content

Instantly share code, notes, and snippets.

@StephenKing
Last active February 19, 2022 21:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save StephenKing/4531841 to your computer and use it in GitHub Desktop.
Save StephenKing/4531841 to your computer and use it in GitHub Desktop.
<VirtualHost *:443>
ServerName review.typo3.org
ServerAlias
DocumentRoot /var/www
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/ssl_certs/....crt
SSLCertificateKeyFile /etc/ssl_certs/....key
LogLevel info
ErrorLog /var/log/apache2/review.typo3.org-error.log
CustomLog /var/log/apache2/review.typo3.org-access.log combined
AddExternalAuth typo3org-auth /var/gerrit/scripts/typo3org-authentication.php
SetExternalAuthMethod typo3org-auth pipe
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location "/login/">
AuthType Basic
AuthName "Review System - Please log in with your typo3.org username and passwords."
AuthBasicProvider external
AuthExternal typo3org-auth
Require valid-user
</Location>
ProxyPass / http://localhost:8080/
</VirtualHost>
<VirtualHost *:80>
ServerName review.typo3.org
ServerAlias
RewriteEngine On
RewriteRule (.*) https://%{HTTP_HOST}$1
</VirtualHost>
#!/usr/bin/php
<?php
$credentials['apiKey'] = 'xxxx';
$fp = fopen('php://stdin', 'rb');
$credentials['username'] = trim(fgets($fp, 4096));
$credentials['password'] = trim(fgets($fp, 4096));
fclose($fp);
// Build Http query using params
$postData = http_build_query($credentials);
$header = array(
"Connection: close",
"Content-Length: " . strlen($postData),
"Content-Type: application/x-www-form-urlencoded",
"User-agent: Gerrit Code Review typo3org-authentication.php",
);
// Create Http context details
$contextData = array (
'method' => 'POST',
'header' => implode("\r\n", $header) . "\r\n",
'content' => $postData
);
// Create context resource for our request
$context = stream_context_create (array('http' => $contextData));
$url = 'https://example.com/authenticate.php';
if (file_get_contents($url, false, $context) === '1') {
exit(0);
} else {
exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment