Ad Widget

Collapse

Avoiding login screen

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LeoCombes
    Member
    • Mar 2011
    • 32

    #1

    Avoiding login screen

    Hi all.
    I was looking for an answer and although the issue was discussed several times, I can not find an answer.

    I need to access certain graphics of Zabbix from another website, for this I have a frame with the link to the chart.
    The problem is that the first time I try to view the chart, I see the login screen.
    I need to avoid this situation. I have the user "guest" enabled to see the graphics, but do not know how to avoid the login screen and login and login by default with the user "guest". Pass data of user and password as arguments in the hyperlink does not work.

    Is there any way that if you do not login with another user enter automatically with the user "guest"?
    Is there any way to pass user and password as an argument in the link?

    I've seen solutions using wget ... but there must be a more direct solution. I have no problem to modify the code if necessary.
    Other solution?

    Anyone have idea?
    Thank you.
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    Can you provide a little more information about what you are trying to accomplish? Are you trying to embed a graph in another page, or just link to a screen?

    If all you need to do is download a graph Zabcon can do that through the use of the following custom command: http://trac.red-tux.net/browser/trun...x_get_graph.rb
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    • LeoCombes
      Member
      • Mar 2011
      • 32

      #3
      Sorry for the delay in replying.
      I'm trying to embed a graph in a web page.
      I made a script that finds the graph associated with a device from its IP, it returns a string like:

      Code:
      fullscreen=0&hostid=10231&graphid=624
      with this strring creates the URL to call the graph to custom_charts.php.
      "custom_charts.php" is the same "charts.php" but with some lines removed in order not to load the combo selection of host and some more things.



      This works perfectly, but the first time I'm going to use, instead of seeing the graphic login screen appears.
      I can do this with Zabcon without this problem?

      Comment

      • nelsonab
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Sep 2006
        • 1233

        #4
        Hmm, I have a hunch you're getting tripped up by the need for the value for ZBX_AUTH to be set in a cookie. Zabcon will download a graph, but it's meant more for command line use than inside a web server/browser.

        One option may be to write a wrapper for the graphs. This would be a script, php, ruby, your choice, which will perform the login, then perform a download using the login, and funnel the results back to the browser. It would work in a similar way to a web script sending back a graphic image.
        RHCE, author of zbxapi
        Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
        Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

        Comment

        • LeoCombes
          Member
          • Mar 2011
          • 32

          #5
          I found several requests for this feature in this forum and I do not see any solution is implemented. Could not make a feature request for this?
          I find it quite difficult to make an wrapper for fill data automatically on login form.
          It would be easier if I knew the data passes the login form in the process of authentication or better yet know the variables that must be changed to always allow auto login as "guest" if no login has been made.
          Anyone know how make this?

          Comment

          • LeoCombes
            Member
            • Mar 2011
            • 32

            #6
            Finally I have some code to avoid the login screen. It's a dirty solution, but it works and it could help.

            If you have not logged onto the system and enter a URL that contains a graphic, screen or anything else, it automatically logs in as "guest" and tries to show the page.

            If you want to log in as "admin" must go to index.php and add the URL parameter "force_login = 1", thus:
            "...zabbix / index.php? force_login = 1". Login as "admin" and manage your system ...

            For this to work we must add the lines marked in the beginning with ">>" in the "index.php" file. Where appears "(...)" is the place where there are not shown codes, in order to summarize.


            Code:
            	$fields=array(
            		'name'=>			array(T_ZBX_STR, O_NO,	NULL,	NOT_EMPTY,	'isset({enter})', S_LOGIN_NAME),
            		'password'=>		array(T_ZBX_STR, O_OPT,	NULL,	NULL,		'isset({enter})'),
            		'sessionid'=>		array(T_ZBX_STR, O_OPT,	NULL,	NULL,		NULL),
            		'message'=>			array(T_ZBX_STR, O_OPT,	NULL,	NULL,		NULL),
            		'reconnect'=>		array(T_ZBX_INT, O_OPT,	P_SYS,	BETWEEN(0,65535),NULL),
            		'enter'=>			array(T_ZBX_STR, O_OPT, P_SYS,	NULL,		NULL),
            		'form'=>			array(T_ZBX_STR, O_OPT, P_SYS,  NULL,   	NULL),
            		'form_refresh'=>	array(T_ZBX_INT, O_OPT, NULL,   NULL,   	NULL),
            		'request'=>			array(T_ZBX_STR, O_OPT, NULL, 	NULL,   	NULL),
            >>		'force_login'=>			array(T_ZBX_STR, O_OPT, NULL, 	NULL,   	NULL),
            	);
            	check_fields($fields);
            
            (...)
            
            	$request = get_request('request');
            	if(isset($_REQUEST['enter'])&&($_REQUEST['enter']=='Enter')){
            		global $USER_DETAILS;
            		$name = get_request('name','');
            		$passwd = get_request('password','');
            
            
            		$login = CUser::login(array('user'=>$name, 'password'=>$passwd, 'auth_type'=>$authentication_type));
            
            		if($login){
            			$url = is_null($request)?$USER_DETAILS['url']:$request;
            
            			jsRedirect($url);
            			exit();
            		}
            	}
            >>	if(isset($_REQUEST['force_login'])){
            >>		global $USER_DETAILS;
            >>		$name = get_request('name','');
            >>		$passwd = get_request('password','');
            >>		$login = CUser::login(array('user'=>$name, 'password'=>$passwd, 'auth_type'=>$authentication_type));
            >>
            >>		if($login){
            >>			$url = is_null($request)?$USER_DETAILS['url']:$request;
            >>			jsRedirect($url);
            >>			exit();
            >>		}
            >>	}
            >>	elseif(!isset($_REQUEST['force_login'])){
            >>		$name = "guest";
            >>		$passwd = "";
            >>		$login = CUser::login(array('user'=>$name, 'password'=>$passwd, 'auth_type'=>$authentication_type));
            >>		if($login){
            >>			$url = is_null($request)?$USER_DETAILS['url']:$request;
            >>			jsRedirect($url);
            >>			exit();
            >>		}
            >>	}
            
            (...)

            Comment

            • nike-17
              Junior Member
              • Oct 2011
              • 7

              #7
              sorry for delay with answer - you can use Zaebator

              Comment

              • LeoCombes
                Member
                • Mar 2011
                • 32

                #8
                Zaebator is a useful tool, but I can not see the time bar to change the timeline

                Comment

                • bcarpio
                  Member
                  • Jun 2008
                  • 96

                  #9
                  I don't have to patch

                  I don't have to add any patch and requesting a URL works just fine as long as the guest user has access to that URL.

                  I am running 1.8.9 and when I display a graph it works fine as long as the guest user has access.

                  What version of zabbix are you using?

                  Comment

                  • nike-17
                    Junior Member
                    • Oct 2011
                    • 7

                    #10
                    Originally posted by LeoCombes
                    Zaebator is a useful tool, but I can not see the time bar to change the timeline
                    it isn't problem - ypu can pass period as 3 parameter to Zaebator_Service
                    PHP Code:
                    Zaebator_Service_Graph::getGraphImageById($zaebator$graphid$period); 
                    $period it's time in seconds for example 3600 = 1 day
                    you can use something like http://jqueryui.com/demos/slider/ for UI

                    Comment

                    • mobym
                      Junior Member
                      • Apr 2017
                      • 3

                      #11
                      External Access to Zabbix Page

                      Hi all.
                      I was looking for an answer,
                      I need to access toptriggers.php of Zabbix page externally,in order to create a pdf for that.
                      Is there any way to pass user and password as an argument in the link?

                      Anyone have idea?
                      Thank you.
                      Reply With Quote

                      Comment

                      Working...