Security Flashcards

https://symfonycasts.com/screencast/symfony-security/passport (19 cards)

1
Q

Which UserProviders does Symfony offer?

A

Entity User Provider

LDAP User Provider

Memory User Provider

Chain User Provider

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which Role does the ROLE_SUPERADMIN have when the following configuration is given?

security:
    # ...

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
A

ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can routes be made accessible only for users with specific roles?

A
security:
    access_control:
        - { path: '^/admin', roles: ROLE_ADMIN }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you deny access from inside a controller?

A
$this->denyAccessUnlessGranted('ROLE_ADMIN');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you use access control inside templates?

A
{% if is_granted('ROLE_ADMIN') %}
    <a href="...">Delete</a>
{% endif %}

or for certain users

{% if is_granted_for_user(user, 'ROLE_ADMIN') %}
    <a href="...">Delete</a>
{% endif %}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you give routes public access for none logged in users?

A
security:
    access_control:
        - { path: ^/admin/login, roles: PUBLIC_ACCESS }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which role does a user get, if hes logged in through the remember me cookie?

A
IS_REMEMBERED
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which role does a user get in impersonation mode?

A
IS_IMPERSONATOR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does csrf mean?

A

Cross site request forgery

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does csrf_protection work?

A
  1. Symonfy adds a hidden token on the form that it generated on server side.
  2. When a form is being submitted, symfony checks if it has a valid token

This will make sure the origin of the submitted form is symfony and therefore the user session is not being abused by another page that perfoms its own request (attack).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you override the method symfony uses to load a user?

A

Add the UserLoaderInterface to the UserRepository and implement the method loadUserByIdentifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you make symfony decide which firewall to use?

A

The first match will apply. Matching can be:

  • url-pattern
  • host
  • http-methods
  • a custom request matcher that the dev can implement (RequestMatcherInterface)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you improve performance even tho many voters are being used?

A

Use a CacheableVoterInterface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can you configure the voters to grant access in case all voters abstain?

A

In security-config:

       'access_decision_manager' => [
            'allow_if_all_abstain' => true,
        ],
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can you configure the voters to grant access in case at least one voter grants access?

A

In security-config:

       'access_decision_manager' => [
            'strategy' => 'affirmative',
        ],
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can you configure the voters to grant access in case there are more voters that grant access than voters that dont?

A

In security-config:

       'access_decision_manager' => [
            'strategy' => 'consensus',
        ],
17
Q

How can you configure the voters to grant access only if there is not a single voter not granting access?

A

In security-config:

       'access_decision_manager' => [
             'strategy' => 'unanimous',
        ],
18
Q

How can you configure the voters to grant access if the first voter that is being asked grants access? (abstain does not count here)

A

In security-config:

       'access_decision_manager' => [
             'strategy' => 'priority',
        ],
19
Q

How can you change the http status that is being returned in case the access is not granted?

A

The method “isGranted” provides an argument for that.