From bea05a39a06deba7451b0e7d385edbc273d09cfc Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Wed, 13 Mar 2019 23:43:13 +0100 Subject: [PATCH 001/135] Initial import --- .codecov.yml | 11 + .php_cs.dist | 17 + .travis.yml | 32 ++ bin/check-syntax.sh | 15 + composer.json | 45 ++ config-templates/module_consentAdmin.php | 35 ++ default-enable | 3 + dictionaries/consentadmin.definition.json | 65 +++ dictionaries/consentadmin.translation.json | 607 +++++++++++++++++++++ docs/consentAdmin.md | 77 +++ hooks/hook_configpage.php | 15 + hooks/hook_frontpage.php | 19 + locales/ar/LC_MESSAGES/consentAdmin.po | 157 ++++++ locales/cs/LC_MESSAGES/consentAdmin.po | 159 ++++++ locales/da/LC_MESSAGES/consentAdmin.po | 204 +++++++ locales/de/LC_MESSAGES/consentAdmin.po | 166 ++++++ locales/el/LC_MESSAGES/consentAdmin.po | 158 ++++++ locales/en/LC_MESSAGES/consentAdmin.po | 173 ++++++ locales/es/LC_MESSAGES/consentAdmin.po | 166 ++++++ locales/et/LC_MESSAGES/consentAdmin.po | 160 ++++++ locales/eu/LC_MESSAGES/consentAdmin.po | 160 ++++++ locales/fr/LC_MESSAGES/consentAdmin.po | 164 ++++++ locales/he/LC_MESSAGES/consentAdmin.po | 158 ++++++ locales/hr/LC_MESSAGES/consentAdmin.po | 161 ++++++ locales/hu/LC_MESSAGES/consentAdmin.po | 158 ++++++ locales/id/LC_MESSAGES/consentAdmin.po | 164 ++++++ locales/it/LC_MESSAGES/consentAdmin.po | 164 ++++++ locales/ja/LC_MESSAGES/consentAdmin.po | 158 ++++++ locales/lt/LC_MESSAGES/consentAdmin.po | 159 ++++++ locales/lv/LC_MESSAGES/consentAdmin.po | 161 ++++++ locales/nb/LC_MESSAGES/consentAdmin.po | 162 ++++++ locales/nl/LC_MESSAGES/consentAdmin.po | 164 ++++++ locales/nn/LC_MESSAGES/consentAdmin.po | 162 ++++++ locales/pt/LC_MESSAGES/consentAdmin.po | 158 ++++++ locales/ro/LC_MESSAGES/consentAdmin.po | 163 ++++++ locales/ru/LC_MESSAGES/consentAdmin.po | 161 ++++++ locales/sl/LC_MESSAGES/consentAdmin.po | 159 ++++++ locales/sr/LC_MESSAGES/consentAdmin.po | 161 ++++++ locales/sv/LC_MESSAGES/consentAdmin.po | 160 ++++++ locales/zh-tw/LC_MESSAGES/consentAdmin.po | 158 ++++++ locales/zh/LC_MESSAGES/consentAdmin.po | 158 ++++++ phpunit.xml | 19 + psalm.xml | 30 + templates/consentadmin.php | 90 +++ templates/consentadmin.twig | 82 +++ templates/consentadminajax.php | 2 + templates/consentadminajax.twig | 3 + tests/bootstrap.php | 11 + www/assets/css/consentAdmin.css | 39 ++ www/assets/js/consentAdmin.js | 79 +++ www/consentAdmin.php | 338 ++++++++++++ 51 files changed, 6350 insertions(+) create mode 100644 .codecov.yml create mode 100644 .php_cs.dist create mode 100644 .travis.yml create mode 100755 bin/check-syntax.sh create mode 100644 composer.json create mode 100644 config-templates/module_consentAdmin.php create mode 100644 default-enable create mode 100644 dictionaries/consentadmin.definition.json create mode 100644 dictionaries/consentadmin.translation.json create mode 100644 docs/consentAdmin.md create mode 100644 hooks/hook_configpage.php create mode 100644 hooks/hook_frontpage.php create mode 100644 locales/ar/LC_MESSAGES/consentAdmin.po create mode 100644 locales/cs/LC_MESSAGES/consentAdmin.po create mode 100644 locales/da/LC_MESSAGES/consentAdmin.po create mode 100644 locales/de/LC_MESSAGES/consentAdmin.po create mode 100644 locales/el/LC_MESSAGES/consentAdmin.po create mode 100644 locales/en/LC_MESSAGES/consentAdmin.po create mode 100644 locales/es/LC_MESSAGES/consentAdmin.po create mode 100644 locales/et/LC_MESSAGES/consentAdmin.po create mode 100644 locales/eu/LC_MESSAGES/consentAdmin.po create mode 100644 locales/fr/LC_MESSAGES/consentAdmin.po create mode 100644 locales/he/LC_MESSAGES/consentAdmin.po create mode 100644 locales/hr/LC_MESSAGES/consentAdmin.po create mode 100644 locales/hu/LC_MESSAGES/consentAdmin.po create mode 100644 locales/id/LC_MESSAGES/consentAdmin.po create mode 100644 locales/it/LC_MESSAGES/consentAdmin.po create mode 100644 locales/ja/LC_MESSAGES/consentAdmin.po create mode 100644 locales/lt/LC_MESSAGES/consentAdmin.po create mode 100644 locales/lv/LC_MESSAGES/consentAdmin.po create mode 100644 locales/nb/LC_MESSAGES/consentAdmin.po create mode 100644 locales/nl/LC_MESSAGES/consentAdmin.po create mode 100644 locales/nn/LC_MESSAGES/consentAdmin.po create mode 100644 locales/pt/LC_MESSAGES/consentAdmin.po create mode 100644 locales/ro/LC_MESSAGES/consentAdmin.po create mode 100644 locales/ru/LC_MESSAGES/consentAdmin.po create mode 100644 locales/sl/LC_MESSAGES/consentAdmin.po create mode 100644 locales/sr/LC_MESSAGES/consentAdmin.po create mode 100644 locales/sv/LC_MESSAGES/consentAdmin.po create mode 100644 locales/zh-tw/LC_MESSAGES/consentAdmin.po create mode 100644 locales/zh/LC_MESSAGES/consentAdmin.po create mode 100644 phpunit.xml create mode 100644 psalm.xml create mode 100644 templates/consentadmin.php create mode 100644 templates/consentadmin.twig create mode 100644 templates/consentadminajax.php create mode 100644 templates/consentadminajax.twig create mode 100644 tests/bootstrap.php create mode 100644 www/assets/css/consentAdmin.css create mode 100644 www/assets/js/consentAdmin.js create mode 100644 www/consentAdmin.php diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..f7f39e1 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,11 @@ +coverage: + status: + project: yes + +comment: + layout: "diff" + behavior: once + require_changes: true + require_base: no + require_head: yes + branches: null diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..6a85976 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,17 @@ +in([ + __DIR__ . '/config-templates', + __DIR__ . '/hooks', + __DIR__ . '/tests', + __DIR__ . '/www', + ]) +; +return PhpCsFixer\Config::create() + ->setRules([ + '@PSR2' => true, + '@PSR4' => true, + '@PSR5' => true, + ]) + ->setFinder($finder) +; diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c47ac23 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,32 @@ +sudo: required + +language: php + +php: + - 5.5 + - 5.6 + - 7.0 + - 7.1 + - 7.2 + - 7.3 + +env: + - SIMPLESAMLPHP_VERSION=1.17.* + +before_script: + - composer require "simplesamlphp/simplesamlphp:${SIMPLESAMLPHP_VERSION}" --no-update + - composer update --no-interaction + - if [[ "$TRAVIS_PHP_VERSION" == "7.3" ]]; then composer require --dev vimeo/psalm:1.1.9; fi + +script: + - bin/check-syntax.sh + - if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]]; then php vendor/phpunit/phpunit/phpunit; else php vendor/phpunit/phpunit/phpunit --no-coverage; fi + - if [[ "$TRAVIS_PHP_VERSION" == "7.3" ]]; then vendor/bin/psalm; fi + +after_success: + # Codecov, need to edit bash uploader for incorrect TRAVIS_PYTHON_VERSION environment variable matching, at least until codecov/codecov-bash#133 is resolved + - curl -s https://codecov.io/bash > .codecov + - sed -i -e 's/TRAVIS_.*_VERSION/^TRAVIS_.*_VERSION=/' .codecov + - chmod +x .codecov + - if [[ $TRAVIS_PHP_VERSION == "5.6" ]]; then ./.codecov -X gcov; fi +# - if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]]; then bash <(curl -s https://codecov.io/bash); fi diff --git a/bin/check-syntax.sh b/bin/check-syntax.sh new file mode 100755 index 0000000..718d5d5 --- /dev/null +++ b/bin/check-syntax.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +PHP='/usr/bin/env php' +RETURN=0 + +# check PHP files +for FILE in `find config-templates hooks tests templates www -name "*.php"`; do + $PHP -l $FILE > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Syntax check failed for ${FILE}" + RETURN=`expr ${RETURN} + 1` + fi +done + +exit $RETURN diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d4062d1 --- /dev/null +++ b/composer.json @@ -0,0 +1,45 @@ +{ + "name": "simplesamlphp/simplesamlphp-module-consentadmin", + "description": "A module that allows users to manage their consent", + "type": "simplesamlphp-module", + "keywords": ["simplesamlphp", "consentadmin"], + "license": "LGPL-3.0-or-later", + "authors": [ + { + "name": "Jacob Christiansen", + "email": "jach@wayf.dk" + }, + { + "name": "Olav Morken", + "email": "lavmrk@gmail.com" + } + ], + "config": { + "preferred-install": { + "simplesamlphp/simplesamlphp": "source", + "*": "dist" + } + }, + "autoload-dev": { + "psr-4": { + "SimpleSAML\\Test\\Utils\\": "vendor/simplesamlphp/simplesamlphp/tests/Utils" + } + }, + "require": { + "php": ">=5.5", + "simplesamlphp/composer-module-installer": "~1.1", + "simplesamlphp/simplesamlphp-module-consent": "^1.0", + "webmozart/assert": "~1.4" + }, + "require-dev": { + "simplesamlphp/simplesamlphp": "^1.17", + "phpunit/phpunit": "~4.8.36" + }, + "extra": { + "ssp-mixedcase-module-name": "consentAdmin" + }, + "support": { + "issues": "https://github.com/tvdijen/simplesamlphp-module-consentadmin/issues", + "source": "https://github.com/tvdijen/simplesamlphp-module-consentadmin" + } +} diff --git a/config-templates/module_consentAdmin.php b/config-templates/module_consentAdmin.php new file mode 100644 index 0000000..9c54203 --- /dev/null +++ b/config-templates/module_consentAdmin.php @@ -0,0 +1,35 @@ + + * @package SimpleSAMLphp + */ +$config = [ + /* + * Configuration for the database connection. + */ + 'consentadmin' => [ + 'consent:Database', + 'dsn' => 'mysql:host=DBHOST;dbname=DBNAME', + 'username' => 'USERNAME', + 'password' => 'PASSWORD', + ], + + // Hash attributes including values or not + 'attributes.hash' => true, + + // If you set attributes.exclude in the consent module, this must match + // 'attributes.exclude' => [], + + // Where to direct the user after logout + // REMEMBER to prefix with http:// otherwise the relaystate is only appended + // to saml2 logout URL + 'returnURL' => 'http://www.wayf.dk', + + // Shows description of the services if set to true (defaults to true) + 'showDescription' => true, + + // Set authority + 'authority' => 'saml2', +]; diff --git a/default-enable b/default-enable new file mode 100644 index 0000000..25615cb --- /dev/null +++ b/default-enable @@ -0,0 +1,3 @@ +This file indicates that the default state of this module +is enabled. To disable, create a file named disable in the +same directory as this file. diff --git a/dictionaries/consentadmin.definition.json b/dictionaries/consentadmin.definition.json new file mode 100644 index 0000000..7864ff1 --- /dev/null +++ b/dictionaries/consentadmin.definition.json @@ -0,0 +1,65 @@ +{ + "sp_empty_description": { + "en": "(no description)" + }, + "attribute_org": { + "en": "Organisation" + }, + "added": { + "en": "Consent Added" + }, + "removed": { + "en": "Consent Removed" + }, + "updated": { + "en": "Consent Updated" + }, + "unknown": { + "en": "Unknown ..." + }, + "attribute_id": { + "en": "Identity" + }, + "attribute_injected": { + "en": "Injected attribut" + }, + "show": { + "en": "Show" + }, + "hide": { + "en": "Hide" + }, + "attributes_text": { + "en": "attributes" + }, + "consentadmin_header": { + "en": "Consent Administration" + }, + "consentadmin_description1": { + "en": "Here you can view and edit your consent for the Service Providers." + }, + "consentadmin_description2": { + "en": "\n

How to delete your consent<\/h3>\nUncheck the box corresponding to the service provider\n\n

Links<\/h3>\n