Issues (103)

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.

app/controllers/AuthController.php (1 issue)

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
2
3
class AuthController extends PageController {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
	/**
6
	 * Page to show if user hasn't logged it but hit by auth filter
7
	 */
8
	public function loginPage() {
9
		$this->layout->title = 'Login';
10
		$this->layout->content = View::make('login');
11
	}
12
13
	/**
14
	 * Login with persona
15
	 *
16
	 * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
17
	 */
18
	public function login() {
19
		/* Force logout */
20
		if (! Auth::guest()) {
21
			Auth::logout();
22
		}
23
24
		if (! $assertion = Input::get("assertion")) {
25
			App::abort(401, 'i don\'t even');
26
		}
27
		// Check with persona
28
		try {
29
			$response = GuzzleHttp\post(
30
				'https://verifier.login.persona.org/verify',
31
				[
32
					'body' => [
33
						'assertion' => $assertion,
34
						'audience'  => url(),
35
					],
36
				]
37
			);
38
		} catch (GuzzleHttp\Exception\BadResponseException $e) {
39
			App::abort(401, 'You are not authorized.');
40
41
			return false;
42
		}
43
44
		$verification = $response->json();
45
		if ($verification['status'] != "okay") {
46
			App::abort(401, 'You are not authorized.');
47
48
			return false;
49
		}
50
		$email = $verification['email'];
51
52
		// Log in to laravel
53
		if (Auth::attempt(['email' => $email, 'password' => 'moz:persona'], true)) {
54
			if (Request::ajax()) {
55
				if(Session::has('url.intended')) {
56
					return Response::json(['redirect' => Session::get('url.intended')]);
57
				} else {
58
					return Response::json(['refresh' => true]);
59
				}
60
			} else {
61
				return Redirect::intended();
62
			}
63
		} else {
64
			// Not an user
65
			Session::put('register_email', $email);
66
			if (Request::ajax()) {
67
				return Response::json(['redirect' => route('auth.register')]);
68
			} else {
69
				return Redirect::route('auth.register.form');
70
			}
71
		}
72
73
	}
74
75
	/**
76
	 * Logout
77
	 *
78
	 * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
79
	 */
80
	public function logout() {
81
		if (Session::has("register_email")) {
82
			Session::forget("register_email");
83
		}
84
85
		Auth::logout();
86
87
		if (Request::ajax()) {
88
			return Response::json(["redirect" => url("/")]);
89
		} else {
90
			return Redirect::to("/");
91
		}
92
	}
93
94
	/**
95
	 * Registration validation rules
96
	 * @var array
97
	 */
98
	public $register_valid_rules = [
99
		'username'    => ['required', 'unique:users', 'min:2', 'max:16'],
100
		'displayname' => ['max:64'],
101
	];
102
103
	/**
104
	 * Registration form
105
	 *
106
	 * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
107
	 */
108
	public function registerForm() {
109
		if (! Session::has('register_email')) {
110
			return Redirect::home();
111
		}
112
113
		$this->layout->content = View::make("register", [
114
			'validation_rules' => $this->register_valid_rules,
115
			'email'            => Session::get('register_email'),
116
		]);
117
118
		return $this->layout;
119
	}
120
121
	/**
122
	 * Registration handler
123
	 *
124
	 * @return $this|\Illuminate\Http\RedirectResponse
125
	 */
126
	public function register() {
127
		if (! Session::has('register_email')) {
128
			return Redirect::home();
129
		}
130
131
		// Validate
132
		$validator = Validator::make(Input::all(), $this->register_valid_rules);
133
		if ($validator->fails()) {
134
			Notification::error("Something's wrong, check the fields bellow!");
135
136
			return Redirect::back()->withInput()->withErrors($validator);
137
		}
138
139
		// Create user
140
		$user = new User();
141
		$user->username = Input::get('username');
142
		$user->displayname = Input::get('displayname');
143
		$user->email = Session::get('register_email');
144
145
		// Save & Login
146
		if ($user->save()) {
147
			Auth::login($user, true);
148
			Session::forget('register_email');
149
150
			Notification::success("Welcome {$user->name}!");
151
152
			return Redirect::intended('/');
153
		} else {
154
			Notification::error("Save errors :'(");
155
156
			return Redirect::to('register')->withInput();
157
		}
158
	}
159
}