Skip to content

Commit

Permalink
Populate IDP saml response with user profile fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-webster-catalyst committed Nov 18, 2024
1 parent 668670a commit 2742b30
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions idp/sso.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
$domxml->loadXML($request);
$xpath = new DOMXPath($domxml);

// Attributes provided by the Behat step.
$attributes = [
'uid' => $USER->username,
'email' => $USER->email,
'firstname' => $USER->firstname,
'lastname' => $USER->lastname
];
// Load profile fields into attributes.
$authplugin = get_auth_plugin('saml2');
$userfields = array_merge($authplugin->userfields, $authplugin->get_custom_user_profile_fields());
profile_load_data($USER);
// Add username as `uid` as many services look for `uid` by default.
$attributes = ['uid' => $USER->username];
foreach ($userfields as $field) {
$attributes[$field] = $USER->$field ? $USER->$field : '';
}

// Get data from input request.
$id = $xpath->evaluate('normalize-space(/*/@ID)');
Expand Down

0 comments on commit 2742b30

Please sign in to comment.