Skip to content

Commit 1aee066

Browse files
committed
It was updated php-saml 2.X instead 3.5.0
1 parent f57561f commit 1aee066

13 files changed

Lines changed: 1044 additions & 867 deletions

onelogin-saml-sso/php/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function saml_slo() {
170170
$sessionIndex = null;
171171
$nameIdFormat = null;
172172
$samlNameIdNameQualifier = null;
173-
$samlNameIdSPNameQualifier = null;
173+
$samlNameIdSPNameQualifier = null;
174174

175175
if (isset($_COOKIE[SAML_NAMEID_COOKIE])) {
176176
$nameId = sanitize_text_field($_COOKIE[SAML_NAMEID_COOKIE]);

onelogin-saml-sso/php/lib/Saml2/Auth.php

Lines changed: 134 additions & 81 deletions
Large diffs are not rendered by default.

onelogin-saml-sso/php/lib/Saml2/AuthnRequest.php

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,70 @@
11
<?php
2+
/**
3+
* This file is part of php-saml.
4+
*
5+
* (c) OneLogin Inc
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*
10+
* @package OneLogin
11+
* @author OneLogin Inc <saml-info@onelogin.com>
12+
* @license MIT https://github.com/onelogin/php-saml/blob/master/LICENSE
13+
* @link https://github.com/onelogin/php-saml
14+
*/
15+
16+
namespace OneLogin\Saml2;
217

318
/**
419
* SAML 2 Authentication Request
5-
*
620
*/
7-
class OneLogin_Saml2_AuthnRequest
21+
class AuthnRequest
822
{
9-
1023
/**
1124
* Object that represents the setting info
12-
* @var OneLogin_Saml2_Settings
25+
*
26+
* @var Settings
1327
*/
1428
protected $_settings;
1529

1630
/**
1731
* SAML AuthNRequest string
32+
*
1833
* @var string
1934
*/
2035
private $_authnRequest;
2136

2237
/**
2338
* SAML AuthNRequest ID.
39+
*
2440
* @var string
2541
*/
2642
private $_id;
2743

2844
/**
2945
* Constructs the AuthnRequest object.
3046
*
31-
* @param OneLogin_Saml2_Settings $settings Settings
32-
* @param bool $forceAuthn When true the AuthNReuqest will set the ForceAuthn='true'
33-
* @param bool $isPassive When true the AuthNReuqest will set the Ispassive='true'
34-
* @param bool $setNameIdPolicy When true the AuthNReuqest will set a nameIdPolicy
47+
* @param Settings $settings SAML Toolkit Settings
48+
* @param bool $forceAuthn When true the AuthNReuqest will set the ForceAuthn='true'
49+
* @param bool $isPassive When true the AuthNReuqest will set the Ispassive='true'
50+
* @param bool $setNameIdPolicy When true the AuthNReuqest will set a nameIdPolicy
3551
* @param string $nameIdValueReq Indicates to the IdP the subject that should be authenticated
3652
*/
37-
public function __construct(OneLogin_Saml2_Settings $settings, $forceAuthn = false, $isPassive = false, $setNameIdPolicy = true, $nameIdValueReq = null)
53+
public function __construct(\OneLogin\Saml2\Settings $settings, $forceAuthn = false, $isPassive = false, $setNameIdPolicy = true, $nameIdValueReq = null)
3854
{
3955
$this->_settings = $settings;
4056

4157
$spData = $this->_settings->getSPData();
4258
$security = $this->_settings->getSecurityData();
4359

44-
$id = OneLogin_Saml2_Utils::generateUniqueID();
45-
$issueInstant = OneLogin_Saml2_Utils::parseTime2SAML(time());
60+
$id = Utils::generateUniqueID();
61+
$issueInstant = Utils::parseTime2SAML(time());
4662

4763
$subjectStr = "";
4864
if (isset($nameIdValueReq)) {
4965
$subjectStr = <<<SUBJECT
5066
51-
<saml:Subject>
67+
<saml:Subject>
5268
<saml:NameID Format="{$spData['NameIDFormat']}">{$nameIdValueReq}</saml:NameID>
5369
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"></saml:SubjectConfirmation>
5470
</saml:Subject>
@@ -59,7 +75,7 @@ public function __construct(OneLogin_Saml2_Settings $settings, $forceAuthn = fal
5975
if ($setNameIdPolicy) {
6076
$nameIDPolicyFormat = $spData['NameIDFormat'];
6177
if (isset($security['wantNameIdEncrypted']) && $security['wantNameIdEncrypted']) {
62-
$nameIDPolicyFormat = OneLogin_Saml2_Constants::NAMEID_ENCRYPTED;
78+
$nameIDPolicyFormat = Constants::NAMEID_ENCRYPTED;
6379
}
6480

6581
$nameIdPolicyStr = <<<NAMEIDPOLICY
@@ -141,7 +157,7 @@ public function __construct(OneLogin_Saml2_Settings $settings, $forceAuthn = fal
141157
ID="$id"
142158
Version="2.0"
143159
{$providerNameStr}{$forceAuthnStr}{$isPassiveStr}
144-
IssueInstant="$issueInstant"
160+
IssueInstant="{$issueInstant}"
145161
Destination="{$destination}"
146162
ProtocolBinding="{$spData['assertionConsumerService']['binding']}"
147163
AssertionConsumerServiceURL="{$acsUrl}">

onelogin-saml-sso/php/lib/Saml2/Constants.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
<?php
2-
2+
/**
3+
* This file is part of php-saml.
4+
*
5+
* (c) OneLogin Inc
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*
10+
* @package OneLogin
11+
* @author OneLogin Inc <saml-info@onelogin.com>
12+
* @license MIT https://github.com/onelogin/php-saml/blob/master/LICENSE
13+
* @link https://github.com/onelogin/php-saml
14+
*/
15+
16+
namespace OneLogin\Saml2;
17+
318
/**
419
* Constants of OneLogin PHP Toolkit
520
*
621
* Defines all required constants
722
*/
8-
class OneLogin_Saml2_Constants
23+
class Constants
924
{
1025
// Value added to the current time in time condition validations
1126
const ALLOWED_CLOCK_DRIFT = 180; // 3 min in seconds

onelogin-saml-sso/php/lib/Saml2/Error.php

Lines changed: 27 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
<?php
2-
2+
/**
3+
* This file is part of php-saml.
4+
*
5+
* (c) OneLogin Inc
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*
10+
* @package OneLogin
11+
* @author OneLogin Inc <saml-info@onelogin.com>
12+
* @license MIT https://github.com/onelogin/php-saml/blob/master/LICENSE
13+
* @link https://github.com/onelogin/php-saml
14+
*/
15+
16+
namespace OneLogin\Saml2;
17+
18+
use Exception;
19+
320
/**
421
* Error class of OneLogin PHP Toolkit
522
*
623
* Defines the Error class
724
*/
8-
class OneLogin_Saml2_Error extends Exception
25+
class Error extends Exception
926
{
1027
// Errors
1128
const SETTINGS_FILE_NOT_FOUND = 0;
@@ -33,88 +50,16 @@ class OneLogin_Saml2_Error extends Exception
3350
* @param int $code The code error (defined in the error class).
3451
* @param array|null $args Arguments used in the message that describes the error.
3552
*/
36-
public function __construct($msg, $code = 0, $args = null)
37-
{
38-
assert('is_string($msg)');
39-
assert('is_int($code)');
40-
41-
$message = OneLogin_Saml2_Utils::t($msg, $args);
42-
43-
parent::__construct($message, $code);
44-
}
45-
}
46-
47-
/**
48-
* This class implements another custom Exception handler,
49-
* related to exceptions that happens during validation process.
50-
*/
51-
class OneLogin_Saml2_ValidationError extends Exception
52-
{
53-
# Validation Errors
54-
const UNSUPPORTED_SAML_VERSION = 0;
55-
const MISSING_ID = 1;
56-
const WRONG_NUMBER_OF_ASSERTIONS = 2;
57-
const MISSING_STATUS = 3;
58-
const MISSING_STATUS_CODE = 4;
59-
const STATUS_CODE_IS_NOT_SUCCESS = 5;
60-
const WRONG_SIGNED_ELEMENT = 6;
61-
const ID_NOT_FOUND_IN_SIGNED_ELEMENT = 7;
62-
const DUPLICATED_ID_IN_SIGNED_ELEMENTS = 8;
63-
const INVALID_SIGNED_ELEMENT = 9;
64-
const DUPLICATED_REFERENCE_IN_SIGNED_ELEMENTS = 10;
65-
const UNEXPECTED_SIGNED_ELEMENTS = 11;
66-
const WRONG_NUMBER_OF_SIGNATURES_IN_RESPONSE = 12;
67-
const WRONG_NUMBER_OF_SIGNATURES_IN_ASSERTION = 13;
68-
const INVALID_XML_FORMAT = 14;
69-
const WRONG_INRESPONSETO = 15;
70-
const NO_ENCRYPTED_ASSERTION = 16;
71-
const NO_ENCRYPTED_NAMEID = 17;
72-
const MISSING_CONDITIONS = 18;
73-
const ASSERTION_TOO_EARLY = 19;
74-
const ASSERTION_EXPIRED = 20;
75-
const WRONG_NUMBER_OF_AUTHSTATEMENTS = 21;
76-
const NO_ATTRIBUTESTATEMENT = 22;
77-
const ENCRYPTED_ATTRIBUTES = 23;
78-
const WRONG_DESTINATION = 24;
79-
const EMPTY_DESTINATION = 25;
80-
const WRONG_AUDIENCE = 26;
81-
const ISSUER_MULTIPLE_IN_RESPONSE = 27;
82-
const ISSUER_NOT_FOUND_IN_ASSERTION = 28;
83-
const WRONG_ISSUER = 29;
84-
const SESSION_EXPIRED = 30;
85-
const WRONG_SUBJECTCONFIRMATION = 31;
86-
const NO_SIGNED_MESSAGE = 32;
87-
const NO_SIGNED_ASSERTION = 33;
88-
const NO_SIGNATURE_FOUND = 34;
89-
const KEYINFO_NOT_FOUND_IN_ENCRYPTED_DATA = 35;
90-
const CHILDREN_NODE_NOT_FOUND_IN_KEYINFO = 36;
91-
const UNSUPPORTED_RETRIEVAL_METHOD = 37;
92-
const NO_NAMEID = 38;
93-
const EMPTY_NAMEID = 39;
94-
const SP_NAME_QUALIFIER_NAME_MISMATCH = 40;
95-
const DUPLICATED_ATTRIBUTE_NAME_FOUND = 41;
96-
const INVALID_SIGNATURE = 42;
97-
const WRONG_NUMBER_OF_SIGNATURES = 43;
98-
const RESPONSE_EXPIRED = 44;
99-
const UNEXPECTED_REFERENCE = 45;
100-
const NOT_SUPPORTED = 46;
101-
const KEY_ALGORITHM_ERROR = 47;
102-
const MISSING_ENCRYPTED_ELEMENT = 48;
103-
104-
105-
/**
106-
* Constructor
107-
*
108-
* @param string $msg Describes the error.
109-
* @param int $code The code error (defined in the error class).
110-
* @param array|null $args Arguments used in the message that describes the error.
111-
*/
112-
public function __construct($msg, $code = 0, $args = null)
53+
public function __construct($msg, $code = 0, $args = array())
11354
{
114-
assert('is_string($msg)');
115-
assert('is_int($code)');
55+
assert(is_string($msg));
56+
assert(is_int($code));
11657

117-
$message = OneLogin_Saml2_Utils::t($msg, $args);
58+
if (!isset($args)) {
59+
$args = array();
60+
}
61+
$params = array_merge(array($msg), $args);
62+
$message = call_user_func_array('sprintf', $params);
11863

11964
parent::__construct($message, $code);
12065
}

0 commit comments

Comments
 (0)