Skip to content

Commit

Permalink
8.2.6
Browse files Browse the repository at this point in the history
- Expand the existing user lookup to prevent unwanted user duplication (#134)
  • Loading branch information
pookmish authored Jan 9, 2023
2 parents c166d9a + 60d53c9 commit 049905d
Show file tree
Hide file tree
Showing 22 changed files with 251 additions and 171 deletions.
65 changes: 0 additions & 65 deletions .circleci/config.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .github/auto-label.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"rules": {
"patch": ["*.info.yml"],
"frontend": ["*.js", "*.scss", "*.css", "*.twig", ".theme"],
"backend": ["*.php", "*.module"],
"ci": [".circleci", "blt", ".github"],
"tests": ["tests"]
}
}
28 changes: 28 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler/blob/master/README.md

name: PR Labeler
on:
pull_request:
types: [opened, synchronize]
jobs:
pr-labeler:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: codelytv/pr-size-labeler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_max_size: '100'
s_max_size: '500'
m_max_size: '1000'
l_max_size: '3000'
fail_if_xl: 'false'
message_if_xl: ''
- uses: banyan/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 29 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
# .github/workflows/release.yml
name: Release

on:
pull_request:
types: closed

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Tag
uses: K-Phoen/semver-release-action@master
with:
release_branch: master
tag_format: "%major%.%minor%.%patch%"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# .github/workflows/release.yml
name: Release

on:
pull_request:
types: [closed]

jobs:
build:
runs-on: ubuntu-latest
if: github.event.pull_request.merged
steps:
- name: Tag
id: tag
uses: K-Phoen/semver-release-action@master
with:
release_branch: main
tag_format: "%major%.%minor%.%patch%"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
with:
ref: 'main'
fetch-depth: 0
- name: Back to Dev
if: ${{ steps.tag.outputs.tag }}
run: |
composer global require su-sws/stanford-caravan:dev-8.x-2.x
~/.composer/vendor/bin/sws-caravan back-to-dev ${{ steps.tag.outputs.tag }} $GITHUB_WORKSPACE main
111 changes: 81 additions & 30 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
name: PHPUnit Coverage Tests
runs-on: ubuntu-latest
container:
image: pookmish/drupal8ci:php8
image: pookmish/drupal8ci:latest
services:
mysql:
image: mysql:5.7
Expand All @@ -27,33 +27,84 @@ jobs:
run: |
composer global require su-sws/stanford-caravan:dev-8.x-2.x
~/.composer/vendor/bin/sws-caravan phpunit /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --with-coverage
acceptance:
name: Codeception Acceptance Tests
runs-on: ubuntu-latest
env:
DRUPAL_DATABASE_NAME: drupal
DRUPAL_DATABASE_USERNAME: drupal
DRUPAL_DATABASE_PASSWORD: drupal
DRUPAL_DATABASE_HOST: mysql
container:
image: pookmish/drupal8ci:php8
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_ROOT_PASSWORD: drupal
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
- name: Save Test Results
uses: actions/upload-artifact@v3
if: failure()
with:
path: project
- name: Run tests
run: |
composer global require su-sws/stanford-caravan:dev-8.x-2.x
~/.composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=acceptance
name: unit-tests-results
path: /var/www/html/artifacts
# acceptance:
# name: Codeception Acceptance Tests
# runs-on: ubuntu-latest
# env:
# DRUPAL_DATABASE_NAME: drupal
# DRUPAL_DATABASE_USERNAME: drupal
# DRUPAL_DATABASE_PASSWORD: drupal
# DRUPAL_DATABASE_HOST: mysql
# container:
# image: pookmish/drupal8ci:latest
# options: '--network-alias drupal8ci'
# services:
# mysql:
# image: mysql:5.7
# env:
# MYSQL_DATABASE: drupal
# MYSQL_USER: drupal
# MYSQL_PASSWORD: drupal
# MYSQL_ROOT_PASSWORD: drupal
# ports:
# - 33306:3306
# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
# steps:
# - uses: actions/checkout@v3
# with:
# path: project
# - name: Run tests
# run: |
# composer global require su-sws/stanford-caravan:dev-8.x-2.x
# ~/.composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=acceptance
# - name: Save Test Results
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: acceptance-tests-results
# path: /var/www/html/artifacts
# functional:
# name: Codeception Functional Tests
# runs-on: ubuntu-latest
# env:
# DRUPAL_DATABASE_NAME: drupal
# DRUPAL_DATABASE_USERNAME: drupal
# DRUPAL_DATABASE_PASSWORD: drupal
# DRUPAL_DATABASE_HOST: mysql
# container:
# image: pookmish/drupal8ci:latest
# options: '--network-alias=drupal8ci'
# services:
# selenium:
# image: selenium/standalone-chrome
# options: '--shm-size="2g"'
# mysql:
# image: mysql:5.7
# env:
# MYSQL_DATABASE: drupal
# MYSQL_USER: drupal
# MYSQL_PASSWORD: drupal
# MYSQL_ROOT_PASSWORD: drupal
# ports:
# - 33306:3306
# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
# steps:
# - uses: actions/checkout@v3
# with:
# path: project
# - name: Run tests
# run: |
# composer global require su-sws/stanford-caravan:dev-8.x-2.x
# ~/.composer/vendor/bin/sws-caravan codeception /var/www/html --extension-dir=$GITHUB_WORKSPACE/project --suites=functional
# - name: Save Test Results
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: functional-tests-results
# path: /var/www/html/artifacts
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Stanford SSP

8.2.6
--------------------------------------------------------------------------------
_Release Date: 2023-01-09_

- Expand the existing user lookup to prevent unwanted user duplication (#134)

8.2.5
--------------------------------------------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
"license": "GPL-2.0-or-later",
"minimum-stability": "dev",
"require": {
"php": ">=7.0.0",
"composer/installers": "^1.2",
"drupal/simplesamlphp_auth": "^3.1",
"ext-json": "*"
"php": ">=8.1",
"ext-json": "*",
"drupal/core": "^9.4 || ^10.0",
"drupal/simplesamlphp_auth": "^3.1"
},
"require-dev": {
"su-sws/drupal-patches": "^8.0"
},
"prefer-stable": true,
"config": {
"sort-packages": true
},
Expand Down
2 changes: 2 additions & 0 deletions config/install/stanford_ssp.settings.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
saml_attribute: eduPersonEntitlement
use_workgroup_api: false
hide_local_login: true
local_login_fieldset_label: 'Drupal Login'
local_login_fieldset_open: false
workgroup_api_cert: ''
workgroup_api_key: ''
restriction: all
Expand Down
6 changes: 6 additions & 0 deletions config/schema/stanford_ssp.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ stanford_ssp.settings:
hide_local_login:
type: boolean
label: 'Hide core local login form on user page'
local_login_fieldset_label:
type: string
label: 'Local login fieldset label'
local_login_fieldset_open:
type: boolean
label: Default open state for local login fieldset
use_workgroup_api:
type: boolean
label: 'Use workgroup mapping instead of saml attributes'
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/StanfordSspCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(AuthmapInterface $auth_map, FormBuilderInterface $fo
* @command saml:entitlement-role
* @aliases ssp-ser,saml-entitlement-role
*/
public function entitlementRole($entitlement, $role_id) {
public function entitlementRole(string $entitlement, string $role_id) {
$role_id = Html::escape($role_id);
$existing_roles = user_roles(TRUE);
if (!isset($existing_roles[$role_id])) {
Expand Down Expand Up @@ -120,7 +120,7 @@ public function entitlementRole($entitlement, $role_id) {
* @command saml:add-user
* @aliases ssp-au,saml-add-user
*/
public function addUser($sunetid, array $options = [
public function addUser(string $sunetid, array $options = [
'name' => NULL,
'email' => NULL,
'roles' => NULL,
Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/StanfordSSPEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function responseHandler(ResponseEvent $event) {
$url = Url::fromRoute('user.login', [], ['query' => ['destination' => $destination]]);
if ($this->samlConfig->get('activate') && $this->stanfordConfig->get('hide_local_login')) {
global $base_url;
$destination = "$base_url/$destination";;
$destination = "$base_url/$destination";
$url = Url::fromRoute('simplesamlphp_auth.saml_login', [], ['query' => ['ReturnTo' => $destination]]);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Form/RoleSyncForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
],
];

foreach ($form_state->get('mappings', []) as $role_mapping) {
foreach ($form_state->get('mappings') as $role_mapping) {
$form['user_info']['role_population'][$role_mapping] = $this->buildRoleRow($role_mapping);
}

Expand Down Expand Up @@ -209,7 +209,7 @@ protected function getRoleHeaders() {
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
protected function buildRoleRow($role_mapping_string) {
protected function buildRoleRow(string $role_mapping_string): array {
[$role_id, $comparison] = explode(':', $role_mapping_string, 2);

$exploded_comparison = explode(',', $comparison, 3);
Expand Down Expand Up @@ -287,7 +287,7 @@ public function addMappingCallback(array $form, FormStateInterface $form_state)
* Current form state.
*/
public function removeMappingCallback(array $form, FormStateInterface $form_state) {
$mappings = $form_state->get('mappings', []);
$mappings = $form_state->get('mappings');
unset($mappings[$form_state->getTriggeringElement()['#mapping']]);
$form_state->set('mappings', $mappings);
$form_state->setRebuild();
Expand Down
1 change: 1 addition & 0 deletions src/Service/StanfordSSPAuthManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function getAttribute($attribute) {
return $this->getAuthname() . '@stanford.edu';
}
}
return FALSE;
}

}
Loading

0 comments on commit 049905d

Please sign in to comment.