Phpservermon: Disable user login system

Created on 18 Oct 2016  路  8Comments  路  Source: phpservermon/phpservermon

Hi all. First of all, tks for this amazing tool! it's awesome :)

So, I need to disable the user login system in order to keep the tool open.
I tried to do some changes on "\src\psm\Service\User.class.php" file, but didn't work.

Anyone can help me?

enhancement good first issue help wanted

Most helpful comment

Additional requests from other issues:

  • #539 Only disable login for specific IP.

Summery:
The user login could be disabled.

  • So the current status and the history will be publicly available.
  • But an administrator account will still be necessary to add and remove servers.

correct?

All 8 comments

You could try to set PSM_USER_ANONYMOUS = PSM_USER_USER
https://github.com/phpservermon/phpservermon/blob/68c087025dccc6f69a45e1f088350a22a2cd8d39/src/bootstrap.php#L37

Try at your own risk !

Hello,

When will this option been build in?

Greetings,
Robin

When some contributor will take time to submit a PR

I really need this option.. i cant figure it out.. Can someone help me? An LDAP option would be nicer, but i think that would cost more time..

I export the data from the database into a .json file. Then i read the .json file on a external page for my users. This way i dont need any kind of authentication. Little bit less secure, but there is no any sensitive data in the .json file. It works great for me.

Additional requests from other issues:

  • #539 Only disable login for specific IP.

Summery:
The user login could be disabled.

  • So the current status and the history will be publicly available.
  • But an administrator account will still be necessary to add and remove servers.

correct?

I found a workaround unofficial solution here: https://sourceforge.net/p/phpservermon/discussion/845823/thread/f1b2e4ff/

Credit: Tommy Grignon
Edited a bit to fix english errors.

First, Create a Public user, assign servers as you wish the public user to.
Second, Memorize the ID it gives to you. (When I tried It didn't give me an ID, the ID is equivalent to the number of users you've made on PHPServermon, should be able to find it in your database as well)

Next, navigate to \src\psm\Service\User.php
on Line 98 (after $this->session = $session;)

add code:
global $_GET;

if ($_GET["kl"] == "public"){
$user_id = 2;
$this->setUserLoggedIn($user_id, true);
$user = $this->getUser($user_id);
$this->newRememberMeCookie();
}

Enter URL http:/server/servermonitor/?kl=public to bypass login

This method use a particular userid so even if somebody change the password, the script will never use it anyway.

OPTIONAL:
You can change other things to cut some menu items,
\psm\Module\AbstractController.php

Line 271 : erase the server_update function, I think this is only the crontab need to make a status update and I seen some troubles when I make it manually.

$items = array('server_status', 'server', 'server_log', 'user', 'config');

Line 274 : comment the entire items line, when you are only User (Public account) you don't want to have other things to see other then the servers status page

//$items = array('server_status', 'server', 'server_log', 'server_update');

Here a quick workaround:
Create a anonymous user.
Add this user to all the servers that should be displayed to everyone.

Add a file a the web root (public_alerts.php) with these lines :
require __DIR__.'/src/bootstrap.php';
psm_no_cache();
$User = $router->getService('user');
// Use the anonymous login and password.
$User->loginWithPostData('anonymous','anonymous');
$router->run('server_status');
# Comment this line if you want anonymous users be able to see details and other pages /!\ The could also access profile pages and change password....
$User->getSession()->invalidate();

The public alert are now available on http:///public_alerts.php

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nitrocode picture nitrocode  路  10Comments

amelhorn picture amelhorn  路  8Comments

djexthreme picture djexthreme  路  4Comments

gaia picture gaia  路  3Comments

b1f17773 picture b1f17773  路  4Comments