Skip to content

Instantly share code, notes, and snippets.

@andreybolonin
Created August 21, 2019 07:44
Show Gist options
  • Save andreybolonin/008ba603b642b0178d2178008d5d2e1b to your computer and use it in GitHub Desktop.
Save andreybolonin/008ba603b642b0178d2178008d5d2e1b to your computer and use it in GitHub Desktop.
security.yaml
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
class: App\Entity\User
property: username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/article
anonymous: ~
# http_basic: ~
# activate different ways to authenticate
# http_basic: true
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
# form_login: true
# https://symfony.com/doc/current/security/form_login_setup.html
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
# - { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }
- { path: ^/article/login, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/article/logout, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/article, roles: ROLE_ADMIN }
encoders:
# Symfony\Component\Security\Core\User\User: plaintext
App\Entity\User:
algorithm: argon2i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment