Skip to content

[CAS plugin] StaffSession is not created correctly #165

@luketainton

Description

@luketainton

That message is returned here:

You’ll need to unpack the plugin and do some debugging in this method to see where the issue is occurring. You’ll also need to check your Apache and PHP error logs for any related errors. Looking at the method, if we can’t get the $staff and $staff->getId(); then we return the message so you need to find out why there is no staff. Maybe there is no Email address in the request? Or maybe you can’t create the session?

Note:
You will also need to create your own issue report as your report is different than the OP’s (which is OAuth related).

Cheers.

Originally posted by @JediKev in #126 (comment)

I've done some digging around by editing the source code on the fly. The original function to trigger a sign in is:

function signOn() {
    if (isset($_SESSION[':cas']['user'])) {
        $staff = new StaffSession($this->cas->getEmail());
        if ($staff && $staff->getId()) {
            return $staff;
        } else {
            $_SESSION['_staff']['auth']['msg'] = 'Have your administrator create a local account';
        }
    }
}

I've edited it as below in order to get the web app to print details to the browser:

function signOn() {
    if (isset($_SESSION[':cas']['user'])) {
        $staff = new StaffSession($this->cas->getEmail());
        print_r($staff);
        die();
        if ($staff && $staff->getId()) {
            return $staff;
        } else {
            $_SESSION['_staff']['auth']['msg'] = 'Have your administrator create a local account. ';
            echo('PostProcess: ');
            print_r($_SESSION[':cas']);
            die();
        }
    }
}

When I try to login using CAS after this modification, I get redirected to my SSO system correctly and I'm able to login. When it redirects back to osTicket, I get the following:
StaffSession Object ( [session] => [token] => [authkey] => [departments] => [stats] => Array ( ) [_extra] => [passwd_change] => [_roles] => [_teams] => [_config] => [_perm] => [ht] => Array ( ) [dirty] => Array ( ) [__new__] => 1 [__deleted__] => [__deferred__] => Array ( ) ) .

It would seem that as no ID is present for getId() to return, the if statement is failing. Either that, or the StaffSession isn't being created at all.

As part of my debugging I added a line to always print $_SESSION[':cas'] to the browser. In this response I get back an array containing a username, email, and name.

Does anyone have any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions