Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
d2937ea7
Commit
d2937ea7
authored
Oct 06, 2014
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on stack.
parent
2893433b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
125 additions
and
61 deletions
+125
-61
AuthMiddleware.php
app/Http/Middleware/AuthMiddleware.php
+11
-8
BasicAuthMiddleware.php
app/Http/Middleware/BasicAuthMiddleware.php
+39
-0
CsrfMiddleware.php
app/Http/Middleware/CsrfMiddleware.php
+26
-0
GuestMiddleware.php
app/Http/Middleware/GuestMiddleware.php
+12
-6
MaintenanceMiddleware.php
app/Http/Middleware/MaintenanceMiddleware.php
+11
-5
AppServiceProvider.php
app/Providers/AppServiceProvider.php
+26
-4
FilterServiceProvider.php
app/Providers/FilterServiceProvider.php
+0
-37
app.php
config/app.php
+0
-1
No files found.
app/Http/
Filters/AuthFilter
.php
→
app/Http/
Middleware/AuthMiddleware
.php
View file @
d2937ea7
<?php
namespace
App\Http\
Filters
;
<?php
namespace
App\Http\
Middleware
;
use
Illuminate\Http\Request
;
use
Closure
;
use
Illuminate\Routing\Route
;
use
Illuminate\Routing\Route
;
use
Illuminate\Contracts\Auth\Authenticator
;
use
Illuminate\Contracts\Auth\Authenticator
;
use
Illuminate\Contracts\Routing\Middleware
;
use
Illuminate\Contracts\Routing\ResponseFactory
;
use
Illuminate\Contracts\Routing\ResponseFactory
;
class
Auth
Filter
{
class
Auth
Middleware
implements
Middleware
{
/**
/**
* The authenticator implementation.
* The authenticator implementation.
...
@@ -36,13 +37,13 @@ class AuthFilter {
...
@@ -36,13 +37,13 @@ class AuthFilter {
}
}
/**
/**
*
Run the request filter
.
*
Handle an incoming request
.
*
*
* @param \
Illuminate\Routing\Route $route
* @param \
Symfony\Component\HttpFoundation\Request $request
* @param \
Illuminate\Http\Request $reques
t
* @param \
Closure $nex
t
* @return
mixed
* @return
\Symfony\Component\HttpFoundation\Response
*/
*/
public
function
filter
(
Route
$route
,
Request
$reques
t
)
public
function
handle
(
$request
,
Closure
$nex
t
)
{
{
if
(
$this
->
auth
->
guest
())
if
(
$this
->
auth
->
guest
())
{
{
...
@@ -55,6 +56,8 @@ class AuthFilter {
...
@@ -55,6 +56,8 @@ class AuthFilter {
return
$this
->
response
->
redirectGuest
(
'auth/login'
);
return
$this
->
response
->
redirectGuest
(
'auth/login'
);
}
}
}
}
return
$next
(
$request
);
}
}
}
}
app/Http/
Filters/BasicAuthFilter
.php
→
app/Http/
Middleware/BasicAuthMiddleware
.php
View file @
d2937ea7
<?php
namespace
App\Http\
Filters
;
<?php
namespace
App\Http\
Middleware
;
use
Closure
;
use
Illuminate\Contracts\Routing\Middleware
;
use
Illuminate\Contracts\Auth\Authenticator
;
use
Illuminate\Contracts\Auth\Authenticator
;
class
BasicAuth
Filter
{
class
BasicAuth
Middleware
implements
Middleware
{
/**
/**
* The authenticator implementation.
* The authenticator implementation.
...
@@ -23,13 +25,15 @@ class BasicAuthFilter {
...
@@ -23,13 +25,15 @@ class BasicAuthFilter {
}
}
/**
/**
*
Run the request filter
.
*
Handle an incoming request
.
*
*
* @return mixed
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response
*/
*/
public
function
filter
(
)
public
function
handle
(
$request
,
Closure
$next
)
{
{
return
$this
->
auth
->
basic
();
return
$this
->
auth
->
basic
()
?:
$next
(
$request
)
;
}
}
}
}
app/Http/
Filters/CsrfFilter
.php
→
app/Http/
Middleware/CsrfMiddleware
.php
View file @
d2937ea7
<?php
namespace
App\Http\
Filters
;
<?php
namespace
App\Http\
Middleware
;
use
Illuminate\Http\Request
;
use
Closure
;
use
Illuminate\
Routing\Rout
e
;
use
Illuminate\
Contracts\Routing\Middlewar
e
;
use
Illuminate\Session\TokenMismatchException
;
use
Illuminate\Session\TokenMismatchException
;
class
Csrf
Filter
{
class
Csrf
Middleware
implements
Middleware
{
/**
/**
*
Run the request filter
.
*
Handle an incoming request
.
*
*
* @param \Illuminate\Routing\Route $route
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return void
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Illuminate\Session\TokenMismatchException
*/
*/
public
function
filter
(
Route
$route
,
Request
$reques
t
)
public
function
handle
(
$request
,
Closure
$nex
t
)
{
{
if
(
$request
->
getSession
()
->
token
()
!=
$request
->
input
(
'_token'
))
if
(
$request
->
getSession
()
->
token
()
!=
$request
->
input
(
'_token'
))
{
{
throw
new
TokenMismatchException
;
throw
new
TokenMismatchException
;
}
}
return
$next
(
$request
);
}
}
}
}
app/Http/
Filters/GuestFilter
.php
→
app/Http/
Middleware/GuestMiddleware
.php
View file @
d2937ea7
<?php
namespace
App\Http\
Filters
;
<?php
namespace
App\Http\
Middleware
;
use
Illuminate\Contracts\Auth\Authenticator
;
use
Closure
;
use
Illuminate\Http\RedirectResponse
;
use
Illuminate\Http\RedirectResponse
;
use
Illuminate\Contracts\Auth\Authenticator
;
use
Illuminate\Contracts\Routing\Middleware
;
class
Guest
Filter
{
class
Guest
Middleware
implements
Middleware
{
/**
/**
* The authenticator implementation.
* The authenticator implementation.
...
@@ -24,16 +26,20 @@ class GuestFilter {
...
@@ -24,16 +26,20 @@ class GuestFilter {
}
}
/**
/**
*
Run the request filter
.
*
Handle an incoming request
.
*
*
* @return mixed
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response
*/
*/
public
function
filter
(
)
public
function
handle
(
$request
,
Closure
$next
)
{
{
if
(
$this
->
auth
->
check
())
if
(
$this
->
auth
->
check
())
{
{
return
new
RedirectResponse
(
url
(
'/'
));
return
new
RedirectResponse
(
url
(
'/'
));
}
}
return
$next
(
$request
);
}
}
}
}
app/Http/
Filters/MaintenanceFilter
.php
→
app/Http/
Middleware/MaintenanceMiddleware
.php
View file @
d2937ea7
<?php
namespace
App\Http\
Filters
;
<?php
namespace
App\Http\
Middleware
;
use
Closure
;
use
Illuminate\Http\Response
;
use
Illuminate\Http\Response
;
use
Illuminate\Contracts\Routing\Middleware
;
use
Illuminate\Contracts\Foundation\Application
;
use
Illuminate\Contracts\Foundation\Application
;
class
Maintenance
Filter
{
class
Maintenance
Middleware
{
/**
/**
* The application implementation.
* The application implementation.
...
@@ -24,16 +26,20 @@ class MaintenanceFilter {
...
@@ -24,16 +26,20 @@ class MaintenanceFilter {
}
}
/**
/**
*
Run the request filter
.
*
Handle an incoming request
.
*
*
* @return mixed
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response
*/
*/
public
function
filter
(
)
public
function
handle
(
$request
,
Closure
$next
)
{
{
if
(
$this
->
app
->
isDownForMaintenance
())
if
(
$this
->
app
->
isDownForMaintenance
())
{
{
return
new
Response
(
'Be right back!'
,
503
);
return
new
Response
(
'Be right back!'
,
503
);
}
}
return
$next
(
$request
);
}
}
}
}
app/Providers/AppServiceProvider.php
View file @
d2937ea7
...
@@ -6,6 +6,31 @@ use Illuminate\Routing\Stack\Builder as Stack;
...
@@ -6,6 +6,31 @@ use Illuminate\Routing\Stack\Builder as Stack;
class
AppServiceProvider
extends
ServiceProvider
{
class
AppServiceProvider
extends
ServiceProvider
{
/**
* All of the application's route middleware keys.
*
* @var array
*/
protected
$middleware
=
[
'auth'
=>
'App\Http\Middleware\AuthMiddleware'
,
'auth.basic'
=>
'App\Http\Middleware\BasicAuthMiddleware'
,
'csrf'
=>
'App\Http\Middleware\CsrfMiddleware'
,
'guest'
=>
'App\Http\Middleware\GusetMiddleware'
,
];
/**
* The application's middleware stack.
*
* @var array
*/
protected
$stack
=
[
'App\Http\Middleware\MaintenanceMiddleware'
,
'Illuminate\Cookie\Guard'
,
'Illuminate\Cookie\Queue'
,
'Illuminate\Session\Middleware\Reader'
,
'Illuminate\Session\Middleware\Writer'
,
];
/**
/**
* Bootstrap any necessary services.
* Bootstrap any necessary services.
*
*
...
@@ -20,10 +45,7 @@ class AppServiceProvider extends ServiceProvider {
...
@@ -20,10 +45,7 @@ class AppServiceProvider extends ServiceProvider {
$this
->
app
->
stack
(
function
(
Stack
$stack
,
Router
$router
)
$this
->
app
->
stack
(
function
(
Stack
$stack
,
Router
$router
)
{
{
return
$stack
return
$stack
->
middleware
(
'Illuminate\Cookie\Guard'
)
->
middleware
(
$this
->
stack
)
->
middleware
(
'Illuminate\Cookie\Queue'
)
->
middleware
(
'Illuminate\Session\Middlewares\Reader'
)
->
middleware
(
'Illuminate\Session\Middlewares\Writer'
)
->
then
(
function
(
$request
)
use
(
$router
)
->
then
(
function
(
$request
)
use
(
$router
)
{
{
return
$router
->
dispatch
(
$request
);
return
$router
->
dispatch
(
$request
);
...
...
app/Providers/FilterServiceProvider.php
deleted
100644 → 0
View file @
2893433b
<?php
namespace
App\Providers
;
use
Illuminate\Foundation\Support\Providers\FilterServiceProvider
as
ServiceProvider
;
class
FilterServiceProvider
extends
ServiceProvider
{
/**
* The filters that should run before all requests.
*
* @var array
*/
protected
$before
=
[
'App\Http\Filters\MaintenanceFilter'
,
];
/**
* The filters that should run after all requests.
*
* @var array
*/
protected
$after
=
[
//
];
/**
* All available route filters.
*
* @var array
*/
protected
$filters
=
[
'auth'
=>
'App\Http\Filters\AuthFilter'
,
'auth.basic'
=>
'App\Http\Filters\BasicAuthFilter'
,
'csrf'
=>
'App\Http\Filters\CsrfFilter'
,
'guest'
=>
'App\Http\Filters\GuestFilter'
,
];
}
config/app.php
View file @
d2937ea7
...
@@ -102,7 +102,6 @@ return [
...
@@ -102,7 +102,6 @@ return [
'App\Providers\ArtisanServiceProvider'
,
'App\Providers\ArtisanServiceProvider'
,
'App\Providers\ErrorServiceProvider'
,
'App\Providers\ErrorServiceProvider'
,
'App\Providers\EventServiceProvider'
,
'App\Providers\EventServiceProvider'
,
'App\Providers\FilterServiceProvider'
,
'App\Providers\LogServiceProvider'
,
'App\Providers\LogServiceProvider'
,
'App\Providers\RouteServiceProvider'
,
'App\Providers\RouteServiceProvider'
,
...
...
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