Skip to content

Commit 72bcc7b

Browse files
committed
Add Namespaces
1 parent 7cf3bb3 commit 72bcc7b

File tree

166 files changed

+2024
-31833
lines changed

Some content is hidden

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

166 files changed

+2024
-31833
lines changed

README.md

+42-124
Large diffs are not rendered by default.

_toolkit_loader.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// http://php.net/manual/en/language.oop5.autoload.php
66

77
// Load composer vendor folder if any
8-
if (file_exists('vendor/autoload.php')) {
9-
require 'vendor/autoload.php';
8+
if (file_exists(__DIR__ . 'vendor/autoload.php')) {
9+
require __DIR__ . '/vendor/autoload.php';
1010
}
1111

1212
/*
@@ -21,7 +21,7 @@
2121

2222

2323
// Load php-saml
24-
$libDir = __DIR__ . '/lib/Saml2/';
24+
$libDir = __DIR__ . '/src/Saml2/';
2525

2626
$folderInfo = scandir($libDir);
2727

@@ -30,4 +30,3 @@
3030
include_once $libDir.$element;
3131
}
3232
}
33-

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"homepage": "https://developers.onelogin.com/saml/php",
77
"keywords": ["saml", "saml2", "onelogin"],
88
"autoload": {
9-
"classmap": [
10-
"lib/Saml2"
11-
]
9+
"psr-4": {
10+
"OneLogin\\Saml2\\": "src/"
11+
}
1212
},
1313
"support": {
1414
"email": "[email protected]",

demo1/index.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88

99
require_once dirname(__DIR__).'/_toolkit_loader.php';
1010

11+
use OneLogin\Saml2\Auth;
12+
use OneLogin\Saml2\Utils;
13+
1114
require_once 'settings.php';
1215

13-
$auth = new OneLogin_Saml2_Auth($settingsInfo);
16+
$auth = new Auth($settingsInfo);
1417

1518
if (isset($_GET['sso'])) {
1619
$auth->login();
@@ -78,7 +81,7 @@
7881
$_SESSION['samlNameIdFormat'] = $auth->getNameIdFormat();
7982
$_SESSION['samlSessionIndex'] = $auth->getSessionIndex();
8083
unset($_SESSION['AuthNRequestID']);
81-
if (isset($_POST['RelayState']) && OneLogin_Saml2_Utils::getSelfURL() != $_POST['RelayState']) {
84+
if (isset($_POST['RelayState']) && Utils::getSelfURL() != $_POST['RelayState']) {
8285
$auth->redirectTo($_POST['RelayState']);
8386
}
8487
} else if (isset($_GET['sls'])) {

demo1/metadata.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,25 @@
66

77
require_once dirname(__DIR__).'/_toolkit_loader.php';
88

9+
use OneLogin\Saml2\Settings;
10+
use OneLogin\Saml2\Error;
11+
912
require_once 'settings.php' ;
1013

1114
try {
12-
#$auth = new OneLogin_Saml2_Auth($settingsInfo);
15+
#$auth = new OneLogin\Saml2\Auth($settingsInfo);
1316
#$settings = $auth->getSettings();
1417
// Now we only validate SP settings
15-
$settings = new OneLogin_Saml2_Settings($settingsInfo, true);
18+
$settings = new Settings($settingsInfo, true);
1619
$metadata = $settings->getSPMetadata();
1720
$errors = $settings->validateMetadata($metadata);
1821
if (empty($errors)) {
1922
header('Content-Type: text/xml');
2023
echo $metadata;
2124
} else {
22-
throw new OneLogin_Saml2_Error(
25+
throw new Error(
2326
'Invalid SP metadata: '.implode(', ', $errors),
24-
OneLogin_Saml2_Error::METADATA_SP_INVALID
27+
Error::METADATA_SP_INVALID
2528
);
2629
}
2730
} catch (Exception $e) {

demo2/consume.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99

1010
require_once dirname(__DIR__).'/_toolkit_loader.php';
1111

12+
use OneLogin\Saml2\Response;
13+
use OneLogin\Saml2\Settings;
14+
1215
try {
1316
if (isset($_POST['SAMLResponse'])) {
14-
$samlSettings = new OneLogin_Saml2_Settings();
15-
$samlResponse = new OneLogin_Saml2_Response($samlSettings, $_POST['SAMLResponse']);
17+
$samlSettings = new Settings();
18+
$samlResponse = new Response($samlSettings, $_POST['SAMLResponse']);
1619
if ($samlResponse->isValid()) {
1720
echo 'You are: ' . $samlResponse->getNameId() . '<br>';
1821
$attributes = $samlResponse->getAttributes();

demo2/index.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,21 @@
1212

1313
require_once dirname(__DIR__).'/_toolkit_loader.php';
1414

15+
use OneLogin\Saml2\AuthnRequest;
16+
use OneLogin\Saml2\Settings;
17+
use OneLogin\Saml2\Utils;
18+
1519
if (!isset($_SESSION['samlUserdata'])) {
16-
$settings = new OneLogin_Saml2_Settings();
17-
$authRequest = new OneLogin_Saml2_AuthnRequest($settings);
20+
$settings = new Settings();
21+
$authRequest = new AuthnRequest($settings);
1822
$samlRequest = $authRequest->getRequest();
1923

2024
$parameters = array('SAMLRequest' => $samlRequest);
21-
$parameters['RelayState'] = OneLogin_Saml2_Utils::getSelfURLNoQuery();
25+
$parameters['RelayState'] = Utils::getSelfURLNoQuery();
2226

2327
$idpData = $settings->getIdPData();
2428
$ssoUrl = $idpData['singleSignOnService']['url'];
25-
$url = OneLogin_Saml2_Utils::redirect($ssoUrl, $parameters, true);
29+
$url = Utils::redirect($ssoUrl, $parameters, true);
2630

2731
header("Location: $url");
2832
} else {

demo2/metadata.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
require_once dirname(__DIR__).'/_toolkit_loader.php';
1010

11+
use OneLogin\Saml2\Metadata;
12+
use OneLogin\Saml2\Settings;
13+
1114
header('Content-Type: text/xml');
1215

13-
$samlSettings = new OneLogin_Saml2_Settings();
16+
$samlSettings = new Settings();
1417
$sp = $samlSettings->getSPData();
1518

16-
$samlMetadata = OneLogin_Saml2_Metadata::builder($sp);
19+
$samlMetadata = Metadata::builder($sp);
1720
echo $samlMetadata;

demo2/slo.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010

1111
require_once dirname(__DIR__).'/_toolkit_loader.php';
1212

13-
$samlSettings = new OneLogin_Saml2_Settings();
13+
use OneLogin\Saml2\LogoutRequest;
14+
use OneLogin\Saml2\Settings;
15+
use OneLogin\Saml2\Utils;
16+
17+
$samlSettings = new Settings();
1418

1519
$idpData = $samlSettings->getIdPData();
1620
if (isset($idpData['singleLogoutService']) && isset($idpData['singleLogoutService']['url'])) {
@@ -20,15 +24,15 @@
2024
}
2125

2226
if (isset($_SESSION['IdPSessionIndex']) && !empty($_SESSION['IdPSessionIndex'])) {
23-
$logoutRequest = new OneLogin_Saml2_LogoutRequest($samlSettings, null, $_SESSION['IdPSessionIndex']);
27+
$logoutRequest = new LogoutRequest($samlSettings, null, $_SESSION['IdPSessionIndex']);
2428
} else {
25-
$logoutRequest = new OneLogin_Saml2_LogoutRequest($samlSettings);
29+
$logoutRequest = new LogoutRequest($samlSettings);
2630
}
2731

2832
$samlRequest = $logoutRequest->getRequest();
2933

3034
$parameters = array('SAMLRequest' => $samlRequest);
3135

32-
$url = OneLogin_Saml2_Utils::redirect($sloUrl, $parameters, true);
36+
$url = Utils::redirect($sloUrl, $parameters, true);
3337

3438
header("Location: $url");

demo2/sso.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212

1313
require_once dirname(__DIR__).'/_toolkit_loader.php';
1414

15-
$auth = new OneLogin_Saml2_Auth();
15+
use OneLogin\Saml2\Auth;
16+
use OneLogin\Saml2\Utils;
17+
18+
$auth = new OneLogin\Saml2\Auth();
1619

1720
if (!isset($_SESSION['samlUserdata'])) {
1821
$auth->login();
1922
} else {
20-
$indexUrl = str_replace('/sso.php', '/index.php', OneLogin_Saml2_Utils::getSelfURLNoQuery());
21-
OneLogin_Saml2_Utils::redirect($indexUrl);
23+
$indexUrl = str_replace('/sso.php', '/index.php', Utils::getSelfURLNoQuery());
24+
Utils::redirect($indexUrl);
2225
}

docs/Onelogin_PHPToolkit_Guide.pdf

-136 KB
Binary file not shown.

docs/Saml2/classes.svg

-84
This file was deleted.

0 commit comments

Comments
 (0)