Skip to content

Commit

Permalink
1284: Added PethPrefix scope to traefik rules to allow co-hosting wit…
Browse files Browse the repository at this point in the history
…h legacy eventdb
  • Loading branch information
turegjorup committed May 3, 2024
1 parent 5f85e2a commit 6b77d82
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 5 additions & 4 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ security:
security: false
main:
form_login:
login_path: app_login
check_path: app_login
login_path: app_admin_login
check_path: app_admin_login
enable_csrf: true

logout:
path: app_logout
target: app_login
path: app_admin_logout
target: app_admin_login

# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true

# 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/login, , roles: PUBLIC_ACCESS }
- { path: ^/admin, roles: !php/enum App\Types\UserRoles::ROLE_API_USER->value }
# - { path: ^/profile, roles: ROLE_USER }

Expand Down
8 changes: 8 additions & 0 deletions docker-compose.server.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ services:
volumes:
- "./.docker/data/rabbit:/var/lib/rabbitmq/mnesia"

nginx:
labels:
# Scope hosting by path prefix to allow shared hosting with legacy EventDB
# 'https://api.detskeriaarhus.dk/easyadmin/' -> Legacy EventDB
# 'https://api.detskeriaarhus.dk/admin/' -> EventDB v2
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-http.rule=Host(`${COMPOSE_SERVER_DOMAIN}`) && PathPrefix(`/admin`)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_SERVER_DOMAIN}`) && PathPrefix(`/admin`)"

supervisor:
# @TODO: Create supervisor with ansible, when merged with Ture's PR
image: itkdev/supervisor-php8.3:alpine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Controller;
namespace App\Controller\Admin;

use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -15,7 +15,7 @@ public function __construct(
) {
}

#[Route('/login', name: 'app_login')]
#[Route('/admin/login', name: 'app_admin_login')]
public function index(): Response
{
$error = $this->authenticationUtils->getLastAuthenticationError();
Expand All @@ -41,7 +41,7 @@ public function index(): Response
]);
}

#[Route('/logout', name: 'app_logout', methods: ['GET'])]
#[Route('/admin/logout', name: 'app_admin_logout', methods: ['GET'])]
public function logout(): never
{
throw new \Exception('Don\'t forget to activate logout in security.yaml');
Expand Down

0 comments on commit 6b77d82

Please sign in to comment.