File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -1119,6 +1119,46 @@ if (isset($_SESSION['samlUserdata'])) { // If there is user data we print it.
11191119}
11201120```
11211121
1122+ #### Example (using Composer) that initiates the SSO request and handles the response (is the acs target) ####
1123+
1124+ Install package via composer:
1125+ ```
1126+ composer require onelogin/php-saml
1127+ ```
1128+
1129+ Create an index.php:
1130+ ``` php
1131+ <?php
1132+ require('vendor/autoload.php');
1133+
1134+ session_start();
1135+ $needsAuth = empty($_SESSION['samlUserdata']);
1136+
1137+ if ($needsAuth) {
1138+ // put SAML settings into an array to avoid placing files in the
1139+ // composer vendor/ directories
1140+ $samlsettings = array(/*...config goes here...*/);
1141+
1142+ $auth = new \OneLogin\Saml2\Auth($samlsettings);
1143+
1144+ if (!empty($_REQUEST['SAMLResponse']) && !empty($_REQUEST['RelayState'])) {
1145+ $auth->processResponse(null);
1146+ $errors = $auth->getErrors();
1147+ if (empty($errors)) {
1148+ // user has authenticated successfully
1149+ $needsAuth = false;
1150+ $_SESSION['samlUserdata'] = $auth->getAttributes();
1151+ }
1152+ }
1153+
1154+ if ($needsAuth) {
1155+ $auth->login();
1156+ }
1157+ }
1158+
1159+ // rest of your app goes here
1160+ ```
1161+
11221162#### URL-guessing methods ####
11231163
11241164php-saml toolkit uses a bunch of methods in OneLogin_Saml2_Utils that try to guess the URL where the SAML messages are processed.
You can’t perform that action at this time.
0 commit comments