Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
e408ca41
Commit
e408ca41
authored
Jun 19, 2012
by
Dave Marshall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pulled standard auth mechanisms in to extendable factories
parent
8150e2ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
32 deletions
+38
-32
src/Silex/Provider/SecurityServiceProvider.php
src/Silex/Provider/SecurityServiceProvider.php
+38
-32
No files found.
src/Silex/Provider/SecurityServiceProvider.php
View file @
e408ca41
...
...
@@ -117,6 +117,28 @@ class SecurityServiceProvider implements ServiceProviderInterface
);
});
$app
[
'security.authentication.factory._proto'
]
=
$app
->
protect
(
function
(
$name
,
$options
,
$type
,
$entryPoint
=
'form'
)
use
(
$app
)
{
if
(
!
isset
(
$app
[
'security.authentication.'
.
$name
.
'.'
.
$type
]))
{
if
(
!
isset
(
$app
[
'security.entry_point.'
.
$entryPoint
.
'.'
.
$name
]))
{
$app
[
'security.entry_point.'
.
$entryPoint
.
'.'
.
$name
]
=
$app
[
'security.entry_point.'
.
$entryPoint
.
'._proto'
](
$name
);
}
$app
[
'security.authentication.'
.
$name
.
'.'
.
$type
]
=
$app
[
'security.authentication.'
.
$type
.
'._proto'
](
$name
,
$options
);
}
return
$app
[
'security.authentication.'
.
$name
.
'.'
.
$type
];
});
foreach
(
array
(
'logout'
,
'pre_auth'
,
'form'
,
'http'
,
'remember_me'
,
'anonymous'
)
as
$type
)
{
$entryPoint
=
$type
==
'http'
?
'http'
:
'form'
;
$app
[
'security.authentication.factory.'
.
$type
]
=
$app
->
protect
(
function
(
$name
,
$options
)
use
(
$type
,
$app
,
$entryPoint
)
{
$app
[
'security.authentication.'
.
$name
.
'.'
.
$type
]
=
$app
[
'security.authentication.factory._proto'
](
$name
,
$options
,
$type
,
$entryPoint
);
return
array
(
$app
[
'security.authentication.'
.
$name
.
'.'
.
$type
],
$entryPoint
);
});
}
$app
[
'security.firewall_map'
]
=
$app
->
share
(
function
()
use
(
$app
)
{
$map
=
new
FirewallMap
();
$entryPoint
=
'form'
;
...
...
@@ -142,49 +164,33 @@ class SecurityServiceProvider implements ServiceProviderInterface
}
$listeners
[]
=
$app
[
'security.context_listener.'
.
$name
];
}
if
(
count
(
$firewall
))
{
foreach
(
array
(
'logout'
,
'pre_auth'
,
'form'
,
'http'
,
'remember_me'
,
'anonymous'
)
as
$type
)
{
if
(
isset
(
$firewall
[
$type
]))
{
$options
=
$firewall
[
$type
];
// normalize options
if
(
!
is_array
(
$options
))
{
if
(
!
$options
)
{
continue
;
}
foreach
(
$firewall
as
$type
=>
$options
)
{
$options
=
array
();
// normalize options
if
(
!
is_array
(
$options
))
{
if
(
!
$options
)
{
continue
;
}
if
(
'http'
==
$type
)
{
$entryPoint
=
'http'
;
}
if
(
!
isset
(
$app
[
'security.authentication.'
.
$name
.
'.'
.
$type
]))
{
if
(
!
isset
(
$app
[
'security.entry_point.'
.
$entryPoint
.
'.'
.
$name
]))
{
$app
[
'security.entry_point.'
.
$entryPoint
.
'.'
.
$name
]
=
$app
[
'security.entry_point.'
.
$entryPoint
.
'._proto'
](
$name
);
}
$app
[
'security.authentication.'
.
$name
.
'.'
.
$type
]
=
$app
[
'security.authentication.'
.
$type
.
'._proto'
](
$name
,
$options
);
}
$options
=
array
();
}
$listeners
[]
=
$app
[
'security.authentication.'
.
$name
.
'.'
.
$type
];
if
(
isset
(
$app
[
'security.authentication.factory.'
.
$type
]))
{
list
(
$listener
,
$entryPoint
)
=
$app
[
'security.authentication.factory.'
.
$type
](
$name
,
$options
);
$listeners
[]
=
$listener
;
}
}
if
(
$protected
)
{
$listeners
[]
=
$app
[
'security.access_listener'
];
$listeners
[]
=
$app
[
'security.access_listener'
];
if
(
isset
(
$firewall
[
'switch_user'
]))
{
$listeners
[]
=
$app
[
'security.authentication.switch_user._proto'
](
$name
,
$firewall
[
'switch_user'
]);
}
if
(
isset
(
$firewall
[
'switch_user'
]))
{
$listeners
[]
=
$app
[
'security.authentication.switch_user._proto'
](
$name
,
$firewall
[
'switch_user'
]);
}
}
if
(
$protected
&&
!
isset
(
$app
[
'security.exception_listener.'
.
$name
]))
{
$app
[
'security.exception_listener.'
.
$name
]
=
$app
[
'security.exception_listener._proto'
](
$entryPoint
,
$name
);
if
(
!
isset
(
$app
[
'security.exception_listener.'
.
$name
]))
{
$app
[
'security.exception_listener.'
.
$name
]
=
$app
[
'security.exception_listener._proto'
](
$entryPoint
,
$name
);
}
}
$map
->
add
(
...
...
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