Skip to content

Commit

Permalink
Bug fixes and disable authentication in default route.
Browse files Browse the repository at this point in the history
  • Loading branch information
francis94c committed Apr 9, 2020
1 parent aeebeb1 commit b895a8d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libraries/REST.php
Expand Up @@ -193,7 +193,9 @@ function __construct(?array $params=null)
//}

// Authenticate
$this->authenticate();
if ($this->ci->uri->total_segments() > 0) {
$this->authenticate();
}

// Generic Rate Limiter.
if ($this->limit_api && !$this->checked_rate_limit &&
Expand Down Expand Up @@ -295,11 +297,13 @@ private function bearer_auth(string $auth, int $flags):void
{
$authorization = $this->get_authorization_header();
$shouldProceed = $this->auth_proceed(false, $flags);
if ($authorization == null || substr_count($authorization, ' ') != 1 && !$shouldProceed) {
if ($authorization == null || substr_count($authorization, ' ') != 1) {
if ($shouldProceed) return;
$this->handle_response(RESTResponse::BAD_REQUEST, $auth, 'Bad Request'); // Exits.
}
$token = explode(" ", $authorization);
if ($token[0] != $auth && !$shouldProceed) {
if ($token[0] != $auth) {
if ($shouldProceed) return;
$this->handle_response(RESTResponse::BAD_REQUEST, $auth, 'Bad Request'); // Exits.
}
$this->token = $token[1];
Expand Down

0 comments on commit b895a8d

Please sign in to comment.