codeigniter-restserver icon indicating copy to clipboard operation
codeigniter-restserver copied to clipboard

Basic auth always valid

Open fabio-ravizzotti opened this issue 9 years ago • 9 comments

Hi, I think there is a problem on basic authentication in the version 3.0.0 because it results valid with wrong credentials or without them.

I tried to rollback to version 2.8.0 and all it works correctly.

May you check it please?

fabio-ravizzotti avatar Jan 10 '17 14:01 fabio-ravizzotti

Same problem here... basic auth only work for index pages. If I create another public function in the controller, any request goes through

asystat avatar Jan 13 '17 19:01 asystat

Investigating...

chriskacerguis avatar Jan 20 '17 02:01 chriskacerguis

So, the problem is here: https://github.com/chriskacerguis/codeigniter-restserver/blob/master/application/libraries/REST_Controller.php#L828

basically, it needs to add the following 2 lines:

$this->output->_display();
exit; 

The problem that I am having is that using exit breaks the unit testing, so I'm trying to rework things so I don't have to use exit.

Ultimately, the issue is with _display() in the CI Output Class

https://codeigniter.com/user_guide/libraries/output.html#CI_Output::_display

chriskacerguis avatar Jan 20 '17 03:01 chriskacerguis

Hi,

I'm starting using the restserver, thanks for providing such good tool.

It appears the rest_auth = 'session' method is always validating any request, whether the session exists or not.

While debugging the REST_Controller.php I've found the _check_php_session is actually identifying the lacking of the session and throwing a HTTP_UNAUTHORIZED response, but the process continues and the user method (i.e. "get") always responds as if is validated.

amorimtiago avatar Jan 23 '17 12:01 amorimtiago

Digest auth, also always valid

mpa2304 avatar Jan 24 '17 16:01 mpa2304

I suggest that the REST_Controller will not call the endpoint if authentication failed. Aborting the script execution mid-air might have worse implications than breaking tests...

benyaminshoham avatar Jan 25 '17 08:01 benyaminshoham

I found this problem. In the REST_Controller.php function _remap (line 629) $this->response is missing a 'return;' after each unauthorized or forbidden response. The code keeps going to the next section which eventually becomes authorized.

This has been fixed in other pull requests in a much more complicated way.

zilth avatar Mar 28 '17 01:03 zilth

Fix comes with this commit https://github.com/chriskacerguis/codeigniter-restserver/commit/54b2b9cf0698811f9fdf3a1f833f94295ef7a955

kalimerre avatar Apr 10 '17 11:04 kalimerre

See here https://github.com/chriskacerguis/codeigniter-restserver/issues/790

Closing this, please reopen if you are still having the issues.

chriskacerguis avatar Apr 16 '17 21:04 chriskacerguis