Skip to content

Kévin Dunglas

Founder of Les-Tilleuls.coop (worker-owned cooperative). Creator of API Platform, Mercure.rocks, Vulcain.rocks and of some Symfony components.

Menu
  • Talks
  • Resume
  • Sponsor me
  • Contact
Menu

Sécuriser tant bien que mal une application Symfony installée dans un sous-répertoire

Posted on December 5, 2012January 12, 2014 by Kévin Dunglas

Souvent, pour des raisons de coups liées aux certificats SSL, il n’est pas possible d’installer une application Symfony dans son propre virtual host. L’application se retrouve alors dans un sous-répertoire du DocumentRoot, ouverte à tous vents et c’est une catastrophe en terme de sécurité !

Imaginons que notre DocumentRoot soit /home/web et que l’application Symfony soit installée dans le répertoire /home/web/my-sf-app/. Ainsi l’URL de l’application est https://example.com/my-sf-app/web. Si un utilisateur mal intentionné accède à https://example.com/my-sf-app/app/config/config.yml il obtient le fichier de configuration principal de l’application qui contient entre-autre les identifiants d’accès à la base de données… Mauvaise idée.

Sécurisons tant bien que mal tout ça (en partant du principe que votre serveur est Apache) grâce aux fichiers de configuration .htaccess :

Le premier, à créer, sera /home/web/my-sf-app/.htaccess et servira à interdire l’accès à tous les fichiers de l’application :

Order allow,deny
Deny from all

Le second, /home/web/my-sf-app/web/.htaccess, existe normalement déjà dans notre application Symfony (il est utilisé pour l’URL rewriting), ajoutons-y au début :

Order allow,deny
Allow from all

Ce n’est toujours pas la panacée, il est toujours aisée de reconnaitre quelle est la technologie employée à la structure des répertoires, mais c’est déjà mieux !

Related posts:

  1. Generate a Symfony password hash from the command line
  2. CoopTilleulsOVHBundle: OVH SDK integration in Symfony
  3. DunglasTodoMVCBundle compatible with Symfony 2.4
  4. Symfony Live 2015 : Construire des applications API-centric avec Symfony

Leave a Reply Cancel reply

Follow me on Twitter

My Tweets

Subscribe to this blog

Recent Posts

  • Read the Linux Manual Pages on Mac and BSD, Directly From the Terminal
  • Ne vous lamentez pas, organisez-vous !
  • FrankenPHP: The Modern Php App Server, written in Go
  • API Platform 3 Is Released!
  • Mercure 0.14: Major Performance Improvement and New Features

Top Posts & Pages

  • Securely Access Private Git Repositories and Composer Packages in Docker Builds
  • JSON Columns and Doctrine DBAL 3 Upgrade
  • Preventing CORS Preflight Requests Using Content Negotiation
  • Generate a Symfony password hash from the command line
  • Symfony's New Native Docker Support (Symfony World)
  • FrankenPHP: The Modern Php App Server, written in Go
  • Goroutines, threads, and thread IDs
  • API Platform 3 Is Released!
  • Connection to a MS SQL Server from Symfony / Doctrine on Mac or Linux
  • Vulcain: HTTP/2 Server Push
 and the rise of client-driven REST APIs

Persistence in PHP with the Doctrine ORM

Persistence in PHP with the Doctrine ORM

Tags

Apache API API Platform Buzz Caddy Docker Doctrine Go Google GraphQL HTTP/2 Hydra hypermedia Hébergement Javascript JSON-LD Kubernetes La Coopérative des Tilleuls Les-Tilleuls.coop Lille Linux Mac Mercure Mercure.rocks Messagerie Instantanée MySQL PHP Punk Rock Python React REST Rock'n'Roll RSS Schema.org Security SEO SEO Symfony Symfony Live Sécurité Ubuntu Web 2.0 Wordpress XHTML XML

Archives

Categories

  • DevOps (25)
  • Mercure (4)
  • Opinions (91)
  • Programming (185)
    • Android (5)
    • Go (13)
    • JavaScript (43)
    • PHP (143)
      • API Platform (65)
      • Symfony (89)
    • Python (14)
      • Django (5)
  • Security (15)
  • SEO (24)
  • Talks (39)
  • Ubuntu (68)
  • Wordpress (6)

Social

  • Mastodon
  • Twitter
  • LinkedIn
  • YouTube
  • GitHub

Links

  • API Platform
  • Les-Tilleuls.coop
  • Mercure.rocks
  • Vulcain.rocks
© 2023 Kévin Dunglas | Powered by Minimalist Blog WordPress Theme