JMSSecurityExtraBundle icon indicating copy to clipboard operation
JMSSecurityExtraBundle copied to clipboard

ConfigDriver enhancements

Open cblegare opened this issue 11 years ago • 1 comments

Replaces PR #147 having made a mess in commits. Recent commits in upstream repo have been merged.

Instead of defaulting DI-configuration of method access control to equivalent of PreAuthorize annotation, this pull request provides support for more specific method access control policies.

DI configuration entries can now use the following configuration keys

  • pre_authorize
  • secure
  • secure_param
  • secure_return
  • run_as

and use them in the same way they are used with annotations.

Here is an example of valid YAML DI configuration

jms_security_extra:
    # ...
    method_access_control:

        # retro-compatible with good'ol DI configuration
        'UserManager::delete$': 'hasRole("FOO")'
        'TestBundle:Crud:add': 'hasRole("FOO")'
        'TestBundle:Foo:exception': 'permitAll'
        'TestBundle:Foo:.*': 'hasRole("MOO")'

        # key may be anything.  
        # It is not used if 'pattern' is set
        AdvancedConfig:                                  
            pattern: 'TestBundle:Crud:delete$'
            pre_authorize: 'hasRole("FOO")'
        -
            pattern: 'TestBundle:*'
            secure_return: 
                roles:
                    - ROLE_SUPERADMIN
        'SecretSecureService::secure*'    # Name stands as 'pattern' if needed
             run_as: 'ROLE_NINJA'

This pull request fully solves

  • Issue #142 and #143
  • Issue #140

This pull request hacks around

  • Issue #145

cblegare avatar Jan 06 '14 20:01 cblegare

looks like you messed your rebase: you merge your rebased branch with your older branch instead of forcing the push

stof avatar Jan 09 '14 20:01 stof