Skip to content

Commit db2c1ad

Browse files
authored
Merge pull request #9 from ioigoume/phpstan-failing-check
phpstan-failing-check
2 parents 55b2985 + bfd094f commit db2c1ad

9 files changed

Lines changed: 762 additions & 57 deletions

File tree

composer.json

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,43 @@
3636
"require": {
3737
"php": "^8.2",
3838
"ext-pcre": "*",
39+
"ext-dom": "*",
3940

4041
"simplesamlphp/assert": "^1.9",
4142
"simplesamlphp/composer-module-installer": "^1.4",
42-
"simplesamlphp/simplesamlphp": "~2.4",
43+
"simplesamlphp/simplesamlphp": "dev-simplesamlphp-2.5 as v2.5.x-dev",
4344
"simplesamlphp/simplesamlphp-module-ldap": "~1.2",
44-
"simplesamlphp/xml-cas": "^2.0",
45-
"simplesamlphp/xml-common": "^2.0",
46-
"symfony/http-foundation": "^6.4 || ^7.3"
45+
"simplesamlphp/xml-cas-module-slate": "~1.1.0",
46+
"simplesamlphp/xml-cas": "^v2.2.0",
47+
"simplesamlphp/xml-common": "~2.4.0",
48+
"symfony/http-foundation": "~7.4.0"
4749
},
4850
"require-dev": {
49-
"simplesamlphp/simplesamlphp-test-framework": "^1.10"
51+
"simplesamlphp/simplesamlphp-test-framework": "^1.10",
52+
"phpunit/phpunit": "^11",
53+
"icanhazstring/composer-unused": "^0.9.5",
54+
"squizlabs/php_codesniffer": "^4.0.0",
55+
"phpstan/phpstan": "^2.1.33",
56+
"maglnet/composer-require-checker": "^4"
5057
},
5158
"support": {
5259
"issues": "https://github.com/simplesamlphp/simplesamlphp-module-cas/issues",
5360
"source": "https://github.com/simplesamlphp/simplesamlphp-module-cas"
61+
},
62+
"scripts": {
63+
"pre-commit": [
64+
"vendor/bin/phpcs -p",
65+
"vendor/bin/composer-require-checker check --config-file=tools/composer-require-checker.json composer.json",
66+
"vendor/bin/phpstan analyze -c phpstan.neon",
67+
"vendor/bin/phpstan analyze -c phpstan-dev.neon",
68+
"vendor/bin/composer-unused",
69+
"vendor/bin/phpunit --no-coverage --testdox"
70+
],
71+
"tests": [
72+
"vendor/bin/phpunit --no-coverage"
73+
],
74+
"propose-fix": [
75+
"vendor/bin/phpcs --report=diff"
76+
]
5477
}
5578
}

docs/cas.md

Lines changed: 38 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,36 @@ Or you might have to call serviceValidate for Protocol 3 via **/p3/**:
5151
]
5252
```
5353

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

5686
```xml
@@ -76,22 +106,22 @@ for each value:
76106
```php
77107
'cas' => [
78108
'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',
109+
'uid' => 'cas:user',
110+
'sn' => 'cas:attributes/cas:sn',
111+
'givenName' => 'cas:attributes/cas:firstname',
112+
'mail' => 'cas:attributes/cas:mail',
83113
],
84114
],
85115
```
86116

87117
and even some custom attributes if they're set:
88118

89119
```php
90-
'customabc' => '/cas:serviceResponse/cas:authenticationSuccess/custom:abc',
120+
'customabc' => 'custom:abc',
91121
```
92122

93123
You'll probably want to avoid querying LDAP for attributes:
94-
set `ldap` to a `null`:
124+
set `ldap` to `null`:
95125

96126
```php
97127
'example-cas' => [

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)