Skip to content

Commit 3abce1d

Browse files
committed
Migrate to xsd-types
1 parent 7244337 commit 3abce1d

File tree

378 files changed

+7649
-6861
lines changed

Some content is hidden

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

378 files changed

+7649
-6861
lines changed

.github/workflows/interoperability.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
operating-system: [ubuntu-latest]
26-
php-versions: ['8.2']
26+
php-versions: ['8.4']
2727

2828
steps:
2929
- name: Setup PHP, with composer and extensions
@@ -80,8 +80,14 @@ jobs:
8080
run: |
8181
mkdir -p /tmp/metadata
8282
wget https://mds.edugain.org/edugain-v2.xml -O /tmp/metadata/edugain.xml
83-
wget https://technical.edugain.org/mds-v2.cer -O /tmp/metadataedugain-pub.crt
83+
wget https://technical.edugain.org/mds-v2.cer -O /tmp/metadata/edugain-pub.crt
8484
85+
- name: Download eduID metadata & public key
86+
if: steps.cache-metadata.outputs.cache-hit != 'true'
87+
run: |
88+
mkdir -p /tmp/metadata
89+
wget https://metadata.eduid.cz/entities/eduid -O /tmp/metadata/eduid.xml
90+
wget https://www.eduid.cz/docs/eduid/metadata/metadata.eduid.cz.crt.pem -O /tmp/metadata/eduid.crt
8591
8692
- name: Download GRNET metadata
8793
if: steps.cache-metadata.outputs.cache-hit != 'true'

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"psr/http-message": "^2.0",
3333
"psr/log": "^2.0 || ^3.0",
3434
"simplesamlphp/assert": "~1.8.0",
35-
"simplesamlphp/xml-common": "~1.24.0",
36-
"simplesamlphp/xml-security": "~1.13.0",
37-
"simplesamlphp/xml-soap": "~1.7.0"
35+
"simplesamlphp/xml-common": "dev-feature/xsd-types",
36+
"simplesamlphp/xml-security": "dev-feature/xsd-types",
37+
"simplesamlphp/xml-soap": "dev-feature/xsd-types"
3838
},
3939
"require-dev": {
4040
"ext-intl": "*",

phpstan-baseline.neon

Lines changed: 0 additions & 211 deletions
This file was deleted.

phpstan.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@ parameters:
22
level: 1
33
paths:
44
- src
5-
includes:
6-
- phpstan-baseline.neon

src/Assert/Assert.php

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,39 @@
1111
*
1212
* @package simplesamlphp/saml2
1313
*
14-
* @method static void validDateTime(mixed $value, string $message = '', string $exception = '')
14+
* @method static void validCIDR(mixed $value, string $message = '', string $exception = '')
15+
* @method static void validDomain(mixed $value, string $message = '', string $exception = '')
1516
* @method static void validEntityID(mixed $value, string $message = '', string $exception = '')
16-
* @method static void validURI(mixed $value, string $message = '', string $exception = '')
17+
* @method static void validGeolocation(mixed $value, string $message = '', string $exception = '')
1718
* @method static void validRelayState(mixed $value, string $message = '', string $exception = '')
18-
* @method static void nullOrValidDateTime(mixed $value, string $message = '', string $exception = '')
19+
* @method static void validSAMLAnyURI(mixed $value, string $message = '', string $exception = '')
20+
* @method static void validSAMLDateTime(mixed $value, string $message = '', string $exception = '')
21+
* @method static void validSAMLString(mixed $value, string $message = '', string $exception = '')
22+
* @method static void nullOrValidCIDR(mixed $value, string $message = '', string $exception = '')
23+
* @method static void nullOrValidDomain(mixed $value, string $message = '', string $exception = '')
1924
* @method static void nullOrValidEntityID(mixed $value, string $message = '', string $exception = '')
25+
* @method static void nullOrValidGeolocation(mixed $value, string $message = '', string $exception = '')
2026
* @method static void nullOrValidRelayState(mixed $value, string $message = '', string $exception = '')
21-
* @method static void nullOrValidURI(mixed $value, string $message = '', string $exception = '')
22-
* @method static void allValidDateTime(mixed $value, string $message = '', string $exception = '')
27+
* @method static void nullOrValidSAMLAnyURI(mixed $value, string $message = '', string $exception = '')
28+
* @method static void nullOrValidSAMLDateTime(mixed $value, string $message = '', string $exception = '')
29+
* @method static void nullOrValidSAMLString(mixed $value, string $message = '', string $exception = '')
30+
* @method static void allValidCIDR(mixed $value, string $message = '', string $exception = '')
31+
* @method static void allValidDomain(mixed $value, string $message = '', string $exception = '')
2332
* @method static void allValidEntityID(mixed $value, string $message = '', string $exception = '')
33+
* @method static void allValidGeolocation(mixed $value, string $message = '', string $exception = '')
2434
* @method static void allValidRelayState(mixed $value, string $message = '', string $exception = '')
25-
* @method static void allValidURI(mixed $value, string $message = '', string $exception = '')
35+
* @method static void allValidSAMLAnyURI(mixed $value, string $message = '', string $exception = '')
36+
* @method static void allValidSAMLDateTime(mixed $value, string $message = '', string $exception = '')
37+
* @method static void allValidSAMLString(mixed $value, string $message = '', string $exception = '')
2638
*/
2739
class Assert extends BaseAssert
2840
{
29-
use CustomAssertionTrait;
41+
use CIDRTrait;
42+
use DomainTrait;
43+
use EntityIDTrait;
44+
use GeolocationTrait;
3045
use RelayStateTrait;
46+
use SAMLAnyURITrait;
47+
use SAMLDateTimeTrait;
48+
use SAMLStringTrait;
3149
}

src/Assert/CIDRTrait.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\SAML2\Assert;
6+
7+
use SimpleSAML\Assert\AssertionFailedException;
8+
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
9+
10+
/**
11+
* @package simplesamlphp/saml2
12+
*/
13+
trait CIDRTrait
14+
{
15+
private static string $cidr_regex = '/^
16+
(?:
17+
(?:
18+
(
19+
(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.
20+
(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.
21+
(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.
22+
(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])
23+
)
24+
[\/](3[0-2]|[1-2]?[0-9])$
25+
)
26+
|
27+
(
28+
(?:[0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|
29+
(?:[0-9a-fA-F]{1,4}:){1,7}:|
30+
(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|
31+
(?:[0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|
32+
(?:[0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|
33+
(?:[0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|
34+
(?:[0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|
35+
[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|
36+
:(?:(:[0-9a-fA-F]{1,4}){1,7}|:)|
37+
::
38+
)
39+
[\/](12[0-8]|1[0-1][0-9]|[1-9]?[0-9])$
40+
)
41+
$/Dxi';
42+
43+
44+
/**
45+
* @param string $value
46+
* @param string $message
47+
*/
48+
protected static function validCIDR(string $value, string $message = ''): void
49+
{
50+
try {
51+
parent::regex(
52+
$value,
53+
self::$cidr_regex,
54+
$message ?: '%s is not a valid RFC4632 CIDR-block',
55+
);
56+
} catch (AssertionFailedException $e) {
57+
throw new ProtocolViolationException($e->getMessage());
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)