Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Support 'security' and 'stateless' flags in security config #573

Merged
merged 1 commit into from
Jan 19, 2013
Merged

Support 'security' and 'stateless' flags in security config #573

merged 1 commit into from
Jan 19, 2013

Conversation

gigablah
Copy link
Contributor

@gigablah gigablah commented Jan 5, 2013

'security' => false will disable the firewall (for a particular area) even if there are listeners configured.

'stateless' => true will prevent ContextListener from getting registered.

@davedevelopment
Copy link
Contributor

I'm not sure I understand what you'd use these flags for, perhaps some
documentation would be useful?
On Jan 5, 2013 10:05 AM, "Chris Heng" notifications@github.com wrote:

'security' => false will disable the firewall even if there are listeners
configured.

'stateless' => true will prevent ContextListener from getting registered.

You can merge this Pull Request by running:

git pull https://github.com/gigablah/Silex security-flags

Or view, comment on, or merge it at:

https://github.com/fabpot/Silex/pull/573
Commit Summary

  • Support 'security' and 'stateless' flags in security config

File Changes

  • M src/Silex/Provider/SecurityServiceProvider.php (10)

Patch Links

@gigablah
Copy link
Contributor Author

gigablah commented Jan 5, 2013

These are the same flags you can use in Symfony2. I guess 'security' => false by itself isn't too useful, but you could hypothetically do something like:

$app->register(new SecurityServiceProvider(), array(
    'security.firewalls' => array(
        'api' => array(
            'pattern' => '^/api',
            'stateless' => true,
            'security' => !$app['debug'],
            'oauth' => true
        )
    )
));

Which will (a) turn off oauth access token authentication when you're debugging (b) turn off read/write on the session during authentication, which isn't wanted since the oauth access token is sent for each request.

@davedevelopment
Copy link
Contributor

Sorry, I think I got confused by the security flag, I understand the stateless one.

@stof
Copy link
Contributor

stof commented Jan 6, 2013

The goal of the security flag is to create a firewall pattern without firewall. The only reason for this is to whitelist a pattern by placing it before another pattern without having to create a crazy regex


$protected = count($firewall);
$protected = (false === $security) ? false : count($firewall);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the parenthesis around the condition?

@fabpot
Copy link
Member

fabpot commented Jan 18, 2013

Can you also update the documentation about these two new settings? Thanks.

@gigablah
Copy link
Contributor Author

It's done. Added a section for Stateless Authentication, and a tip for the security flag.

fabpot added a commit that referenced this pull request Jan 19, 2013
This PR was merged into the master branch.

Commits
-------

e21b380 Support 'security' and 'stateless' flags in security config

Discussion
----------

Support 'security' and 'stateless' flags in security config

`'security' => false` will disable the firewall (for a particular area) even if there are listeners configured.

`'stateless' => true` will prevent `ContextListener` from getting registered.

---------------------------------------------------------------------------

by davedevelopment at 2013-01-05T15:01:38Z

I'm not sure I understand what you'd use these flags for, perhaps some
documentation would be useful?
 On Jan 5, 2013 10:05 AM, "Chris Heng" <notifications@github.com> wrote:

> 'security' => false will disable the firewall even if there are listeners
> configured.
>
> 'stateless' => true will prevent ContextListener from getting registered.
> ------------------------------
> You can merge this Pull Request by running:
>
>   git pull https://github.com/gigablah/Silex security-flags
>
> Or view, comment on, or merge it at:
>
>   https://github.com/fabpot/Silex/pull/573
> Commit Summary
>
>    - Support 'security' and 'stateless' flags in security config
>
> File Changes
>
>    - *M* src/Silex/Provider/SecurityServiceProvider.php (10)
>
> Patch Links
>
>    - https://github.com/fabpot/Silex/pull/573.patch
>    - https://github.com/fabpot/Silex/pull/573.diff
>
>  —
> Reply to this email directly or view it on GitHub<https://github.com/fabpot/Silex/pull/573>.
>
>

---------------------------------------------------------------------------

by gigablah at 2013-01-05T15:30:13Z

These are the same flags you can use in Symfony2. I guess `'security' => false` by itself isn't too useful, but you could hypothetically do something like:

```php
$app->register(new SecurityServiceProvider(), array(
    'security.firewalls' => array(
        'api' => array(
            'pattern' => '^/api',
            'stateless' => true,
            'security' => !$app['debug'],
            'oauth' => true
        )
    )
));
```

Which will (a) turn off oauth access token authentication when you're debugging (b) turn off read/write on the session during authentication, which isn't wanted since the oauth access token is sent for each request.

---------------------------------------------------------------------------

by davedevelopment at 2013-01-06T20:48:20Z

Sorry, I think I got confused by the security flag, I understand the stateless one.

---------------------------------------------------------------------------

by stof at 2013-01-06T21:13:04Z

The goal of the ``security`` flag is to create a firewall pattern without firewall. The only reason for this is to whitelist a pattern by placing it before another pattern without having to create a crazy regex

---------------------------------------------------------------------------

by fabpot at 2013-01-18T15:00:19Z

Can you also update the documentation about these two new settings? Thanks.

---------------------------------------------------------------------------

by gigablah at 2013-01-19T04:37:08Z

It's done. Added a section for Stateless Authentication, and a tip for the `security` flag.
@fabpot fabpot merged commit e21b380 into silexphp:master Jan 19, 2013
@gigablah gigablah deleted the security-flags branch January 19, 2013 10:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants