Skip to content

Commit 51dad60

Browse files
authored
Merge pull request #1 from OS2web/sprint-2
OS2Forms Sprint 2
2 parents 6c01bdc + 31cffd6 commit 51dad60

File tree

5 files changed

+86
-14
lines changed

5 files changed

+86
-14
lines changed

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
language: php
2+
3+
sudo: false
4+
5+
php:
6+
- 7.2
7+
8+
install:
9+
- composer global require drush/drush:8.x-dev drupal/coder mglaman/drupal-check friendsoftwig/twigcs
10+
- export PATH="$HOME/.config/composer/vendor/bin:$PATH"
11+
- phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer
12+
- phpenv rehash
13+
- nvm install node
14+
- nvm use node
15+
- npm install --global yarn
16+
- cd ../ && drush dl drupal-8 --drupal-project-rename=drupal
17+
- cd drupal
18+
- DRUPAL_ROOT=$(pwd)
19+
- export REPOSITORIES='"repositories":\ \['
20+
- export REPOSITORIES_REPLACE='"repositories":\[\{"type":"path","url":"..\/os2web_simplesaml","options":\{"symlink":false\}\},'
21+
- export REQUIRE='"require":\ {'
22+
- export REQUIRE_REPLACE='"require":{"os2web\/os2web_simplesaml":"\*",'
23+
- sed -i "s/$REPOSITORIES/$REPOSITORIES_REPLACE/g" composer.json
24+
- sed -i "s/$REQUIRE/$REQUIRE_REPLACE/g" composer.json
25+
- composer update
26+
- PROJECT_PATH=$DRUPAL_ROOT/modules/contrib/os2web_simplesaml
27+
- cd $DRUPAL_ROOT/core
28+
- yarn install
29+
- npm install --global eslint-config-drupal-bundle stylelint
30+
31+
script:
32+
- phpcs --standard=Drupal --ignore=*.md $PROJECT_PATH
33+
- twigcs $PROJECT_PATH
34+
- cd $DRUPAL_ROOT/core
35+
- eslint $PROJECT_PATH
36+
- stylelint --aei $PROJECT_PATH/**/*.css
37+
- drupal-check $PROJECT_PATH

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
#Module purpose
1+
# OS2Web SimpleSAML Drupal module [![Build Status](https://travis-ci.org/OS2web/os2web_simplesaml.svg?branch=8.x)](https://travis-ci.org/OS2web/os2web_simplesaml)
2+
3+
## Module purpose
24

35
The aim of this module is to enhance integration with **simplesamlphp_auth** module, by force triggering **SimpleSAML auth page** redirect when certain criteria are met.
46

5-
#How does it work
7+
## How does it work
68

79
Module performs checks on a single redirect triggering page. In order for it to work the cache for anonymous user for that page response is programmatically killed.
810

@@ -16,7 +18,7 @@ To improve the performance, the redirect decision is stored in cookies to a limi
1618

1719
Additionally module provides a special field for user entity, called **SimpleSAML UID** that allows to create a **SimpleSAML mapping** with the existing Drupal users.
1820

19-
#Additional setings
21+
## Additional setings
2022

2123
- **IP's whitelist**
2224
Comma separate values of IP or IP ranges that will be redirected to SimpleSAML auth page.
@@ -25,3 +27,35 @@ A certain page that triggers the redirect to SimpleSAML auth page if the criteri
2527
- **Cookies TTL**
2628
Stores the redirect response in the cookies for a certain period of time (_defaults: 5min_).
2729

30+
## Install
31+
32+
Module is available to download via composer.
33+
```
34+
composer require os2web/os2web_simplesaml
35+
drush en os2web_simplesaml
36+
```
37+
38+
## Update
39+
Updating process for OS2Web SimpleSAML module is similar to usual Drupal 8 module.
40+
Use Composer's built-in command for listing packages that have updates available:
41+
42+
```
43+
composer outdated os2web/os2web_simplesaml
44+
```
45+
46+
## Automated testing and code quality
47+
See [OS2Web testing and CI information](https://github.com/OS2Web/docs#testing-and-ci)
48+
49+
## Contribution
50+
51+
Project is opened for new features and os course bugfixes.
52+
If you have any suggestion or you found a bug in project, you are very welcome
53+
to create an issue in github repository issue tracker.
54+
For issue description there is expected that you will provide clear and
55+
sufficient information about your feature request or bug report.
56+
57+
### Code review policy
58+
See [OS2Web code review policy](https://github.com/OS2Web/docs#code-review)
59+
60+
### Git name convention
61+
See [OS2Web git name convention](https://github.com/OS2Web/docs#git-guideline)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Enhances integration with simplesamlphp_auth module, by force triggering SimpleSAML auth page redirect when certain criteria are met",
55
"minimum-stability": "dev",
66
"prefer-stable": true,
7-
"license": "GPL-2.0+",
7+
"license": "EUPL-1.2",
88
"require": {
99
"drupal/simplesamlphp_auth": "^3.1"
1010
}

os2web_simplesaml.info.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ type: module
33
description: Enhances integration with simplesamlphp_auth module, by force triggering SimpleSAML auth page redirect when certain criteria are met.
44
package: OS2Web
55
core: 8.x
6+
core_version_requirement: ^8 || ^9
67
configure: simplesamlphp_auth.admin_settings_local
78

89
dependencies:

os2web_simplesaml.module

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,32 @@ use Drupal\Core\Url;
1616
function os2web_simplesaml_form_simplesamlphp_auth_local_settings_form_alter(&$form, FormStateInterface $form_state, $form_id) {
1717
$config = \Drupal::config('os2web_simplesaml.settings');
1818

19-
$form['os2web_simplesaml_additional_settings'] = array(
19+
$form['os2web_simplesaml_additional_settings'] = [
2020
'#type' => 'fieldset',
2121
'#title' => t('OS2Web SimpleSAML additional settings'),
22-
);
23-
$form['os2web_simplesaml_additional_settings']['redirect_ips'] = array(
22+
];
23+
$form['os2web_simplesaml_additional_settings']['redirect_ips'] = [
2424
'#type' => 'textfield',
2525
'#title' => t("Redirect IP's to SimpleSAML login"),
2626
'#default_value' => $config->get('redirect_ips'),
2727
'#description' => t('Comma separated. Ex. 192.168.1.1,192.168.2.1'),
28-
);
29-
$form['os2web_simplesaml_additional_settings']['redirect_trigger_path'] = array(
28+
];
29+
$form['os2web_simplesaml_additional_settings']['redirect_trigger_path'] = [
3030
'#type' => 'textfield',
3131
'#title' => t('Redirect triggering path'),
3232
'#default_value' => $config->get('redirect_trigger_path'),
3333
'#description' => t('The path that will trigger the redirect. NB! The caching for that path will be programmatically disabled.'),
3434
'#required' => TRUE,
35-
);
36-
$form['os2web_simplesaml_additional_settings']['redirect_cookies_ttl'] = array(
35+
];
36+
$form['os2web_simplesaml_additional_settings']['redirect_cookies_ttl'] = [
3737
'#type' => 'number',
3838
'#min' => 0,
3939
'#step' => 10,
4040
'#title' => t('Redirect cookies time to live (TTL)'),
4141
'#default_value' => $config->get('redirect_cookies_ttl'),
4242
'#description' => t('Number of seconds, after which the positive or negative redirect decision will expire. Setting long time improves the performance, but IP rules change will take longer to become active for all users.'),
4343
'#required' => TRUE,
44-
);
44+
];
4545

4646
$form['#validate'][] = 'os2web_simplesaml_form_validate';
4747
$form['#submit'][] = 'os2web_simplesaml_form_submit';
@@ -143,7 +143,7 @@ function os2web_simplesaml_form_user_register_form_alter(&$form, FormStateInterf
143143
*
144144
* @see os2web_simplesaml_user_form_submit()
145145
*/
146-
function os2web_simplesaml_user_form_includes(&$form) {
146+
function os2web_simplesaml_user_form_includes(array &$form) {
147147
// Getting SimpleSAML existing authname to use as an example.
148148
$query = \Drupal::database()->select('authmap', 'am')
149149
->fields('am', ['authname'])
@@ -155,7 +155,7 @@ function os2web_simplesaml_user_form_includes(&$form) {
155155
'#type' => 'textfield',
156156
'#title' => t('SimpleSAML UID'),
157157
'#access' => \Drupal::currentUser()->hasPermission('change saml authentication setting'),
158-
'#description' => $simplesamlExample ? t('Example of the existing SimpleSAML entry from authmap table: <b>@simplesaml</b>', array('@simplesaml' => $simplesamlExample)) : t('Provide a string serves the UID of the user.')
158+
'#description' => $simplesamlExample ? t('Example of the existing SimpleSAML entry from authmap table: <b>@simplesaml</b>', ['@simplesaml' => $simplesamlExample]) : t('Provide a string serves the UID of the user.'),
159159
];
160160

161161
// Adding custom validation.

0 commit comments

Comments
 (0)