Skip to content

Commit bfc3652

Browse files
committed
Merge master into release-5.x
1 parent 8419f77 commit bfc3652

File tree

519 files changed

+3572
-2873
lines changed

Some content is hidden

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

519 files changed

+3572
-2873
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
# Should be the higest supported version, so we can use the newest tools
5454
php-version: '8.3'
55-
tools: composer, composer-require-checker, composer-unused, phpcs
55+
tools: composer, composer-require-checker, composer-unused:0.9.2, phpcs
5656
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
5757
coverage: none
5858

README-DEV.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Test with the PHPCS configuration in `tools/phpcs/ruleset.xml`
1111
Use PHPUnit for Unit Testing.
1212
Test with the 2 known users: [SimpleSAMLphp][1] and [OpenConext-engineblock][2].
1313

14-
## Using Tests in Development
14+
### Using Tests in Development
1515

16-
In order to run the unittests, use `vendor/bin/phpunit -c tools/phpunit`
16+
In order to run the unittests, use `vendor/bin/phpunit`
1717

1818
## Contributing
1919

@@ -26,5 +26,5 @@ Also when introducing a BC breaking change, please update the [UPGRADING.md](UPG
2626

2727
[1]: https://www.simplesamlphp.org
2828
[2]: https://www.openconext.org
29-
[3]: https://github.com/simplesamlphp/saml2/wiki/SAML2-v1.0-Technical-Design
30-
[4]: https://github.com/simplesamlphp/saml2/wiki/Background
29+
[3]: https://github.com/simplesamlphp/saml2/wiki/Background
30+
[4]: https://github.com/simplesamlphp/saml2/wiki/SAML2-v1.0-Technical-Design

README.md

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# SimpleSAMLphp SAML2 library
22

3-
[![Build Status](https://travis-ci.org/simplesamlphp/saml2.png?branch=feature/fix-build)](https://travis-ci.org/simplesamlphp/saml2) [![Coverage Status](https://img.shields.io/coveralls/simplesamlphp/saml2.svg)](https://coveralls.io/r/simplesamlphp/saml2)
3+
![CI](https://github.com/simplesamlphp/saml2/actions/workflows/php.yml/badge.svg)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/simplesamlphp/saml2/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/simplesamlphp/saml2/?branch=master)
5+
[![Coverage Status](https://codecov.io/gh/simplesamlphp/saml2/branch/master/graph/badge.svg)](https://codecov.io/gh/simplesamlphp/saml2)
6+
[![Type coverage](https://shepherd.dev/github/simplesamlphp/saml2/coverage.svg)](https://shepherd.dev/github/simplesamlphp/saml2)
7+
[![Psalm Level](https://shepherd.dev/github/simplesamlphp/saml2/level.svg)](https://shepherd.dev/github/simplesamlphp/saml2)
48

5-
A PHP library for SAML2 related functionality. Extracted from [SimpleSAMLphp](https://www.simplesamlphp.org),
6-
used by [OpenConext](https://www.openconext.org).
7-
This library started as a collaboration between [UNINETT](https://www.uninett.no) and [SURFnet](https://www.surfnet.nl) but everyone is invited to contribute.
9+
A PHP library for SAML2 related functionality.
10+
11+
It is used by several products, most notably [SimpleSAMLphp](https://www.simplesamlphp.org) and [OpenConext](https://www.openconext.org).
812

913
## Before you use it
1014

@@ -17,23 +21,25 @@ Note that the **HTTP Artifact Binding and SOAP client do not work** outside of S
1721

1822
## Which version to pick?
1923

20-
The latest released version (`5.x` range) is the _only supported version_.
24+
The latest released version (`4.x` range) is the _preferred version_.
25+
The `3.x branch` is our LTS branch and will be supported as long as supported releases of [SimpleSAMLphp](https://www.simplesamlphp.org) are using this branch.
2126

22-
All other branches (`4.x` and earlier) are no longer supported and will not receive any maintenance or
27+
All other branches (`3.x` and earlier) are no longer supported and will not receive any maintenance or
2328
(security) fixes. Do not use these versions.
2429

25-
Also be sure to check the [UPGRADING.md](UPGRADING.md) file if you are upgrading from an older version to `>= 5.x`. Here
30+
We conform to [Semantic Versioning](https://semver.org/).
31+
Be sure to check the [UPGRADING.md](UPGRADING.md) file if you are upgrading from an older version. Here
2632
you will find instructions on how to deal with BC breaking changes between versions.
2733

2834
## Usage
2935

3036
* Install with [Composer](https://getcomposer.org/doc/00-intro.md), run the following command in your project:
3137

3238
```bash
33-
composer require simplesamlphp/saml2:^5.0
39+
composer require simplesamlphp/saml2:^4.0
3440
```
3541

36-
* Provide the required external dependencies by extending and implementing the ```SAML2\Compat\AbstractContainer```
42+
* Provide the required external dependencies by extending and implementing the ```\SimpleSAML\SAML2\Compat\AbstractContainer```
3743
then injecting it in the ContainerSingleton (see example below).
3844

3945
* **Make sure you've read the security section below**.
@@ -43,37 +49,32 @@ composer require simplesamlphp/saml2:^5.0
4349
Example:
4450

4551
```php
46-
// Use Composers autoloading
47-
require 'vendor/autoload.php';
48-
49-
// Implement the Container interface (out of scope for example)
50-
require 'container.php';
51-
SimpleSAML\SAML2\Compat\ContainerSingleton::setContainer($container);
52-
53-
// Set up an AuthnRequest
54-
$id = $container->generateId();
55-
$issuer = new SimpleSAML\SAML2\XML\saml\Issuer('https://sp.example.edu');
56-
$destination = 'https://idp.example.edu';
57-
$request = new SimpleSAML\SAML2\XML\samlp\AuthnRequest(
58-
id: $id,
59-
issuer: $issuer,
60-
destination: $destination,
61-
);
62-
63-
64-
// Send it off using the HTTP-Redirect binding
65-
$binding = new SimpleSAML\SAML2\HTTPRedirect();
66-
$binding->send($request);
52+
// Use Composers autoloading
53+
require 'vendor/autoload.php';
54+
55+
// Implement the Container interface (out of scope for example)
56+
require 'container.php';
57+
\SimpleSAML\SAML2\Compat\ContainerSingleton::setContainer($container);
58+
59+
// Create Issuer
60+
$issuer = new \SimpleSAML\SAML2\XML\saml\Issuer('https://sp.example.edu');
61+
62+
// Instantiate XML Random utils
63+
$randomUtils = new \SimpleSAML\XML\Utils\Random();
64+
65+
// Set up an AuthnRequest
66+
$request = new \SimpleSAML\SAML2\XML\samlp\AuthnRequest(
67+
$issuer,
68+
$randomUtils->generateId(),
69+
null,
70+
'https://idp.example.edu'
71+
);
72+
73+
// Send it off using the HTTP-Redirect binding
74+
$binding = new \SimpleSAML\SAML2\HTTPRedirect();
75+
$binding->send($request);
6776
```
6877

69-
## Security
70-
71-
* Should you need to create a DOMDocument instance, use the `SimpleSAML\XML\DOMDocumentFactory` to create DOMDocuments from
72-
either a string (`SimpleSAML\XML\DOMDocumentFactory::fromString($theXmlAsString)`), a file (`SimpleSAML\XML\DOMDocumentFactory::fromFile($pathToTheFile)`)
73-
or just a new instance (`SimpleSAML\XML\DOMDocumentFactory::create()`). This in order to protect yourself against the
74-
[XXE Processing Vulnerability](https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing), as well as
75-
[XML Entity Expansion](https://phpsecurity.readthedocs.org/en/latest/Injection-Attacks.html#defenses-against-xml-entity-expansion) attacks
76-
7778
## License
7879

7980
This library is licensed under the LGPL license version 2.1.

UPGRADING.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22

33
## 4.x to 5.0
44

5-
### Namespaces have changed
5+
### Namespace migration
66

7-
All classes have been renamed from `SAML2\MyClass` to `SimpleSAML\SAML2\MyClass`.
7+
All the classes had their namespace changed from SAML2 to SimpleSAML\SAML2.
88

9-
### Bindings now implement PSR-7
9+
### NameIDPolicy BC breaking change
1010

11-
The bindings now take a PSR-7 request and will respond with a PSR-7 response.
11+
The NameIDPolicy can no longer be represented as an array, but has to be handled using
12+
the newly added NameIDPolicy-class.
13+
14+
### StatusResponse BC breaking change
15+
16+
The API of the StatusResponse-class has been slightly changed; getStatus/setStatus will now handle Status-objects
17+
instead of the previous array
1218

1319
## 4.0 to 4.1
1420

@@ -30,9 +36,9 @@ This problem was fixed in [#120](https://github.com/simplesamlphp/saml2/pull/120
3036
If you are using the assertion processor as a stand-alone component, then you will have to update your code to reflect this
3137
change, see: [e6c01fa](https://github.com/simplesamlphp/saml2/commit/e6c01fa9b0e815682e24916f03a84d245480c4a0).
3238

33-
### NameID's and Issuers
39+
### NameIDs and Issuers
3440

35-
In pre 4.0 releases we allowed both objects and arrays to be used for Issuers and nameID's. We know only support objects.
41+
In pre 4.0 releases we allowed both objects and arrays to be used for Issuers and nameIDs. We know only support objects.
3642
If in your code you use something like this:
3743

3844
```php

codecov.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
coverage:
4+
status:
5+
project:
6+
default:
7+
target: 0%
8+
threshold: 2%
9+
patch: false
10+
comment:
11+
layout: "diff"
12+
behavior: once
13+
require_changes: true
14+
require_base: false
15+
require_head: true
16+
branches: null
17+
github_checks:
18+
annotations: false

phpcs.xml

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,79 +7,42 @@
77
<!-- Use this to exclude paths. You can have multiple patterns -->
88
<!--<exclude-pattern>*/tests/*</exclude-pattern>-->
99
<!--<exclude-pattern>*/other/*</exclude-pattern>-->
10+
1011
<file>src</file>
1112
<file>tests</file>
1213

1314
<!-- This is the rule we inherit from. If you want to exlude some specific rules, see the docs on how to do that -->
1415
<rule ref="PSR12"/>
16+
<rule ref="vendor/simplesamlphp/simplesamlphp-test-framework/phpcs-simplesamlphp.xml"/>
1517

16-
<!-- Ignore files with side effects that we cannot fix -->
17-
<rule ref="PSR1.Files.SideEffects">
18-
<exclude-pattern>tests/SAML2/XML/md/RoleDescriptorTest.php</exclude-pattern>
18+
<rule ref="Generic.PHP.RequireStrictTypes">
19+
<exclude-pattern>tests/bin/**</exclude-pattern>
1920
</rule>
2021

21-
<rule ref="PSR1.Methods.CamelCapsMethodName">
22-
<exclude-pattern>tests/SAML2/Assertion/ProcessorTest.php</exclude-pattern>
23-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php</exclude-pattern>
24-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php</exclude-pattern>
25-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php</exclude-pattern>
26-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php</exclude-pattern>
27-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php</exclude-pattern>
28-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php</exclude-pattern>
29-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php</exclude-pattern>
30-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php</exclude-pattern>
31-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php</exclude-pattern>
32-
<exclude-pattern>tests/SAML2/Certificate/KeyTest.php</exclude-pattern> <exclude-pattern>tests/SAML2/Certificate/KeyLoaderTest.php</exclude-pattern>
33-
<exclude-pattern>tests/SAML2/Certificate/PrivateKeyLoaderTest.php</exclude-pattern>
34-
<exclude-pattern>tests/SAML2/Certificate/PrivateKeyTest.php</exclude-pattern>
35-
<exclude-pattern>tests/SAML2/Certificate/X509Test.php</exclude-pattern>
36-
<exclude-pattern>tests/SAML2/Utilities/ArrayCollectionTest.php</exclude-pattern>
37-
<exclude-pattern>tests/SAML2/Utilities/FileTest.php</exclude-pattern>
22+
<rule ref="PSR1.Files.SideEffects">
23+
<exclude-pattern>src/_autoload.php</exclude-pattern>
3824
</rule>
3925

4026
<rule ref="Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase">
41-
<exclude-pattern>src/SAML2/Assertion.php</exclude-pattern>
42-
<exclude-pattern>src/SAML2/LogoutRequest.php</exclude-pattern>
43-
<exclude-pattern>src/SAML2/EncryptedAssertion.php</exclude-pattern>
27+
<exclude-pattern>**/Assertion.php</exclude-pattern>
28+
<exclude-pattern>**/LogoutRequest.php</exclude-pattern>
29+
<exclude-pattern>**/EncryptedAssertion.php</exclude-pattern>
4430
</rule>
4531

4632
<!-- Lines can be a little bit longer before they break the build -->
4733
<rule ref="Generic.Files.LineLength">
48-
<properties>
49-
<property name="lineLimit" value="120"/>
50-
<property name="absoluteLineLimit" value="130"/>
51-
</properties>
52-
<exclude-pattern>tests/SAML2/AssertionTest.php</exclude-pattern>
53-
<exclude-pattern>tests/SAML2/Assertion/ProcessorTest.php</exclude-pattern>
34+
<exclude-pattern>**/BindingTest.php</exclude-pattern>
35+
<exclude-pattern>**/HTTPPostTest.php</exclude-pattern>
36+
<exclude-pattern>**/HTTPRedirectTest.php</exclude-pattern>
37+
<exclude-pattern>**/SOAPTest.php</exclude-pattern>
5438
<exclude-pattern>tests/SAML2/Assertion/Validation/AssertionValidatorTest.php</exclude-pattern>
55-
<exclude-pattern>tests/SAML2/AttributeQueryTest.php</exclude-pattern>
56-
<exclude-pattern>tests/SAML2/AuthnRequestTest.php</exclude-pattern>
57-
<exclude-pattern>tests/SAML2/BindingTest.php</exclude-pattern>
58-
<exclude-pattern>tests/SAML2/Certificate/KeyLoaderTest.php</exclude-pattern>
59-
<exclude-pattern>tests/SAML2/CertificatesMock.php</exclude-pattern>
60-
<exclude-pattern>tests/SAML2/HTTPPostTest.php</exclude-pattern>
61-
<exclude-pattern>tests/SAML2/HTTPRedirectTest.php</exclude-pattern>
62-
<exclude-pattern>tests/SAML2/LogoutRequestTest.php</exclude-pattern>
63-
<exclude-pattern>tests/SAML2/ResponseTest.php</exclude-pattern>
64-
<exclude-pattern>tests/SAML2/SOAPTest.php</exclude-pattern>
65-
<exclude-pattern>tests/SAML2/Utilities/ArrayCollectionTest.php</exclude-pattern>
66-
<exclude-pattern>tests/SAML2/UtilsTest.php</exclude-pattern>
67-
<exclude-pattern>tests/SAML2/XML/md/AffiliationDescriptorTest.php</exclude-pattern>
68-
<exclude-pattern>tests/SAML2/XML/md/ContactPersonTest.php</exclude-pattern>
69-
<exclude-pattern>tests/SAML2/XML/md/EndpointTypeTest.php</exclude-pattern>
70-
<exclude-pattern>tests/SAML2/XML/md/EntityDescriptorTest.php</exclude-pattern>
71-
<exclude-pattern>tests/SAML2/XML/mdattr/EntityAttributesTest.php</exclude-pattern>
72-
<exclude-pattern>tests/SAML2/XML/mdui/LogoTest.php</exclude-pattern>
7339
<exclude-pattern>tests/SAML2/XML/saml/AssertionTest.php</exclude-pattern>
7440
<exclude-pattern>tests/SAML2/XML/saml/AttributeValueTest.php</exclude-pattern>
7541
<exclude-pattern>tests/SAML2/XML/saml/AuthnContextTest.php</exclude-pattern>
7642
<exclude-pattern>tests/SAML2/XML/saml/EncryptedAssertionTest.php</exclude-pattern>
7743
<exclude-pattern>tests/SAML2/XML/saml/EncryptedIDTest.php</exclude-pattern>
78-
<exclude-pattern>tests/SAML2/XML/saml/IssuerXMLShowAllTest.php</exclude-pattern>
79-
<exclude-pattern>tests/SAML2/XML/saml/NameIDTest.php</exclude-pattern>
8044
<exclude-pattern>tests/SAML2/XML/samlp/RequestedAuthnContextTest.php</exclude-pattern>
8145
<exclude-pattern>tests/SAML2/XML/samlp/StatusDetailTest.php</exclude-pattern>
8246
<exclude-pattern>tests/SAML2/XML/shibmd/KeyAuthorityTest.php</exclude-pattern>
83-
<exclude-pattern>tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php</exclude-pattern>
8447
</rule>
8548
</ruleset>

phpstan-baseline-dev.neon

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ parameters:
3030
count: 3
3131
path: tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
3232

33-
-
34-
message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:andReturnNull\\(\\)\\.$#"
35-
count: 2
36-
path: tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
37-
3833
-
3934
message: "#^Parameter \\#1 \\$response of class SimpleSAML\\\\SAML2\\\\Assertion\\\\Validation\\\\ConstraintValidator\\\\SubjectConfirmationResponseToMatches constructor expects SimpleSAML\\\\SAML2\\\\XML\\\\samlp\\\\Response, Mockery\\\\MockInterface given\\.$#"
4035
count: 5
@@ -56,45 +51,20 @@ parameters:
5651
path: tests/SAML2/Certificate/KeyCollectionTest.php
5752

5853
-
59-
message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:atMost\\(\\)\\.$#"
60-
count: 2
61-
path: tests/SAML2/Certificate/KeyLoaderTest.php
62-
63-
-
64-
message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#"
65-
count: 1
54+
message: "#^Call to an undefined method Mockery\\\\Expectation\\:\\:shouldReceive\\(\\)\\.$#"
55+
count: 3
6656
path: tests/SAML2/Certificate/KeyLoaderTest.php
6757

6858
-
6959
message: "#^Parameter \\#1 \\$config of method SimpleSAML\\\\SAML2\\\\Certificate\\\\KeyLoader\\:\\:loadKeysFromConfiguration\\(\\) expects SimpleSAML\\\\SAML2\\\\Configuration\\\\CertificateProvider, Mockery\\\\MockInterface given\\.$#"
7060
count: 3
7161
path: tests/SAML2/Certificate/KeyLoaderTest.php
7262

73-
-
74-
message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#"
75-
count: 8
76-
path: tests/SAML2/Response/SignatureValidationTest.php
77-
78-
-
79-
message: "#^Call to method shouldReceive\\(\\) on an unknown class alias\\:SimpleSAML\\\\SAML2\\\\Assertion\\\\ProcessorBuilder\\.$#"
80-
count: 1
81-
path: tests/SAML2/Response/SignatureValidationTest.php
82-
83-
-
84-
message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#"
85-
count: 2
86-
path: tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
87-
8863
-
8964
message: "#^Parameter \\#1 \\$response of method SimpleSAML\\\\SAML2\\\\Response\\\\Validation\\\\ConstraintValidator\\\\DestinationMatches\\:\\:validate\\(\\) expects SimpleSAML\\\\SAML2\\\\XML\\\\samlp\\\\Response, Mockery\\\\MockInterface given\\.$#"
9065
count: 2
9166
path: tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
9267

93-
-
94-
message: "#^Call to an undefined method Mockery\\\\ExpectationInterface\\|Mockery\\\\HigherOrderMessage\\:\\:once\\(\\)\\.$#"
95-
count: 3
96-
path: tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
97-
9868
-
9969
message: "#^Parameter \\#1 \\$response of method SimpleSAML\\\\SAML2\\\\Response\\\\Validation\\\\ConstraintValidator\\\\IsSuccessful\\:\\:validate\\(\\) expects SimpleSAML\\\\SAML2\\\\XML\\\\samlp\\\\Response, Mockery\\\\MockInterface given\\.$#"
10070
count: 2

0 commit comments

Comments
 (0)