Search code examples
phpsimplesamlphp

Redirect users in specific user group to a given page after login using simpleSAMLphp


I have one group of users who have more limited access to a site. I would like it so that most users (in the general access group) are forwarded to the front page of the site, but a specific group be forwarded to a particular page after login. I am sure this must be possible but I can't find it in the documentation.


Solution

  • I ended up putting a redirect in the header based on specific attributes I had given to types of user. Here's my approach in case anyone searches their way to this

    if($_SESSION['attributes']['Usertype'][0] == "guest")
    {
    header("Location:  https://www.mypage.org/?page=guest-account-creation");
    die();
    }
    
    if($_SESSION['attributes']['Usertype'][0] == "group 1")
    {
    header("Location:  https://www.mypage.org/?page=just-for-group-1");
    die();
    }
    
    if($_SESSION['attributes']['Usertype'][0] == "group 2")
    {
    header("Location: https://www.mypage.org/?page=just-for-group-1");
    die();
    }
    

    I put this along with the SAML code right at the head of the php of my pages, and it works well. Note this is not a security based solution, just a user flow one (I am not using this to secure certain site areas from certain users, just getting them to the most useful place).