Skip to content
Snippets Groups Projects
Commit a5f8c04c authored by Tim van Dijen's avatar Tim van Dijen
Browse files
parent 98ae3780
No related branches found
No related tags found
No related merge requests found
Showing
with 92 additions and 72 deletions
......@@ -2,8 +2,8 @@
<?php
$baseDir = dirname(dirname(__FILE__));
require_once $baseDir.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'_autoload.php';
require_once \SimpleSAML\Utils\Config::getConfigDir().DIRECTORY_SEPARATOR.'config.php';
require_once $baseDir.DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . '_autoload.php';
require_once \SimpleSAML\Utils\Config::getConfigDir() . DIRECTORY_SEPARATOR . 'config.php';
# Iterate through configured metadata sources and ensure
# that a PDO source exists.
......@@ -18,10 +18,10 @@ foreach ($config['metadata.sources'] as $s) {
$metadata = [];
require_once $filename;
$set = basename($filename, ".php");
echo "importing set '$set'...".PHP_EOL;
echo "importing set '$set'..." . PHP_EOL;
foreach ($metadata as $k => $v) {
echo "\t$k".PHP_EOL;
echo "\t$k" . PHP_EOL;
$mdshp->addEntry($k, $set, $v);
}
}
......
......@@ -5,8 +5,8 @@
$baseDir = dirname(dirname(__FILE__));
// Add library autoloader and configuration
require_once $baseDir.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'_autoload.php';
require_once \SimpleSAML\Utils\Config::getConfigDir().DIRECTORY_SEPARATOR.'config.php';
require_once $baseDir . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . '_autoload.php';
require_once \SimpleSAML\Utils\Config::getConfigDir() . DIRECTORY_SEPARATOR . 'config.php';
echo "Initializing Metadata Database...".PHP_EOL;
......@@ -19,9 +19,9 @@ foreach ($config['metadata.sources'] as $source) {
$result = $metadataStorageHandler->initDatabase();
if ($result === false) {
echo "Failed to initialize metadata database.".PHP_EOL;
echo "Failed to initialize metadata database." . PHP_EOL;
} else {
echo "Successfully initialized metadata database.".PHP_EOL;
echo "Successfully initialized metadata database." . PHP_EOL;
}
}
}
#!/usr/bin/env php
<?php
// Check that the memcache library is enabled
if (!class_exists('Memcache') && !class_exists('Memcached')) {
echo "Error: the memcached (or memcache) PHP extension appears to be unavailable.\n";
......@@ -39,21 +38,21 @@ $keys = [];
foreach ($stats as $group) {
foreach ($group as $server => $state) {
if ($state === false) {
echo "WARNING: Server ".$server." is down.\n";
echo "WARNING: Server " . $server . " is down.\n";
$warnServerDown++;
continue;
}
$items = $state['curr_items'];
echo "Server ".$server." has ".$items." items.\n";
echo "Server " . $server . " has " . $items . " items.\n";
$serverKeys = getServerKeys($server);
$keys = array_merge($keys, $serverKeys);
}
}
echo "Total number of keys: ".count($keys)."\n";
echo "Total number of keys: " . count($keys) . "\n";
$keys = array_unique($keys);
echo "Total number of unique keys: ".count($keys)."\n";
echo "Total number of unique keys: ".count($keys) . "\n";
echo "Starting synchronization.\n" ;
......@@ -70,19 +69,19 @@ foreach ($keys as $key) {
echo "Synchronization done.\n";
echo $sync." keys in sync.\n";
echo $sync . " keys in sync.\n";
if ($skipped > 0) {
echo $skipped." keys skipped.\n";
echo $skipped . " keys skipped.\n";
echo "Keys are skipped because they are either expired, or are of a type unknown\n";
echo "to SimpleSAMLphp.\n";
}
if ($warnServerDown > 0) {
echo "WARNING: ".$warnServerDown." server(s) down. Not all servers are synchronized.\n";
echo "WARNING: " . $warnServerDown . " server(s) down. Not all servers are synchronized.\n";
}
if ($warnBigSlab > 0) {
echo "WARNING: ".$warnBigSlab." slab(s) may have contained more keys than we were told about.\n";
echo "WARNING: " . $warnBigSlab . " slab(s) may have contained more keys than we were told about.\n";
}
/**
......@@ -98,7 +97,7 @@ function getServerKeys($server)
$host = $server[0];
$port = (int) $server[1];
echo "Connecting to: ".$host.":".$port."\n";
echo "Connecting to: " . $host . ":" . $port . "\n";
$socket = fsockopen($host, $port);
echo "Connected. Finding keys.\n";
......@@ -126,7 +125,7 @@ function getServerKeys($server)
// Dump keys in slabs
$keys = [];
foreach ($slabs as $slab) {
if (fwrite($socket, "stats cachedump ".$slab." 1000000\r\n") === false) {
if (fwrite($socket, "stats cachedump " . $slab . " 1000000\r\n") === false) {
echo "Error requesting cache dump from server.\n";
exit(1);
}
......@@ -147,17 +146,17 @@ function getServerKeys($server)
if (preg_match('/^ITEM (.*) \[\d+ b; \d+ s\]/', $line, $matches)) {
$keys[] = $matches[1];
} else {
echo "Unknown result from cache dump: ".$line."\n";
echo "Unknown result from cache dump: " . $line . "\n";
}
}
if ($resultSize > 1900000 || count($keys) >= 1000000) {
echo "WARNING: Slab ".$slab." on server ".$host.":".$port.
echo "WARNING: Slab ".$slab." on server " . $host . ":" . $port .
" may have contained more keys than we were told about.\n";
$GLOBALS['warnBigSlab'] += 1;
}
}
echo "Found ".count($keys)." key(s).\n";
echo "Found " . count($keys) . " key(s).\n";
fclose($socket);
return $keys;
......
#!/usr/bin/env php
<?php
/*
* Interactive script to generate password hashes.
*
*/
// This is the base directory of the SimpleSAMLphp installation
$baseDir = dirname(dirname(__FILE__));
// Add library autoloader
require_once($baseDir.'/lib/_autoload.php');
require_once($baseDir . '/lib/_autoload.php');
echo "Enter password: ";
......@@ -21,4 +21,4 @@ if (empty($password)) {
exit(1);
}
echo "\n ".SimpleSAML\Utils\Crypto::pwHash($password)."\n\n";
echo "\n " . SimpleSAML\Utils\Crypto::pwHash($password) . "\n\n";
......@@ -6,17 +6,17 @@
* translation file for each supported language.
*/
$base = __DIR__.'/../';
$base = __DIR__ . '/../';
include_once($base.'vendor/autoload.php');
include_once($base . 'vendor/autoload.php');
include_once($base.'attributemap/name2urn.php');
include_once($base . 'attributemap/name2urn.php');
$names = $attributemap;
include_once($base.'attributemap/urn2oid.php');
include_once($base . 'attributemap/urn2oid.php');
$urns = $attributemap;
include_once($base.'attributemap/newSchacNS.php');
include_once($base . 'attributemap/newSchacNS.php');
$schac = $attributemap;
/*
......@@ -25,8 +25,8 @@ $schac = $attributemap;
* probably consider moving the "dictionaries/attributes.definition.json" file somewhere else, and keep using it as
* the authoritative source of known attributes for this script.
*/
$defs = json_decode(file_get_contents($base.'dictionaries/attributes.definition.json'), true);
$trans = json_decode(file_get_contents($base.'dictionaries/attributes.translation.json'), true);
$defs = json_decode(file_get_contents($base . 'dictionaries/attributes.definition.json'), true);
$trans = json_decode(file_get_contents($base . 'dictionaries/attributes.translation.json'), true);
$attributes = [];
......@@ -38,16 +38,16 @@ unset($languages['no']);
// build the list of attributes with their corresponding aliases
foreach ($names as $name => $urn) {
$lower = str_replace([':', '-'], '_', strtolower($name));
if (!array_key_exists('attribute_'.$lower, $defs)) {
if (!array_key_exists('attribute_' . $lower, $defs)) {
$defs['attribute_'.$lower] = [];
}
if (!array_key_exists('attribute_'.$lower, $trans)) {
if (!array_key_exists('attribute_' . $lower, $trans)) {
$trans['attribute_'.$lower] = [];
}
if (array_key_exists('no', $trans['attribute_'.$lower])) {
if (array_key_exists('no', $trans['attribute_' . $lower])) {
// fix the locale code
$trans['attribute_'.$lower]['nb'] = $trans['attribute_'.$lower]['no'];
unset($trans['attribute_'.$lower]['no']);
$trans['attribute_' . $lower]['nb'] = $trans['attribute_' . $lower]['no'];
unset($trans['attribute_' . $lower]['no']);
}
$names = [$name, $urn, $urns[$urn]];
if (array_key_exists($urn, $schac)) {
......@@ -57,16 +57,16 @@ foreach ($names as $name => $urn) {
'names' => $names,
'translations' => array_merge(
[
'en' => $defs['attribute_'.$lower]['en'],
'en' => $defs['attribute_' . $lower]['en'],
],
$trans['attribute_'.$lower]
$trans['attribute_' . $lower]
),
];
}
// process other sets of attributes
foreach (['facebook', 'linkedin', 'openid', 'twitter', 'windowslive'] as $set) {
include_once($base.'attributemap/'.$set.'2name.php');
include_once($base . 'attributemap/' . $set . '2name.php');
foreach ($attributemap as $alias => $attr) {
if (array_key_exists($attr, $attributes)) {
$attributes[$attr]['names'][] = $alias;
......@@ -79,7 +79,7 @@ foreach (array_keys($languages) as $language) {
$strings = new Gettext\Translations();
// load existing translations in the PO files
$strings->addFromPoFile($base.'locales/'.$language."/LC_MESSAGES/attributes.po");
$strings->addFromPoFile($base . 'locales/' . $language . "/LC_MESSAGES/attributes.po");
foreach ($attributes as $attribute) {
foreach ($attribute['names'] as $name) {
......@@ -88,7 +88,8 @@ foreach (array_keys($languages) as $language) {
}
$translation = new Gettext\Translation('', $name);
if (array_key_exists($language, $attribute['translations']) &&
!is_null($attribute['translations'][$language])) {
!is_null($attribute['translations'][$language])
) {
$t = $strings->find($translation);
if ($t) {
if ($t->getOriginal() === $t->getTranslation()) {
......@@ -98,7 +99,7 @@ foreach (array_keys($languages) as $language) {
}
}
if (!is_null($attribute['translations']['en']) && $language !== 'en') {
$translation->addComment('English string: '.$attribute['translations']['en']);
$translation->addComment('English string: ' . $attribute['translations']['en']);
}
$strings[] = $translation;
}
......@@ -116,6 +117,6 @@ foreach (array_keys($languages) as $language) {
$strings->deleteHeader('PO-Revision-Date');
$strings->setLanguage($language);
echo "Saving translations to ".$base."locales/".$language."/LC_MESSAGES/attributes.po\n";
Gettext\Generators\Po::toFile($strings, $base.'locales/'.$language.'/LC_MESSAGES/attributes.po');
echo "Saving translations to " . $base . "locales/" . $language . "/LC_MESSAGES/attributes.po\n";
Gettext\Generators\Po::toFile($strings, $base . 'locales/' . $language . '/LC_MESSAGES/attributes.po');
}
......@@ -57,7 +57,8 @@ $config = [
'dsn' => 'pgsql:host=sql.example.org;port=5432;dbname=simplesaml',
'username' => 'simplesaml',
'password' => 'secretpassword',
'query' => 'SELECT uid, givenName, email, eduPersonPrincipalName FROM users WHERE uid = :username AND password = SHA2(CONCAT((SELECT salt FROM users WHERE uid = :username), :password), 256);',
'query' => 'SELECT uid, givenName, email, eduPersonPrincipalName FROM users WHERE uid = :username ' .
'AND password = SHA2(CONCAT((SELECT salt FROM users WHERE uid = :username), :password), 256);',
],
*/
......
<?php
/**
* SAML 2.0 IdP configuration for SimpleSAMLphp.
*
......
<?php
/**
* SAML 2.0 remote IdP metadata for SimpleSAMLphp.
*
......
<?php
/**
* SAML 2.0 remote SP metadata for SimpleSAMLphp.
*
......
<?php
/**
* SAML 1.1 IdP configuration for SimpleSAMLphp.
*
......
<?php
/**
* SAML 1.1 remote IdP metadata for SimpleSAMLphp.
*
......
<?php
/**
* SAML 1.1 SP configuration for SimpleSAMLphp.
*
......
<?php
/**
* SAML 1.1 remote SP metadata for SimpleSAMLphp.
*
......
<?php
/**
* WS-Federation remote IdP metadata for SimpleSAMLphp.
*/
......
<?php
/**
* WS-Federation SP configuration for SimpleSAMLphp.
*
......
......@@ -9,7 +9,7 @@ import json from "highlight.js/lib/languages/json";
$(document).ready(function () {
// get available languages
let languages = $.map($('#language-selector option'), function (option) {
return option.text.toLowerCase();
return option.text.toLowerCase();
});
// initialize selectize
......@@ -30,7 +30,7 @@ $(document).ready(function () {
});
// expander boxes
$('.expandable > .expander').on('click', function(e) {
$('.expandable > .expander').on('click', function (e) {
e.preventDefault();
let target = $(e.currentTarget);
target.parents('.expandable').toggleClass('expanded');
......@@ -41,15 +41,15 @@ $(document).ready(function () {
hljs.registerLanguage('xml', xml);
hljs.registerLanguage('php', php);
hljs.registerLanguage('json', json);
$('.code-box-content.xml, .code-box-content.php, .code-box-content.json').each(function(i, block) {
$('.code-box-content.xml, .code-box-content.php, .code-box-content.json').each(function (i, block) {
hljs.highlightBlock(block)
});
// clipboard
let clipboard = new ClipboardJS('.copy');
clipboard.on('success', function(e) {
setTimeout(function() {
clipboard.on('success', function (e) {
setTimeout(function () {
e.clearSelection();
}, 150);
});
});
\ No newline at end of file
});
......@@ -12,7 +12,8 @@
* error or not, and call the appropriate method (either completed() or failed()).
*/
class SimpleSAMLLogout {
constructor(page) {
constructor(page)
{
if (page === 'core:logout-iframe') { // main page
this.populateData();
if (Object.keys(this.sps).length === 0) {
......@@ -21,7 +22,6 @@ class SimpleSAMLLogout {
}
this.btnall.on('click', this.initLogout.bind(this));
window.addEventListener('message', this.clearAssociation.bind(this), false);
} else if (page === 'IFrameLogoutHandler') { // iframe
let data = $('i[id="data"]');
let message = {
......@@ -41,7 +41,8 @@ class SimpleSAMLLogout {
*
* @param event The event containing the message from the iframe.
*/
clearAssociation(event) {
clearAssociation(event)
{
if (event.origin !== SimpleSAMLLogout.getOrigin()) {
// we don't accept events from other origins
return;
......@@ -69,7 +70,8 @@ class SimpleSAMLLogout {
*
* @param id The ID of the SP that completed logout successfully.
*/
completed(id) {
completed(id)
{
if (typeof this.sps[id] === 'undefined') {
return;
}
......@@ -91,7 +93,8 @@ class SimpleSAMLLogout {
* @param id The ID of the SP that failed to complete logout.
* @param reason The reason why logout failed.
*/
failed(id, reason) {
failed(id, reason)
{
if (typeof this.sps[id] === 'undefined') {
return;
}
......@@ -121,7 +124,8 @@ class SimpleSAMLLogout {
*
* Note: this method won't do anything if there are SPs pending logout (e.g. waiting for the timeout).
*/
finish() {
finish()
{
if (Object.keys(this.sps).length > 0) { // pending services
return;
}
......@@ -134,7 +138,6 @@ class SimpleSAMLLogout {
this.errmsg.removeClass('hidden');
this.errfrm.removeClass('hidden');
this.actions.addClass('hidden');
} else { // all services done
this.btncontinue.click();
}
......@@ -144,12 +147,13 @@ class SimpleSAMLLogout {
/**
* Get the origin of the current page.
*/
static getOrigin() {
static getOrigin()
{
let origin = window.location.origin;
if (!origin) {
// IE < 11 does not support window.location.origin
origin = window.location.protocol + "//" + window.location.hostname +
(window.location.port ? ':' + window.location.port: '');
(window.location.port ? ':' + window.location.port : '');
}
return origin;
}
......@@ -160,7 +164,8 @@ class SimpleSAMLLogout {
*
* @param event The click event on the "Yes, all services" button.
*/
initLogout(event) {
initLogout(event)
{
event.preventDefault();
this.btnall.prop('disabled', true);
......@@ -180,7 +185,8 @@ class SimpleSAMLLogout {
*
* If an SP didn't reply by the timeout, we'll mark it as failed.
*/
initTimeout() {
initTimeout()
{
let timeout = 10;
for (const id in this.sps) {
......@@ -217,7 +223,8 @@ class SimpleSAMLLogout {
/**
* This method populates the data we need from data-* properties in the page.
*/
populateData() {
populateData()
{
this.sps = {};
this.btnall = $('button[id="btn-all"]');
this.btncancel = $('button[id="btn-cancel"]');
......@@ -231,7 +238,7 @@ class SimpleSAMLLogout {
// initialise SP status and timeout arrays
$('li[id^="sp-"]').each(function () {
let id = $(this).data('id');
let iframe = $('iframe[id="iframe-'+id+'"]');
let iframe = $('iframe[id="iframe-' + id + '"]');
let status = $(this).data('status');
switch (status) {
......@@ -246,10 +253,10 @@ class SimpleSAMLLogout {
timeout: $(this).data('timeout'),
element: $(this),
iframe: iframe,
icon: $('i[id="icon-'+id+'"]'),
icon: $('i[id="icon-' + id + '"]'),
};
});
}
}
export default SimpleSAMLLogout;
\ No newline at end of file
export default SimpleSAMLLogout;
<?php
// initialize the autoloader
require_once(dirname(dirname(__FILE__)).'/lib/_autoload.php');
require_once(dirname(dirname(__FILE__)) . '/lib/_autoload.php');
// enable assertion handler for all pages
\SimpleSAML\Error\Assertion::installHandler();
......@@ -45,7 +45,7 @@ function SimpleSAML_error_handler($errno, $errstr, $errfile = null, $errline = 0
// show an error with a full backtrace
$context = (is_null($errfile) ? '' : " at $errfile:$errline");
$e = new \SimpleSAML\Error\Exception('Error '.$errno.' - '.$errstr.$context);
$e = new \SimpleSAML\Error\Exception('Error ' . $errno . ' - ' . $errstr . $context);
$e->logError();
// resume normal error processing
......
......@@ -41,8 +41,8 @@ if (!empty($xmldata)) {
// remove the entityDescriptor element because it is unused, and only makes the output harder to read
unset($entityMetadata['entityDescriptor']);
$text .= '$metadata['.var_export($entityId, true).'] = '.
var_export($entityMetadata, true).";\n";
$text .= '$metadata[' . var_export($entityId, true) . '] = ' .
var_export($entityMetadata, true) . ";\n";
}
$entities = $text;
}
......
......@@ -10,7 +10,10 @@ $session = \SimpleSAML\Session::getSessionFromRequest();
$template = new \SimpleSAML\XHTML\Template($config, 'sandbox.php');
$template->data['pagetitle'] = 'Sandbox';
$template->data['sometext'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur.';
$template->data['sometext'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.' .
' Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit.' .
' Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. ' .
'Nam tincidunt congue enim, ut porta lorem lacinia consectetur.';
$template->data['remaining'] = $session->getAuthData('admin', 'Expire') - time();
$template->data['logout'] = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment