{"record":{"id":"f25a06898f6ecf59","repo":"moodle/moodle","slug":"shib-not-all-attributes-error","errorCode":"shib_not_all_attributes_error","errorMessage":"shib_not_all_attributes_error","messagePattern":"shib_not_all_attributes_error","errorType":"exception","errorClass":"moodle_exception","httpStatus":null,"severity":"error","filePath":"public/auth/shibboleth/auth.php","lineNumber":98,"sourceCode":"            return false;\n        }\n    }\n\n\n\n    /**\n     * Returns the user information for 'external' users. In this case the\n     * attributes provided by Shibboleth\n     *\n     * @return array $result Associative array of user data\n     */\n    function get_userinfo($username) {\n    // reads user information from shibboleth attributes and return it in array()\n        global $CFG;\n\n        // Check whether we have got all the essential attributes\n        if ( empty($_SERVER[$this->config->user_attribute]) ) {\n            throw new \\moodle_exception( 'shib_not_all_attributes_error', 'auth_shibboleth' , '',\n                    \"'\".$this->config->user_attribute.\"' ('\".$_SERVER[$this->config->user_attribute].\"'), '\".\n                $this->config->field_map_firstname.\"' ('\".$_SERVER[$this->config->field_map_firstname].\"'), '\".\n                $this->config->field_map_lastname.\"' ('\".$_SERVER[$this->config->field_map_lastname].\"') and '\".\n                $this->config->field_map_email.\"' ('\".$_SERVER[$this->config->field_map_email].\"')\");\n        }\n\n        $attrmap = $this->get_attributes();\n\n        $result = array();\n        $search_attribs = array();\n\n        foreach ($attrmap as $key=>$value) {\n            // Check if attribute is present\n            if (!isset($_SERVER[$value])){\n                $result[$key] = '';\n                continue;\n            }\n","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/moodle/moodle/blob/48ea8c33227277e916cdd4079dbecef448b37f2c/public/auth/shibboleth/auth.php#L80-L116","documentation":"This Moodle exception is thrown by auth_shibboleth's get_userinfo() when the essential Shibboleth attributes are absent from the $_SERVER superglobal. Specifically, $_SERVER[user_attribute] is empty, meaning the IdP did not deliver the mapped username (and the error message lists the missing firstname/lastname/email mappings too). It guards against building a Moodle user profile from incomplete attribute data.","triggerScenarios":"Calling get_userinfo() after a Shibboleth login where $_SERVER[$this->config->user_attribute] is empty — the SP did not receive the mapped user_attribute (e.g. 'persistent-id' or 'eppn') from the IdP.","commonSituations":"IdP not releasing the required attribute (attribute filter/policy mismatch); wrong 'Username mapping' field configured in the Shibboleth auth settings; Shibboleth SP not protecting the Moodle directory so no attributes populate $_SERVER; IdP attribute encoding changes after an upgrade.","solutions":["Check Site administration > Plugins > Authentication > Shibboleth > 'Username mapping' matches an attribute your IdP actually releases (e.g. eppn, persistent-id).","Verify on the IdP that the attribute-release/attribute-filter policy releases username, firstname, lastname and email to this SP.","Test what the SP receives: dump $_SERVER on a protected page or check the SP shibd session dump.","Ensure Apache/Shibboleth actually protects /auth/shibboleth and /login (Request mapping / ShibRequestSetting) so attributes are exposed."],"exampleFix":"// before (auth settings)\n$username_mapping = 'uid'; // IdP never releases 'uid'\n// after\n$username_mapping = 'eppn'; // attribute confirmed released by the IdP","handlingStrategy":"validation","validationCode":"function shibAttributesPresent(array $map): bool {\n    foreach (array_values($map) as $srvKey) {\n        if (empty($_SERVER[$srvKey])) {\n            return false;\n        }\n    }\n    return true;\n}\n// $map = config->user_attribute / field_map_firstname / field_map_lastname / field_map_email","typeGuard":"function hasShibAttribute(string $key): bool {\n    return isset($_SERVER[$key]) && $_SERVER[$key] !== '';\n}","tryCatchPattern":"try {\n    $userinfo = $auth->get_userinfo($username);\n} catch (\\moodle_exception $e) {\n    if ($e->errorcode === 'shib_not_all_attributes_error') {\n        debugging('IdP did not release required attributes: ' . $e->debuginfo, DEBUG_DEVELOPER);\n        // fall back to manual login page\n    }\n    throw $e;\n}","preventionTips":["Keep the IdP attribute-release policy in sync with the Moodle Shibboleth field mappings","After changing 'Username mapping' or field maps, verify the SP actually receives those variables","Monitor SP logs (shibd) for attribute filtering denials"],"tags":["moodle","shibboleth","sso","missing-attributes"],"backgroundTag":"missing-required-config-field","analyzedSha":"48ea8c33227277e916cdd4079dbecef448b37f2c","analyzedAt":"2026-09-14T20:34:48.527Z","contentChangedAt":"2026-09-14T20:34:48.527Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}