Skip to content

Commit

Permalink
Merge pull request #57 from simplesamlphp/psr2
Browse files Browse the repository at this point in the history
Implement namespaces and PSR2 compliance
  • Loading branch information
DRvanR committed Dec 22, 2015
2 parents 4e360dd + 0f229ac commit 80bc962
Show file tree
Hide file tree
Showing 208 changed files with 3,913 additions and 4,554 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build/
/cache.properties
/composer.lock
/composer.phar
/vendor/
build
cache.properties
composer.phar
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,29 @@ So let us know what you would like to see in a PHP SAML2 library.

Note that the **HTTP Artifact Binding and SOAP client do not work** outside of SimpleSAMLphp.

Which version to pick?
----------------------
It is **strongly recommended** to use the latest stable version of the `2.x` range as that is the currently supported version.

The `1.x` range should be considered deprecated. This means it will receive fixes and, if required,
functionality may be backported. This version should only be relied on if migrating the project to
the `2.x` range cannot be done yet.

The `0.x` range is discontinued and will no longer receive any fixes or features. The `0.x` range however
is functionally the same as the `1.x` range. Should your project or a dependency of your project rely on a `0.x` version
[composer inline aliasing](https://getcomposer.org/doc/articles/aliases.md#require-inline-alias) will help, by using
`composer require "simplesamlphp/saml2:1.7.0 as 0.8"` allows to install 1.7.0 as if 0.8 were installed.

Usage
-----

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

```bash
composer require simplesamlphp/saml2
composer require simplesamlphp/saml2:^2.0
```

* Provide the required external dependencies by extending and implementing the ```SAML2_Compat_AbstractContainer```
* Provide the required external dependencies by extending and implementing the ```SAML2\Compat\AbstractContainer```
then injecting it in the ContainerSingleton (see example below).

* **Make sure you've read the security section below**
Expand All @@ -45,24 +58,24 @@ Example:

// Implement the Container interface (out of scope for example)
require 'container.php';
SAML2_Compat_ContainerSingleton::setContainer($container);
SAML2\Compat\ContainerSingleton::setContainer($container);

// Set up an AuthnRequest
$request = new SAML2_AuthnRequest();
$request = new SAML2\AuthnRequest();
$request->setId($container->generateId());
$request->setIssuer('https://sp.example.edu');
$request->setDestination('https://idp.example.edu');

// Send it off using the HTTP-Redirect binding
$binding = new SAML2_HTTPRedirect();
$binding = new SAML2\HTTPRedirect();
$binding->send($request);
```

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

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"ext-openssl": "*",
"ext-dom": "*",

"robrichards/xmlseclibs": "^1.3",
"robrichards/xmlseclibs": "^2.0",
"psr/log": "~1.0"
},
"require-dev": {
Expand All @@ -27,12 +27,12 @@
},
"autoload": {
"psr-0": {
"SAML2_": "src/"
"SAML2\\": "src/"
}
},
"autoload-dev": {
"psr-0": {
"SAML2_": "tests/"
"SAML2\\": "tests/"
}
}
}
Loading

0 comments on commit 80bc962

Please sign in to comment.