Skip to content

Commit 44a79b9

Browse files
authored
Merge pull request #7 from simplesamlphp/library
Migrate to cas-lib
2 parents f649ee7 + ae2ce00 commit 44a79b9

File tree

14 files changed

+900
-120
lines changed

14 files changed

+900
-120
lines changed

.github/workflows/php.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
php-version: ['8.1', '8.2', '8.3', '8.4']
22+
php-version: ['8.2', '8.3', '8.4', '8.5']
2323

24-
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.9.2
24+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.10.6
2525
with:
2626
php-version: ${{ matrix.php-version }}
2727

@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232

33-
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.9.2
33+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.10.6
3434
with:
3535
enable_eslinter: false
3636
enable_jsonlinter: true
@@ -45,15 +45,15 @@ jobs:
4545
fail-fast: false
4646
matrix:
4747
operating-system: [ubuntu-latest]
48-
php-versions: ['8.1', '8.2', '8.3', '8.4']
48+
php-versions: ['8.2', '8.3', '8.4', '8.5']
4949

5050
steps:
5151
- name: Setup PHP, with composer and extensions
5252
# https://github.com/shivammathur/setup-php
5353
uses: shivammathur/setup-php@v2
5454
with:
5555
php-version: ${{ matrix.php-versions }}
56-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
56+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, ldap, mbstring, openssl, pcre, spl, xml
5757
tools: composer
5858
ini-values: error_reporting=E_ALL
5959
coverage: pcov
@@ -85,15 +85,15 @@ jobs:
8585
run: composer install --no-progress --prefer-dist --optimize-autoloader
8686

8787
- name: Run unit tests with coverage
88-
if: ${{ matrix.php-versions == '8.4' }}
88+
if: ${{ matrix.php-versions == '8.5' }}
8989
run: vendor/bin/phpunit
9090

9191
- name: Run unit tests (no coverage)
92-
if: ${{ matrix.php-versions != '8.4' }}
92+
if: ${{ matrix.php-versions != '8.5' }}
9393
run: vendor/bin/phpunit --no-coverage
9494

9595
- name: Save coverage data
96-
if: ${{ matrix.php-versions == '8.4' }}
96+
if: ${{ matrix.php-versions == '8.5' }}
9797
uses: actions/upload-artifact@v4
9898
with:
9999
name: coverage-data
@@ -107,15 +107,15 @@ jobs:
107107
fail-fast: true
108108
matrix:
109109
operating-system: [windows-latest]
110-
php-versions: ['8.1', '8.2', '8.3', '8.4']
110+
php-versions: ['8.2', '8.3', '8.4', '8.5']
111111

112112
steps:
113113
- name: Setup PHP, with composer and extensions
114114
# https://github.com/shivammathur/setup-php
115115
uses: shivammathur/setup-php@v2
116116
with:
117117
php-version: ${{ matrix.php-versions }}
118-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml, zip
118+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, ldap, mbstring, openssl, pcre, spl, xml, zip
119119
tools: composer
120120
ini-values: error_reporting=E_ALL
121121
coverage: none
@@ -161,7 +161,7 @@ jobs:
161161
uses: shivammathur/setup-php@v2
162162
with:
163163
# Should be the higest supported version, so we can use the newest tools
164-
php-version: '8.4'
164+
php-version: '8.5'
165165
tools: composer, composer-require-checker, composer-unused, phpcs
166166
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
167167

@@ -193,7 +193,7 @@ jobs:
193193
run: composer-unused
194194

195195
- name: PHP Code Sniffer
196-
run: phpcs
196+
run: vendor/bin/phpcs
197197

198198
- name: PHPStan
199199
run: |
@@ -214,7 +214,7 @@ jobs:
214214
uses: shivammathur/setup-php@v2
215215
with:
216216
# Should be the lowest supported version
217-
php-version: '8.1'
217+
php-version: '8.2'
218218
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
219219
tools: composer
220220
coverage: none

composer.json

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
},
1818
"allow-plugins": {
1919
"composer/package-versions-deprecated": true,
20-
"simplesamlphp/composer-module-installer": true,
2120
"dealerdirect/phpcodesniffer-composer-installer": true,
2221
"phpstan/extension-installer": true,
22+
"simplesamlphp/composer-module-installer": true,
2323
"simplesamlphp/composer-xmlprovider-installer": true
2424
}
2525
},
@@ -34,17 +34,47 @@
3434
}
3535
},
3636
"require": {
37-
"php": "^8.1",
38-
"simplesamlphp/composer-module-installer": "^1.3.4",
39-
"simplesamlphp/simplesamlphp": "~2.4.0",
37+
"php": "^8.2",
38+
"ext-pcre": "*",
39+
"ext-dom": "*",
40+
41+
"simplesamlphp/assert": "^1.9",
42+
"simplesamlphp/composer-module-installer": "^1.4",
43+
"simplesamlphp/simplesamlphp": "dev-simplesamlphp-2.5 as v2.5.x-dev",
4044
"simplesamlphp/simplesamlphp-module-ldap": "~1.2",
41-
"symfony/http-foundation": "^6.4"
45+
"simplesamlphp/xml-cas-module-slate": "~1.1.0",
46+
"simplesamlphp/xml-cas": "^v2.2.0",
47+
"simplesamlphp/xml-common": "~2.4",
48+
"symfony/http-foundation": "~7.4",
49+
"symfony/http-client": "~7.4",
50+
"symfony/http-client-contracts": "^3.5"
4251
},
4352
"require-dev": {
44-
"simplesamlphp/simplesamlphp-test-framework": "^1.9.2"
53+
"simplesamlphp/simplesamlphp-test-framework": "^1.10",
54+
"phpunit/phpunit": "^11",
55+
"icanhazstring/composer-unused": "^0.9.5",
56+
"squizlabs/php_codesniffer": "^4.0.0",
57+
"phpstan/phpstan": "^2.1.33",
58+
"maglnet/composer-require-checker": "^4"
4559
},
4660
"support": {
4761
"issues": "https://github.com/simplesamlphp/simplesamlphp-module-cas/issues",
4862
"source": "https://github.com/simplesamlphp/simplesamlphp-module-cas"
63+
},
64+
"scripts": {
65+
"pre-commit": [
66+
"vendor/bin/phpcs -p",
67+
"vendor/bin/composer-require-checker check --config-file=tools/composer-require-checker.json composer.json",
68+
"vendor/bin/phpstan analyze -c phpstan.neon",
69+
"vendor/bin/phpstan analyze -c phpstan-dev.neon",
70+
"vendor/bin/composer-unused",
71+
"vendor/bin/phpunit --no-coverage --testdox"
72+
],
73+
"tests": [
74+
"vendor/bin/phpunit --no-coverage"
75+
],
76+
"propose-fix": [
77+
"vendor/bin/phpcs --report=diff"
78+
]
4979
}
5080
}

docs/cas.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ the only difference is this is authentication module and not a script.
55

66
## Setting up the CAS authentication module
77

8-
Adding a authentication source
8+
Adding an authentication source
99

1010
Example authsource.php:
1111

@@ -31,7 +31,7 @@ Example authsource.php:
3131

3232
## Querying Attributes
3333

34-
CAS V3 (since 2017) supports querying attributes. Those have to be published
34+
CAS v3 (since 2017) supports querying attributes. Those have to be published
3535
for the service you're calling. Here the service publishes `sn`, `firstName`
3636
and `mail`.
3737

@@ -51,6 +51,35 @@ Or you might have to call serviceValidate for Protocol 3 via **/p3/**:
5151
]
5252
```
5353

54+
### Optional: Enabling Slate extensions
55+
56+
Some deployments include vendor‑specific fields (for example `slate:*`) in CAS responses.
57+
You can opt in to Slate support:
58+
59+
```php
60+
'cas' => [
61+
// ...
62+
'serviceValidate' => 'https://cas.example.com/p3/serviceValidate',
63+
// Enable Slate support (optional)
64+
'slate.enabled' => true,
65+
66+
// Optional XPath-based attribute mappings
67+
'attributes' => [
68+
// Standard CAS attributes
69+
'uid' => 'cas:user',
70+
'mail' => 'cas:attributes/cas:mail',
71+
72+
// Slate namespaced attributes inside cas:attributes
73+
'slate_person' => 'cas:attributes/slate:person',
74+
'slate_round' => 'cas:attributes/slate:round',
75+
'slate_ref' => 'cas:attributes/slate:ref',
76+
77+
// Some deployments also place vendor elements at the top level
78+
'slate_person_top' => '/cas:serviceResponse/cas:authenticationSuccess/slate:person',
79+
],
80+
],
81+
```
82+
5483
which would return something like
5584

5685
```xml
@@ -76,22 +105,22 @@ for each value:
76105
```php
77106
'cas' => [
78107
'attributes' => [
79-
'uid' => '/cas:serviceResponse/cas:authenticationSuccess/cas:user',
80-
'sn' => '/cas:serviceResponse/cas:authenticationSuccess/cas:attributes/cas:sn',
81-
'givenName' => '/cas:serviceResponse/cas:authenticationSuccess/cas:attributes/cas:firstname',
82-
'mail' => '/cas:serviceResponse/cas:authenticationSuccess/cas:attributes/cas:mail',
108+
'uid' => 'cas:user',
109+
'sn' => 'cas:attributes/cas:sn',
110+
'givenName' => 'cas:attributes/cas:firstname',
111+
'mail' => 'cas:attributes/cas:mail',
83112
],
84113
],
85114
```
86115

87116
and even some custom attributes if they're set:
88117

89118
```php
90-
'customabc' => '/cas:serviceResponse/cas:authenticationSuccess/custom:abc',
119+
'customabc' => 'custom:abc',
91120
```
92121

93122
You'll probably want to avoid querying LDAP for attributes:
94-
set `ldap` to a `null`:
123+
set `ldap` to `null`:
95124

96125
```php
97126
'example-cas' => [

phpstan-dev.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
parameters:
2-
level: 8
2+
level: 9
33
paths:
44
- tests

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
parameters:
2-
level: 7
2+
level: 8
33
paths:
44
- src

phpunit.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="tests/bootstrap.php"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
5+
colors="true"
6+
cacheDirectory=".phpunit.cache">
37
<coverage>
48
<report>
59
<clover outputFile="build/logs/clover.xml"/>

0 commit comments

Comments
 (0)