Issues (29)

Security Analysis    not enabled

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.

Repositories/Sentry/SentryAuthentication.php (8 issues)

Labels
Severity

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 Modules\User\Repositories\Sentry;
2
3
use Cartalyst\Sentry\Facades\Laravel\Sentry;
4
use Cartalyst\Sentry\Throttling\UserBannedException;
5
use Cartalyst\Sentry\Throttling\UserSuspendedException;
6
use Cartalyst\Sentry\Users\LoginRequiredException;
7
use Cartalyst\Sentry\Users\PasswordRequiredException;
8
use Cartalyst\Sentry\Users\UserNotActivatedException;
9
use Cartalyst\Sentry\Users\UserNotFoundException;
10
use Cartalyst\Sentry\Users\WrongPasswordException;
11
use Modules\Core\Contracts\Authentication;
12
use Modules\User\Events\UserHasActivatedAccount;
13
14
class SentryAuthentication implements Authentication
15
{
16
    /**
17
     * Authenticate a user
18
     * @param  array $credentials
19
     * @param  bool  $remember    Remember the user
20
     * @return mixed
21
     */
22
    public function login(array $credentials, $remember = false)
23
    {
24
        try {
25
            Sentry::authenticate($credentials, $remember);
26
27
            return false;
28
        } catch (LoginRequiredException $e) {
0 ignored issues
show
The class Cartalyst\Sentry\Users\LoginRequiredException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
29
            return 'Login field is required.';
30
        } catch (PasswordRequiredException $e) {
0 ignored issues
show
The class Cartalyst\Sentry\Users\PasswordRequiredException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
31
            return 'Password field is required.';
32
        } catch (WrongPasswordException $e) {
0 ignored issues
show
The class Cartalyst\Sentry\Users\WrongPasswordException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
33
            return 'Wrong password, try again.';
34
        } catch (UserNotFoundException $e) {
0 ignored issues
show
The class Cartalyst\Sentry\Users\UserNotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
35
            return 'User was not found.';
36
        } catch (UserNotActivatedException $e) {
0 ignored issues
show
The class Cartalyst\Sentry\Users\UserNotActivatedException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
37
            return 'User is not activated.';
38
        } catch (UserSuspendedException $e) {
0 ignored issues
show
The class Cartalyst\Sentry\Throttling\UserSuspendedException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
39
            return 'User is suspended.';
40
        } catch (UserBannedException $e) {
0 ignored issues
show
The class Cartalyst\Sentry\Throttling\UserBannedException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
41
            return 'User is banned.';
42
        }
43
    }
44
45
    /**
46
     * Register a new user.
47
     * @param  array $user
48
     * @return bool
49
     */
50
    public function register(array $user)
51
    {
52
        return Sentry::register($user);
53
    }
54
55
    /**
56
     * Activate the given used id
57
     * @param  int    $userId
58
     * @param  string $code
59
     * @return bool
60
     */
61
    public function activate($userId, $code)
62
    {
63
        $user = Sentry::findUserById($userId);
64
65
        try {
66
            $success = $user->attemptActivation($code);
67
            if ($success) {
68
                event(new UserHasActivatedAccount($user));
69
            }
70
71
            return $success;
72
        } catch (\Exception $e) {
73
            return false;
74
        }
75
    }
76
77
    /**
78
     * Assign a role to the given user.
79
     * @param  \Modules\User\Repositories\UserRepository $user
80
     * @param  \Modules\User\Repositories\RoleRepository $role
81
     * @return mixed
82
     */
83
    public function assignRole($user, $role)
84
    {
85
        return $role->users()->attach($user);
0 ignored issues
show
The method users() does not seem to exist on object<Modules\User\Repositories\RoleRepository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
86
    }
87
88
    /**
89
     * Log the user out of the application.
90
     * @return mixed
91
     */
92
    public function logout()
93
    {
94
        return Sentry::logout();
95
    }
96
97
    /**
98
     * Create an activation code for the given user
99
     * @param $user
100
     * @return mixed
101
     */
102
    public function createActivation($user)
103
    {
104
        return $user->getActivationCode();
105
    }
106
107
    /**
108
     * Create a reminders code for the given user
109
     * @param $user
110
     * @return mixed
111
     */
112
    public function createReminderCode($user)
113
    {
114
        return $user->getResetPasswordCode();
115
    }
116
117
    /**
118
     * Completes the reset password process
119
     * @param $user
120
     * @param  string $code
121
     * @param  string $password
122
     * @return bool
123
     */
124
    public function completeResetPassword($user, $code, $password)
125
    {
126
        return $user->attemptResetPassword($code, $password);
127
    }
128
129
    /**
130
     * Determines if the current user has access to given permission
131
     * @param $permission
132
     * @return bool
133
     */
134
    public function hasAccess($permission)
135
    {
136
        $user = Sentry::getUser();
137
138
        if (is_null($user)) {
139
            return false;
140
        }
141
142
        return $user->hasAccess($permission);
143
    }
144
145
    /**
146
     * Check if the user is logged in
147
     * @return mixed
148
     */
149
    public function check()
150
    {
151
        if (Sentry::check()) {
152
            return Sentry::getUser();
153
        }
154
155
        return false;
156
    }
157
158
    /**
159
     * Get the ID for the currently authenticated user
160
     * @return int
161
     */
162
    public function id()
163
    {
164
        if (! $user = $this->check()) {
165
            return;
166
        }
167
168
        return $user->id;
169
    }
170
}
171