|
Revision 7791, 2.7 kB
(checked in by fabien, 5 years ago)
|
updated Sean Kerr email address
|
- Property svn:mime-type set to
text/x-php
- Property svn:eol-style set to
native
- Property svn:keywords set to
Id Rev Date
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
class sfBasicSecurityFilter extends sfSecurityFilter |
|---|
| 24 |
{ |
|---|
| 25 |
|
|---|
| 26 |
* Executes this filter. |
|---|
| 27 |
* |
|---|
| 28 |
* @param sfFilterChain A sfFilterChain instance |
|---|
| 29 |
*/ |
|---|
| 30 |
public function execute($filterChain) |
|---|
| 31 |
{ |
|---|
| 32 |
|
|---|
| 33 |
$context = $this->getContext(); |
|---|
| 34 |
$controller = $context->getController(); |
|---|
| 35 |
$user = $context->getUser(); |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
$actionEntry = $controller->getActionStack()->getLastEntry(); |
|---|
| 39 |
$actionInstance = $actionEntry->getActionInstance(); |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
if ( |
|---|
| 43 |
(sfConfig::get('sf_login_module') == $context->getModuleName()) && (sfConfig::get('sf_login_action') == $context->getActionName()) |
|---|
| 44 |
|| |
|---|
| 45 |
(sfConfig::get('sf_secure_module') == $context->getModuleName()) && (sfConfig::get('sf_secure_action') == $context->getActionName()) |
|---|
| 46 |
) |
|---|
| 47 |
{ |
|---|
| 48 |
$filterChain->execute(); |
|---|
| 49 |
|
|---|
| 50 |
return; |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
$credential = $actionInstance->getCredential(); |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
// where the first index is the privilege name and the second index |
|---|
| 58 |
// is the privilege namespace |
|---|
| 59 |
// |
|---|
| 60 |
// NOTE: the nice thing about the Action class is that getCredential() |
|---|
| 61 |
// is vague enough to describe any level of security and can be |
|---|
| 62 |
// used to retrieve such data and should never have to be altered |
|---|
| 63 |
if ($user->isAuthenticated()) |
|---|
| 64 |
{ |
|---|
| 65 |
|
|---|
| 66 |
if ($credential === null || $user->hasCredential($credential)) |
|---|
| 67 |
{ |
|---|
| 68 |
|
|---|
| 69 |
$filterChain->execute(); |
|---|
| 70 |
} |
|---|
| 71 |
else |
|---|
| 72 |
{ |
|---|
| 73 |
|
|---|
| 74 |
$controller->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); |
|---|
| 75 |
|
|---|
| 76 |
throw new sfStopException(); |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
else |
|---|
| 80 |
{ |
|---|
| 81 |
|
|---|
| 82 |
$controller->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action')); |
|---|
| 83 |
|
|---|
| 84 |
throw new sfStopException(); |
|---|
| 85 |
} |
|---|
| 86 |
} |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|