Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logout process #805

Open
Baku305 opened this issue Mar 6, 2024 · 0 comments
Open

Logout process #805

Baku305 opened this issue Mar 6, 2024 · 0 comments

Comments

@Baku305
Copy link

Baku305 commented Mar 6, 2024

I created a hook that checks some attributes within the XML of the SAML response and if it does not satisfy some conditions it redirects the user to the login page with an error message, logging out of the moodle session. the problem that I can't solve, however, is related to the logout on the idp side. In fact, when I then try to log in again from the dedicated button on the main page, the user is still logged in on the fixed side and therefore does not allow me to log in with a different user. can someone help me please. I share the code of my hook, in this case I don't log out on the Moodle side, but my intention is to clean the session and everything works as it should. the problem remains on the idp side. Thanks in advance


defined('MOODLE_INTERNAL') || die();


function local_customsamlhook_extend_auth_saml2_proc()
{
    return [
        51 => array(
            'class' => 'core:PHP',
            'code' => '    
            $attributeName = "http://schemas.xmlsoap.org/claims/Group";
                if (isset($attributes[$attributeName])) {
                    $attributeValues = $attributes[$attributeName];
                    $attributeValuesString = is_array($attributeValues) ? implode(", ", $attributeValues) : $attributeValues;
                    
                    if (strpos($attributeValuesString, "grp-viceversa") === false) {
                        global $PAGE, $OUTPUT, $SESSION, $CFG;

                        // Set the error message in the session.
                        $SESSION->loginerrormsg = "Accesso non Autorizzato: si prega di contattare l\'help desk";
                    
                        $indexPageURL = new moodle_url("$CFG->wwwroot/login/index.php");
                        redirect($indexPageURL);
                        exit(1);
                    }
                } else {
                    global $PAGE, $OUTPUT, $SESSION, $CFG;
                
                        // Set the error message in the session.
                        $SESSION->loginerrormsg = "Accesso non Autorizzato: si prega di contattare l\'help desk";
                    
                        $indexPageURL = new moodle_url("$CFG->wwwroot/login/index.php");
                        redirect($indexPageURL);
                        exit(1);
                }
            '
        )
    ];
}```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant