YetiForceCompany/YetiForceCRM

View on GitHub
app/Integrations/Dav/Backend/Auth.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

The method challenge uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            parent::challenge($request, $response);
        }
Severity: Minor
Found in app/Integrations/Dav/Backend/Auth.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Parameter $request has undeclared type \Sabre\HTTP\RequestInterface
Open

    public function challenge(RequestInterface $request, ResponseInterface $response)
Severity: Minor
Found in app/Integrations/Dav/Backend/Auth.php by phan

Reference to undeclared property \App\Integrations\Dav\Backend\Auth->principalPrefix
Open

        return [true, $this->principalPrefix . $userpass[0]];
Severity: Minor
Found in app/Integrations/Dav/Backend/Auth.php by phan

Parameter $request has undeclared type \Sabre\HTTP\RequestInterface
Open

    public function checkBasic(RequestInterface $request, ResponseInterface $response)
Severity: Minor
Found in app/Integrations/Dav/Backend/Auth.php by phan

Call to method __construct from undeclared class \Sabre\HTTP\auth\basic
Open

        $auth = new HTTP\Auth\Basic(
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Call to undeclared method \App\Integrations\Dav\Backend\Auth::getDigestHash
Open

        $hash = $this->getDigestHash($this->realm, $userpass[0]);
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Class extends undeclared class \Sabre\DAV\auth\backend\pdo (Did you mean class \PDO)
Open

class Auth extends DAV\Auth\Backend\PDO
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Reference to undeclared class \Sabre\DAV\auth\backend\pdo (Did you mean class \PDO)
Open

        return parent::check($request, $response);
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Parameter $response has undeclared type \Sabre\HTTP\ResponseInterface
Open

    public function checkBasic(RequestInterface $request, ResponseInterface $response)
Severity: Minor
Found in app/Integrations/Dav/Backend/Auth.php by phan

Parameter $request has undeclared type \Sabre\HTTP\RequestInterface
Open

    public function check(RequestInterface $request, ResponseInterface $response)
Severity: Minor
Found in app/Integrations/Dav/Backend/Auth.php by phan

Call to method getHeader from undeclared class \Sabre\HTTP\RequestInterface
Open

        if (0 === strpos($request->getHeader('Authorization'), 'Basic')) {
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Parameter $response has undeclared type \Sabre\HTTP\ResponseInterface
Open

    public function check(RequestInterface $request, ResponseInterface $response)
Severity: Minor
Found in app/Integrations/Dav/Backend/Auth.php by phan

Parameter $response has undeclared type \Sabre\HTTP\ResponseInterface
Open

    public function challenge(RequestInterface $request, ResponseInterface $response)
Severity: Minor
Found in app/Integrations/Dav/Backend/Auth.php by phan

Call to method getHeader from undeclared class \Sabre\HTTP\RequestInterface
Open

        if (0 === strpos($request->getHeader('Authorization'), 'Basic')) {
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Call to method getCredentials from undeclared class \Sabre\HTTP\auth\basic
Open

        $userpass = $auth->getCredentials();
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Reference to undeclared class \Sabre\DAV\auth\backend\pdo (Did you mean class \PDO)
Open

            parent::challenge($request, $response);
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Call to method requireLogin from undeclared class \Sabre\HTTP\auth\basic
Open

            $auth->requireLogin();
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Call to method __construct from undeclared class \Sabre\HTTP\auth\basic
Open

            $auth = new HTTP\Auth\Basic(
Severity: Critical
Found in app/Integrations/Dav/Backend/Auth.php by phan

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * Keep in mind that in the case of multiple authentication backends, other

Spaces must be used to indent lines; tabs are not allowed
Open

    public function challenge(RequestInterface $request, ResponseInterface $response)

Spaces must be used to indent lines; tabs are not allowed
Open

                $request,

Spaces must be used to indent lines; tabs are not allowed
Open

    public $tableName = 'dav_users';

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/admin

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * backend returns a so-called principal url.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            parent::challenge($request, $response);

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * When this method is called, the backend must check if authentication was

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        return parent::check($request, $response);

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param RequestInterface  $request

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param ResponseInterface $response

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/users/[username]

Spaces must be used to indent lines; tabs are not allowed
Open

    public function check(RequestInterface $request, ResponseInterface $response)

Spaces must be used to indent lines; tabs are not allowed
Open

     * If authentication was successful, it's expected that the authentication

Spaces must be used to indent lines; tabs are not allowed
Open

            return [false, 'Username or password was incorrect'];

Spaces must be used to indent lines; tabs are not allowed
Open

     * $response->addHeader('WWW-Authenticate', 'Basic realm=SabreDAV');

Spaces must be used to indent lines; tabs are not allowed
Open

     * PDO table name we'll be using.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/admin

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/user1

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            return [false, "No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured"];

Line exceeds 120 characters; contains 136 characters
Open

            return [false, "No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured"];

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * WWW-Authenticate headers may already have been set, and you'll want to

Spaces must be used to indent lines; tabs are not allowed
Open

        } else {

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/user1

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/uid/123457

Spaces must be used to indent lines; tabs are not allowed
Open

     * return a string such as:

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param ResponseInterface $response

Spaces must be used to indent lines; tabs are not allowed
Open

            $response

Spaces must be used to indent lines; tabs are not allowed
Open

     * authentication was required for the current request.

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * [false, "reason for failure"]

Spaces must be used to indent lines; tabs are not allowed
Open

     * return a string such as:

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * The returned value must be one of the following

Spaces must be used to indent lines; tabs are not allowed
Open

        return [true, $this->principalPrefix . $userpass[0]];

Spaces must be used to indent lines; tabs are not allowed
Open

     * existing one.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            $auth->requireLogin();

Spaces must be used to indent lines; tabs are not allowed
Open

     * The realm is often displayed by browser clients when showing the

Spaces must be used to indent lines; tabs are not allowed
Open

     * If you don't use WebDAV ACL (RFC3744) we recommend that you simply

Spaces must be used to indent lines; tabs are not allowed
Open

     * [true, "principals/username"]

Spaces must be used to indent lines; tabs are not allowed
Open

    public function checkBasic(RequestInterface $request, ResponseInterface $response)

Spaces must be used to indent lines; tabs are not allowed
Open

        );

Spaces must be used to indent lines; tabs are not allowed
Open

        $userpass = $auth->getCredentials();

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!$userpass) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * authentication dialog.

Spaces must be used to indent lines; tabs are not allowed
Open

    protected $realm = 'YetiDAV';

Spaces must be used to indent lines; tabs are not allowed
Open

     * The returned value must be one of the following

Spaces must be used to indent lines; tabs are not allowed
Open

     * Examples of a principal url:

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/users/joe

Spaces must be used to indent lines; tabs are not allowed
Open

            return $this->checkBasic($request, $response);

Spaces must be used to indent lines; tabs are not allowed
Open

     * If you don't use WebDAV ACL (RFC3744) we recommend that you simply

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/users/[username]

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * When this method is called, the backend must check if authentication was

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/users/joe

Spaces must be used to indent lines; tabs are not allowed
Open

            $request,

Spaces must be used to indent lines; tabs are not allowed
Open

        if (md5($userpass[0] . ':' . $this->realm . ':' . $userpass[1]) !== $hash) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * This method is called when a user could not be authenticated, and

Spaces must be used to indent lines; tabs are not allowed
Open

     * In this case of Basic Auth, this would for example mean that the

Spaces must be used to indent lines; tabs are not allowed
Open

     * Authentication Realm.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * Examples of a principal url:

Spaces must be used to indent lines; tabs are not allowed
Open

     * If authentication was successful, it's expected that the authentication

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * principals/uid/123457

Spaces must be used to indent lines; tabs are not allowed
Open

        $hash = $this->getDigestHash($this->realm, $userpass[0]);

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param RequestInterface  $request

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * [false, "reason for failure"]

Spaces must be used to indent lines; tabs are not allowed
Open

     * following header needs to be set:

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

     * append your own WWW-Authenticate header instead of overwriting the

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            $auth = new HTTP\Auth\Basic(

Spaces must be used to indent lines; tabs are not allowed
Open

     * status code will already be set.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

            $this->realm,

Spaces must be used to indent lines; tabs are not allowed
Open

        if (0 === strpos($request->getHeader('Authorization'), 'Basic')) {

Spaces must be used to indent lines; tabs are not allowed
Open

                $this->realm,

Spaces must be used to indent lines; tabs are not allowed
Open

     * successful.

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param RequestInterface  $request

Spaces must be used to indent lines; tabs are not allowed
Open

        $auth = new HTTP\Auth\Basic(

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * This gives you the opportunity to set authentication headers. The 401

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

                $response

Spaces must be used to indent lines; tabs are not allowed
Open

     * [true, "principals/username"]

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        if (0 === strpos($request->getHeader('Authorization'), 'Basic')) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * successful.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

            );

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * backend returns a so-called principal url.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param ResponseInterface $response

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

There are no issues that match your filters.

Category
Status