Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit 59e1260

Browse files
authored
Merge pull request #19 from simplesamlphp/feature/xsd-types
Feature/xsd types
2 parents 237e7f1 + ddffb50 commit 59e1260

File tree

1,103 files changed

+6111
-4623
lines changed

Some content is hidden

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

1,103 files changed

+6111
-4623
lines changed

.gitattributes

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ codecov.yml export-ignore
55
.editorconfig export-ignore
66
.gitattributes export-ignore
77
.gitignore export-ignore
8-
psalm.xml export-ignore
9-
psalm-dev.xml export-ignore
8+
phpstan-baseline.neon export-ignore
9+
phpstan-baseline-dev.neon export-ignore
10+
phpstan.neon export-ignore
11+
phpstan-dev.neon export-ignore
1012
phpcs.xml export-ignore
1113
phpunit.xml export-ignore
1214
.php_cs.dist export-ignore

.github/workflows/php.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ 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

2424
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.10.6
2525
with:
@@ -45,7 +45,7 @@ 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
@@ -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@v5
9898
with:
9999
name: coverage-data
@@ -107,7 +107,7 @@ 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
@@ -151,6 +151,7 @@ jobs:
151151

152152
quality:
153153
name: Quality control
154+
needs: [unit-tests-linux]
154155
runs-on: [ubuntu-latest]
155156

156157
steps:
@@ -160,7 +161,7 @@ jobs:
160161
uses: shivammathur/setup-php@v2
161162
with:
162163
# Should be the higest supported version, so we can use the newest tools
163-
php-version: '8.4'
164+
php-version: '8.5'
164165
tools: composer, composer-require-checker, composer-unused, phpcs
165166
extensions: ctype, date, dom, filter, pcre, soap, spl, xml
166167
coverage: none
@@ -193,7 +194,7 @@ jobs:
193194
run: composer-unused
194195

195196
- name: PHP Code Sniffer
196-
run: phpcs
197+
run: vendor/bin/phpcs
197198

198199
- name: PHPStan
199200
run: |
@@ -205,14 +206,16 @@ jobs:
205206
206207
security:
207208
name: Security checks
209+
needs: [unit-tests-linux]
208210
runs-on: [ubuntu-latest]
211+
209212
steps:
210213
- name: Setup PHP, with composer and extensions
211214
# https://github.com/shivammathur/setup-php
212215
uses: shivammathur/setup-php@v2
213216
with:
214217
# Should be the lowest supported version
215-
php-version: '8.1'
218+
php-version: '8.2'
216219
extensions: ctype, date, dom, filter, pcre, soap, spl, xml
217220
tools: composer
218221
coverage: none

codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ comment:
1717
github_checks:
1818
annotations: false
1919
ignore:
20-
- 'src/XML/element.registry.php'
20+
- 'classes/element.registry.php'

composer.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8.1",
13+
"php": "^8.2",
1414
"ext-dom": "*",
1515
"ext-spl": "*",
1616

17-
"simplesamlphp/assert": "~1.8.1",
18-
"simplesamlphp/saml2": "^5.0",
19-
"simplesamlphp/xml-security": "~1.13.0",
20-
"simplesamlphp/xml-common": "~1.25.0"
17+
"simplesamlphp/assert": "~1.9",
18+
"simplesamlphp/saml2": "~6.0",
19+
"simplesamlphp/xml-common": "~2.4",
20+
"simplesamlphp/xml-security": "~2.0",
21+
"simplesamlphp/xml-soap": "~2.0"
2122
},
2223
"require-dev": {
23-
"simplesamlphp/simplesamlphp-test-framework": "~1.9.2"
24+
"simplesamlphp/simplesamlphp-test-framework": "~1.10"
2425
},
2526
"autoload": {
2627
"psr-4": {

resources/schemas/ws-authorization.xsd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
4545
<xs:any namespace='##other' processContents='lax' minOccurs='1' maxOccurs='1' />
4646
</xs:choice>
4747
<xs:attribute name='Name' type='xs:anyURI' use='required' />
48-
<xs:attribute name='Scope' type='xs:anyURI' use='optional' />
49-
<xs:anyAttribute namespace='##other' processContents='lax' />
48+
<xs:attribute name='Scope' type='xs:anyURI' use='optional' />
49+
<xs:anyAttribute namespace='##other' processContents='lax' />
5050
</xs:complexType>
5151

5252
<!-- Section 9.3 -->
@@ -57,16 +57,16 @@ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
5757
<xs:element name="Description" type="tns:DescriptionType" minOccurs="0" maxOccurs="1" />
5858
<xs:element name="DisplayValue" type="tns:DisplayValueType" minOccurs="0" maxOccurs="1" />
5959
<xs:choice minOccurs='0'>
60-
<xs:element name='Value' type='xs:string' minOccurs='1' maxOccurs='1' />
60+
<xs:element name='Value' type='xs:string' minOccurs='1' maxOccurs='1' />
6161
<xs:element name='EncryptedValue' type='tns:EncryptedValueType' minOccurs='1' maxOccurs='1' />
6262
<xs:element name='StructuredValue' type='tns:StructuredValueType' minOccurs='1' maxOccurs='1' />
6363
<xs:element name='ConstrainedValue' type='tns:ConstrainedValueType' minOccurs='1' maxOccurs='1' />
64-
<xs:any namespace='##other' processContents='lax' minOccurs='1' maxOccurs='1' />
65-
</xs:choice>
64+
<xs:any namespace='##other' processContents='lax' minOccurs='1' maxOccurs='1' />
65+
</xs:choice>
6666
</xs:sequence>
67-
<xs:attribute name='Uri' type='xs:anyURI' use='required' />
68-
<xs:attribute name='Optional' type='xs:boolean' use='optional' />
69-
<xs:anyAttribute namespace='##other' processContents='lax' />
67+
<xs:attribute name='Uri' type='xs:anyURI' use='required' />
68+
<xs:attribute name='Optional' type='xs:boolean' use='optional' />
69+
<xs:anyAttribute namespace='##other' processContents='lax' />
7070
</xs:complexType>
7171

7272
<xs:complexType name="DisplayNameType">

src/Assert/Assert.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
/**
1010
* @package simplesamlphp/ws-security
11+
*
12+
* @method static void validWSUDateTime(mixed $value, string $message = '', string $exception = '')
13+
* @method static void allWSUDateTime(mixed $value, string $message = '', string $exception = '')
14+
* @method static void nullOrValueWSUDateTime(mixed $value, string $message = '', string $exception = '')
1115
*/
1216
class Assert extends BaseAssert
1317
{
18+
use WSUDateTimeTrait;
1419
}

src/Assert/WSUDateTimeTrait.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\WSSecurity\Assert;
6+
7+
use SimpleSAML\Assert\AssertionFailedException;
8+
use SimpleSAML\WSSecurity\Exception\ProtocolViolationException;
9+
10+
/**
11+
* @package simplesamlphp/ws-security
12+
*/
13+
trait WSUDateTimeTrait
14+
{
15+
/**
16+
* @param string $value
17+
* @param string $message
18+
*/
19+
protected static function validWSUDateTime(string $value, string $message = ''): void
20+
{
21+
parent::validDateTime($value);
22+
23+
try {
24+
parent::endsWith(
25+
$value,
26+
'Z',
27+
'%s is not a DateTime expressed in the UTC timezone using the \'Z\' timezone identifier.',
28+
);
29+
} catch (AssertionFailedException $e) {
30+
throw new ProtocolViolationException($e->getMessage());
31+
}
32+
}
33+
}

src/Constants.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Constants extends \SimpleSAML\SAML2\Constants
1616
* The namespace for WS-Addressing protocol.
1717
*/
1818
public const NS_ADDR_200408 = 'http://schemas.xmlsoap.org/ws/2004/08/addressing';
19+
1920
public const NS_ADDR_200508 = 'http://www.w3.org/2005/08/addressing';
2021

2122
/**
@@ -37,6 +38,7 @@ class Constants extends \SimpleSAML\SAML2\Constants
3738
* The namespace for WS-Trust protocol.
3839
*/
3940
public const NS_TRUST_200502 = 'http://schemas.xmlsoap.org/ws/2005/02/trust';
41+
4042
public const NS_TRUST_200512 = 'http://docs.oasis-open.org/ws-sx/ws-trust/200512/';
4143

4244
/**
@@ -48,6 +50,7 @@ class Constants extends \SimpleSAML\SAML2\Constants
4850
* The namespace for the Web Service Security Policy protocol.
4951
*/
5052
public const NS_SEC_POLICY_11 = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy';
53+
5154
public const NS_SEC_POLICY_12 = 'http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702';
5255

5356
/**
@@ -79,15 +82,25 @@ class Constants extends \SimpleSAML\SAML2\Constants
7982
* The schema-defined wsa fault codes
8083
*/
8184
public const WSA_FAULT_INVALID_ADDRESSING_HEADER = 'InvalidAddressingHeader';
85+
8286
public const WSA_FAULT_INVALID_ADDRESS = 'InvalidAddress';
87+
8388
public const WSA_FAULT_INVALID_EPR = 'InvalidEPR';
89+
8490
public const WSA_FAULT_INVALID_CARDINALITY = 'InvalidCardinality';
91+
8592
public const WSA_FAULT_MISSING_ADDRESS_IN_EPR = 'MissingAddressInEPR';
93+
8694
public const WSA_FAULT_DUPLICATE_MESSAGEID = 'DupicateMessageID';
95+
8796
public const WSA_FAULT_ACTION_MISMATCH = 'ActionMismatch';
97+
8898
public const WSA_FAULT_MESSAGE_ADDRESSING_HEADER_REQUIRED = 'MessageAddressingHeaderRequired';
99+
89100
public const WSA_FAULT_DESTINATION_UNREACHABLE = 'DestinationUnreachable';
101+
90102
public const WSA_FAULT_ACTION_NOT_SUPPORTED = 'ActionNotSupported';
103+
91104
public const WSA_FAULT_ENDPOINT_UNAVAILABLE = 'EndpointUnavailable';
92105

93106
public const FAULT_CODES = [
@@ -107,6 +120,7 @@ class Constants extends \SimpleSAML\SAML2\Constants
107120
/**
108121
*/
109122
public const WST_REFID_PIN = 'http://docs.oasis-open.org/ws-sx/ws-trust/200802/challenge/PIN';
123+
110124
public const WST_REFID_OTP = 'http://docs.oasis-open.org/ws-sx/ws-trust/200802/challenge/OTP';
111125

112126
/**

src/Utils/XPath.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ class XPath extends \SimpleSAML\XMLSecurity\Utils\XPath
1919
* Get a DOMXPath object that can be used to search for WS Security elements.
2020
*
2121
* @param \DOMNode $node The document to associate to the DOMXPath object.
22+
* @param bool $autoregister Whether to auto-register all namespaces used in the document
2223
*
2324
* @return \DOMXPath A DOMXPath object ready to use in the given document, with several
2425
* ws-related namespaces already registered.
2526
*/
26-
public static function getXPath(DOMNode $node): DOMXPath
27+
public static function getXPath(DOMNode $node, bool $autoregister = false): DOMXPath
2728
{
28-
$xp = parent::getXPath($node);
29+
$xp = parent::getXPath($node, $autoregister);
2930

3031
$xp->registerNamespace('wsa', C::NS_ADDR_200508);
3132
$xp->registerNamespace('wsa', C::NS_ADDR_200408);

0 commit comments

Comments
 (0)