Skip to content

Commit fac0eb4

Browse files
committed
Initial import
1 parent 3b09487 commit fac0eb4

File tree

49 files changed

+2016
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2016
-0
lines changed

.codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
coverage:
2+
status:
3+
project: yes
4+
5+
comment:
6+
layout: "diff"
7+
behavior: once
8+
require_changes: true
9+
require_base: no
10+
require_head: yes
11+
branches: null

.php_cs.dist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->in([
4+
__DIR__ . '/lib',
5+
__DIR__ . '/templates',
6+
__DIR__ . '/tests',
7+
__DIR__ . '/www',
8+
])
9+
;
10+
return PhpCsFixer\Config::create()
11+
->setRules([
12+
'@PSR2' => true,
13+
'@PSR4' => true,
14+
'@PSR5' => true,
15+
])
16+
->setFinder($finder)
17+
;

.travis.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
sudo: required
2+
3+
language: php
4+
5+
php:
6+
- 5.6
7+
- 7.0
8+
- 7.1
9+
- 7.2
10+
- 7.3
11+
12+
env:
13+
- SIMPLESAMLPHP_VERSION=1.17.*
14+
15+
before_script:
16+
- composer require "simplesamlphp/simplesamlphp:${SIMPLESAMLPHP_VERSION}" --no-update
17+
- composer update --no-interaction
18+
- if [[ "$TRAVIS_PHP_VERSION" == "7.3" ]]; then composer require --dev vimeo/psalm:1.1.9; fi
19+
20+
script:
21+
- bin/check-syntax.sh
22+
- if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]]; then php vendor/phpunit/phpunit/phpunit; else php vendor/phpunit/phpunit/phpunit --no-coverage; fi
23+
- if [[ "$TRAVIS_PHP_VERSION" == "7.3" ]]; then vendor/bin/psalm; fi
24+
25+
after_success:
26+
# Codecov, need to edit bash uploader for incorrect TRAVIS_PYTHON_VERSION environment variable matching, at least until codecov/codecov-bash#133 is resolved
27+
- curl -s https://codecov.io/bash > .codecov
28+
- sed -i -e 's/TRAVIS_.*_VERSION/^TRAVIS_.*_VERSION=/' .codecov
29+
- chmod +x .codecov
30+
- if [[ $TRAVIS_PHP_VERSION == "5.6" ]]; then ./.codecov -X gcov; fi
31+
# - if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]]; then bash <(curl -s https://codecov.io/bash); fi

bin/check-syntax.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
PHP='/usr/bin/env php'
4+
RETURN=0
5+
6+
# check PHP files
7+
for FILE in `find lib tests templates www -name "*.php"`; do
8+
$PHP -l $FILE > /dev/null 2>&1
9+
if [ $? -ne 0 ]; then
10+
echo "Syntax check failed for ${FILE}"
11+
RETURN=`expr ${RETURN} + 1`
12+
fi
13+
done
14+
15+
exit $RETURN

composer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "simplesamlphp/simplesamlphp-module-preprodwarning",
3+
"description": "Display a warning when using a pre-production environment",
4+
"type": "simplesamlphp-module",
5+
"keywords": ["simplesamlphp", "preprodwarning"],
6+
"license": "LGPL-3.0-or-later",
7+
"authors": [
8+
{
9+
"name": "Andreas Åkre Solberg",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"config": {
14+
"preferred-install": {
15+
"simplesamlphp/simplesamlphp": "source",
16+
"*": "dist"
17+
}
18+
},
19+
"autoload": {
20+
"psr-4": {
21+
"SimpleSAML\\Module\\preprodwarning\\": "lib/"
22+
}
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"SimpleSAML\\Test\\Utils\\": "vendor/simplesamlphp/simplesamlphp/tests/Utils"
27+
}
28+
},
29+
"require": {
30+
"php": ">=5.6",
31+
"simplesamlphp/composer-module-installer": "~1.1"
32+
},
33+
"require-dev": {
34+
"phpunit/phpunit": "~5.7",
35+
"simplesamlphp/simplesamlphp": "^1.17",
36+
"webmozart/assert": "^1.4"
37+
},
38+
"support": {
39+
"issues": "https://github.com/tvdijen/simplesamlphp-module-preprodwarning/issues",
40+
"source": "https://github.com/tvdijen/simplesamlphp-module-preprodwarning"
41+
}
42+
}

default-enable

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file indicates that the default state of this module
2+
is enabled. To disable, create a file named disable in the
3+
same directory as this file.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"warning": {
3+
"en": "You are now accessing a pre-production system. This authentication setup is for testing and pre-production verification only. If someone sent you a link that pointed you here, and you are not <i>a tester<\/i> you probably got the wrong link, and should <b>not be here<\/b>."
4+
},
5+
"warning_header": {
6+
"en": "Warning about accessing a pre-production system"
7+
},
8+
"yes": {
9+
"en": "Yes, I know I am accessing a pre-production system"
10+
}
11+
}

dictionaries/warning.translation.json

Lines changed: 110 additions & 0 deletions
Large diffs are not rendered by default.

lib/Auth/Process/Warning.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace SimpleSAML\Module\preprodwarning\Auth\Process;
4+
5+
/**
6+
* Give a warning that the user is accessing a test system, not a production system.
7+
*
8+
* @package SimpleSAMLphp
9+
*/
10+
11+
class Warning extends \SimpleSAML\Auth\ProcessingFilter
12+
{
13+
/**
14+
* Process a authentication response.
15+
*
16+
* This function saves the state, and redirects the user to the page where the user
17+
* can authorize the release of the attributes.
18+
*
19+
* @param array $state The state of the response.
20+
* @return void
21+
*/
22+
public function process(&$state)
23+
{
24+
assert(is_array($state));
25+
26+
if (isset($state['isPassive']) && $state['isPassive'] === true) {
27+
// We have a passive request. Skip the warning
28+
return;
29+
}
30+
31+
// Save state and redirect.
32+
$id = \SimpleSAML\Auth\State::saveState($state, 'warning:request');
33+
$url = \SimpleSAML\Module::getModuleURL('preprodwarning/showwarning.php');
34+
\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]);
35+
}
36+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
#, fuzzy
3+
msgid ""
4+
msgstr ""
5+
"Project-Id-Version: SimpleSAMLphp 1.15\n"
6+
"Report-Msgid-Bugs-To: [email protected]\n"
7+
"POT-Creation-Date: 2016-10-12 09:23+0200\n"
8+
"PO-Revision-Date: 2016-10-14 12:14+0200\n"
9+
"Last-Translator: \n"
10+
"Language: af\n"
11+
"Language-Team: \n"
12+
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=utf-8\n"
15+
"Content-Transfer-Encoding: 8bit\n"
16+
"Generated-By: Babel 2.3.4\n"
17+
18+
msgid "{preprodwarning:warning:warning_header}"
19+
msgstr "Waarskuwing oor toegang na 'n pre-produksie stelsel"
20+
21+
msgid "{preprodwarning:warning:warning}"
22+
msgstr ""
23+
"Jy het nou toegang gekry tot 'n pre-produksie stelsel. Dié verifikasie "
24+
"opstel is vir die toets en pre-produksie verifikasie aleen. Indien iemand"
25+
" vir jou 'n skakel gestuur wat na hier verwys en jy is nie <i> 'n toets "
26+
"persoon nie </i> het jy waarskynlik die verkeerde skakel en moet <b> jy "
27+
"nie hier </b> wees nie."
28+
29+
msgid "{preprodwarning:warning:yes}"
30+
msgstr "Ja, ek weet ek verkry toegang tot 'n pre-produksie stelsel"
31+
32+
msgid ""
33+
"You are now accessing a pre-production system. This authentication setup "
34+
"is for testing and pre-production verification only. If someone sent you "
35+
"a link that pointed you here, and you are not <i>a tester</i> you "
36+
"probably got the wrong link, and should <b>not be here</b>."
37+
msgstr ""
38+
"Jy het nou toegang gekry tot 'n pre-produksie stelsel. Dié verifikasie "
39+
"opstel is vir die toets en pre-produksie verifikasie aleen. Indien iemand"
40+
" vir jou 'n skakel gestuur wat na hier verwys en jy is nie <i> 'n toets "
41+
"persoon nie </i> het jy waarskynlik die verkeerde skakel en moet <b> jy "
42+
"nie hier </b> wees nie."
43+
44+
msgid "Warning about accessing a pre-production system"
45+
msgstr "Waarskuwing oor toegang na 'n pre-produksie stelsel"
46+
47+
msgid "Yes, I know I am accessing a pre-production system"
48+
msgstr "Ja, ek weet ek verkry toegang tot 'n pre-produksie stelsel"
49+

0 commit comments

Comments
 (0)