Ad Widget

Collapse

Zabbix API - Pass URL w/ Auth info

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • klaauser
    Junior Member
    • Apr 2016
    • 18

    #1

    Zabbix API - Pass URL w/ Auth info

    Hi -

    I'm using a heavily modified version of mozbx to have a mobile website for my zabbix install. I've had to modify it since it hasn't been updated since Zabbix API for 2.x.

    My question is - I've got a button on the mail screen that says 'Desktop Site' in case users need to visit the full site for some reason. Right now it just links to %zabbixURL%, but I would like to pass a URL that has the authentication token so that they don't have to sign in again.

    I'm not much use when it comes to API development and have basically been blindly adding snippets of code to try and get this thing to work.

    mozbx has already authenticated the user and from what I can tell each individual sub-page checks to see if the user has been authenticated already like this:
    Code:
    // Login
        if (isset($zabbixAuthHash) && strlen($zabbixAuthHash) > 0) {
            // Try it with the authentication hash we have
            $zabbix->setAuthToken($zabbixAuthHash);
        } elseif (strlen($zabbix->getUsername()) > 0 && strlen($zabbix->getPassword()) > 0 && strlen($zabbix->getZabbixApiUrl()) > 0) {
            // Or try it with our info from the cookies
            $zabbix->login();
        }
    
        if (!$zabbix->isLoggedIn()) {
            header("Location: index.php");
            exit();
        }
    I even tried editing the actual Zabbix webpages to include some similar code to no effect. I remember reading SOMEWHERE that there was a way to pass an authentication token in the URL - that's what I'm looking for.

    Thanks in advance!
    Kyle

    EDIT: I just noticed that mozbx is creating a cookie to store auth info:
    Code:
    if ($zabbix->isLoggedIn()) {
    		// Authenticated, save cookie
    		setcookie("zabbixUsername", $zabbix->getUsername(), $arrSettings["cookieExpire"]);
    		setcookie("zabbixPassword", $zabbix->getPassword(), $arrSettings["cookieExpire"]);
    		setcookie("zabbixApi", $zabbix->getZabbixApiUrl(), $arrSettings["cookieExpire"]);
    		setcookie("zabbixAuthHash", $zabbix->getAuthToken(), $arrSettings["cookieExpire"]);
        }
    Is there anyway to use this cookie to log in?
    Last edited by klaauser; 02-02-2017, 04:51.
Working...