Issues (56)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/User/UserAuthenticator.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php namespace Anomaly\UsersModule\User;
2
3
use Anomaly\Streams\Platform\Addon\Extension\ExtensionCollection;
4
use Anomaly\UsersModule\User\Authenticator\Contract\AuthenticatorExtensionInterface;
5
use Anomaly\UsersModule\User\Contract\UserInterface;
6
use Anomaly\UsersModule\User\Event\UserWasKickedOut;
7
use Anomaly\UsersModule\User\Event\UserWasLoggedIn;
8
use Anomaly\UsersModule\User\Event\UserWasLoggedOut;
9
use Illuminate\Contracts\Auth\Guard;
10
use Illuminate\Contracts\Container\Container;
11
use Illuminate\Contracts\Events\Dispatcher;
12
use Illuminate\Http\RedirectResponse;
13
14
/**
15
 * Class UserAuthenticator
16
 *
17
 * @link   http://pyrocms.com/
18
 * @author PyroCMS, Inc. <[email protected]>
19
 * @author Ryan Thompson <[email protected]>
20
 */
21
class UserAuthenticator
22
{
23
24
    /**
25
     * Laravel's authentication.
26
     *
27
     * @var Guard
28
     */
29
    protected $guard;
30
31
    /**
32
     * The event dispatcher.
33
     *
34
     * @var Dispatcher
35
     */
36
    protected $events;
37
38
    /**
39
     * The service container.
40
     *
41
     * @var Container
42
     */
43
    protected $container;
44
45
    /**
46
     * The extension collection.
47
     *
48
     * @var ExtensionCollection
49
     */
50
    protected $extensions;
51
52
    /**
53
     * Create a new Authenticator instance.
54
     *
55
     * @param Guard               $guard
56
     * @param Dispatcher          $events
57
     * @param Container           $container
58
     * @param ExtensionCollection $extensions
59
     */
60 View Code Duplication
    public function __construct(Guard $guard, Dispatcher $events, Container $container, ExtensionCollection $extensions)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
    {
62
        $this->guard      = $guard;
63
        $this->events     = $events;
64
        $this->container  = $container;
65
        $this->extensions = $extensions;
66
    }
67
68
    /**
69
     * Attempt to login a user.
70
     *
71
     * @param  array $credentials
72
     * @param  bool  $remember
73
     * @return bool|UserInterface
74
     */
75
    public function attempt(array $credentials, $remember = false)
76
    {
77
        if ($response = $this->authenticate($credentials)) {
78
79
            if ($response instanceof UserInterface) {
80
                $this->login($response, $remember);
81
            }
82
83
            return $response;
84
        }
85
86
        return false;
87
    }
88
89
    /**
90
     * Attempt to authenticate the credentials.
91
     *
92
     * @param  array $credentials
93
     * @return bool|UserInterface
94
     */
95
    public function authenticate(array $credentials)
96
    {
97
        $authenticators = $this->extensions->search('anomaly.module.users::authenticator.*');
98
99
        /* @var AuthenticatorExtensionInterface $authenticator */
100
        foreach ($authenticators as $authenticator) {
101
102
            $response = $authenticator->authenticate($credentials);
103
104
            if ($response instanceof UserInterface) {
105
                return $response;
106
            }
107
108
            if ($response instanceof RedirectResponse) {
0 ignored issues
show
The class Illuminate\Http\RedirectResponse does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
109
                return $response;
110
            }
111
        }
112
113
        return false;
114
    }
115
116
    /**
117
     * Force login a user.
118
     *
119
     * @param UserInterface $user
120
     * @param bool          $remember
121
     */
122
    public function login(UserInterface $user, $remember = false)
123
    {
124
        $this->guard->login($user, $remember);
125
126
        $this->events->fire(new UserWasLoggedIn($user));
127
    }
128
129
    /**
130
     * Logout a user.
131
     *
132
     * @param UserInterface $user
133
     */
134
    public function logout(UserInterface $user = null)
135
    {
136
        if (!$user) {
137
            $user = $this->guard->user();
138
        }
139
140
        if (!$user) {
141
            return;
142
        }
143
144
        $this->guard->logout($user);
145
146
        $this->events->fire(new UserWasLoggedOut($user));
147
    }
148
149
    /**
150
     * Kick out a user. They've been bad.
151
     *
152
     * @param UserInterface $user
153
     */
154
    public function kickOut(UserInterface $user, $reason)
155
    {
156
        $this->guard->logout($user);
157
158
        $this->events->fire(new UserWasKickedOut($user, $reason));
159
    }
160
}
161