Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
34ee58ac
Commit
34ee58ac
authored
Sep 22, 2014
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do some more injection on filters.
parent
4e5a1517
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
53 deletions
+104
-53
app/Http/Filters/AuthFilter.php
+51
-22
app/Http/Filters/BasicAuthFilter.php
+21
-4
app/Http/Filters/CsrfFilter.php
+2
-3
app/Http/Filters/GuestFilter.php
+0
-21
app/Http/Filters/MaintenanceFilter.php
+30
-3
No files found.
app/Http/Filters/AuthFilter.php
View file @
34ee58ac
...
...
@@ -2,30 +2,59 @@
use
Illuminate\Http\Request
;
use
Illuminate\Routing\Route
;
use
Auth
,
Redirect
,
Response
;
use
Illuminate\Contracts\Auth\Authenticator
;
use
Illuminate\Contracts\Routing\ResponseFactory
;
class
AuthFilter
{
/**
* Run the request filter.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public
function
filter
(
Route
$route
,
Request
$request
)
{
if
(
Auth
::
guest
())
{
if
(
$request
->
ajax
())
{
return
Response
::
make
(
'Unauthorized'
,
401
);
}
else
{
return
Redirect
::
guest
(
'auth/login'
);
}
}
}
/**
* The authenticator implementation.
*
* @var Authenticator
*/
protected
$auth
;
/**
* The response factory implementation.
*
* @var ResponseFactory
*/
protected
$response
;
/**
* Create a new filter instance.
*
* @param Authenticator $auth
* @param ResponseFactory $response
* @return void
*/
public
function
__construct
(
Authenticator
$auth
,
ResponseFactory
$response
)
{
$this
->
auth
=
$auth
;
$this
->
response
=
$response
;
}
/**
* Run the request filter.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public
function
filter
(
Route
$route
,
Request
$request
)
{
if
(
$this
->
auth
->
guest
())
{
if
(
$request
->
ajax
())
{
return
$this
->
response
->
make
(
'Unauthorized'
,
401
);
}
else
{
return
$this
->
response
->
redirectGuest
(
'auth/login'
);
}
}
}
}
app/Http/Filters/BasicAuthFilter.php
View file @
34ee58ac
<?php
namespace
App\Http\Filters
;
use
Auth
;
use
Illuminate\Contracts\Auth\Authenticator
;
class
BasicAuthFilter
{
/**
* The authenticator implementation.
*
* @var Authenticator
*/
protected
$auth
;
/**
* Create a new filter instance.
*
* @param Authenticator $auth
* @return void
*/
public
function
__construct
(
Authenticator
$auth
)
{
$this
->
auth
=
$auth
;
}
/**
* Run the request filter.
*
* @return mixed
*/
public
function
filter
()
{
return
Auth
::
basic
();
return
$this
->
auth
->
basic
();
}
}
\ No newline at end of file
}
app/Http/Filters/CsrfFilter.php
View file @
34ee58ac
<?php
namespace
App\Http\Filters
;
use
Session
;
use
Illuminate\Http\Request
;
use
Illuminate\Routing\Route
;
use
Illuminate\Session\TokenMismatchException
;
...
...
@@ -13,12 +12,12 @@ class CsrfFilter {
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @return void
*
*
* @throws \Illuminate\Session\TokenMismatchException
*/
public
function
filter
(
Route
$route
,
Request
$request
)
{
if
(
Session
::
token
()
!=
$request
->
input
(
'_token'
))
if
(
$request
->
getSession
()
->
token
()
!=
$request
->
input
(
'_token'
))
{
throw
new
TokenMismatchException
;
}
...
...
app/Http/Filters/GuestFilter.php
deleted
100644 → 0
View file @
4e5a1517
<?php
namespace
App\Http\Filters
;
use
Auth
,
Redirect
;
class
GuestFilter
{
/**
* Run the request filter.
*
* @return mixed
*/
public
function
filter
()
{
if
(
Auth
::
check
())
{
return
Redirect
::
to
(
'/'
);
}
}
}
\ No newline at end of file
app/Http/Filters/MaintenanceFilter.php
View file @
34ee58ac
<?php
namespace
App\Http\Filters
;
use
App
,
Response
;
use
Illuminate\Contracts\Foundation\Application
;
use
Illuminate\Contracts\Routing\ResponseFactory
;
class
MaintenanceFilter
{
/**
* The application implementation.
*
* @var Application
*/
protected
$app
;
/**
* The response factory implementation.
*
* @var ResponseFactory
*/
protected
$response
;
/**
* Create a new filter instance.
*
* @param Application $app
* @return void
*/
public
function
__construct
(
Application
$app
,
ResponseFactory
$response
)
{
$this
->
app
=
$app
;
$this
->
response
=
$response
;
}
/**
* Run the request filter.
*
* @return mixed
*/
public
function
filter
()
{
if
(
App
::
isDownForMaintenance
())
if
(
$this
->
app
->
isDownForMaintenance
())
{
return
Response
::
make
(
'Be right back!'
);
return
$this
->
response
->
make
(
'Be right back!'
,
503
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment