Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module: mercure #83

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ MYSQL_VERSION=8.0.27
MYSQL_DATABASE=databasorus
MYSQL_USER=user
MYSQL_PASSWORD=password

MERCURE_URL=http://mercure/.well-known/mercure
MERCURE_PUBLIC_URL=http://localhost:81/.well-known/mercure
MERCURE_SERVER_NAME=:80
MERCURE_CORS_ALLOWED_ORIGINS="http://localhost"
MERCURE_JWT_KEY=!ChangeThisMercureHubJWTSecretKey!
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"symfony/http-client": "^7.0",
"symfony/intl": "^7.0",
"symfony/mailer": "^7.0",
"symfony/mercure-bundle": "^0.3.8",
"symfony/mime": "^7.0",
"symfony/monolog-bundle": "^3.10",
"symfony/notifier": "^7.0",
Expand Down
242 changes: 241 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
];
8 changes: 8 additions & 0 deletions config/packages/mercure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mercure:
hubs:
default:
url: '%env(MERCURE_URL)%'
public_url: '%env(MERCURE_PUBLIC_URL)%'
jwt:
secret: '%env(MERCURE_JWT_KEY)%'
publish: '*'
13 changes: 13 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,18 @@ services:
- '../src/Entity/'
- '../src/Kernel.php'

App\Listener\MercureDiscoveryListener:
tags:
- { name: kernel.event_listener, event: ResponseEvent, method: onKernelResponse }

App\Listener\MercureAuthorizationListener:
tags:
- { name: kernel.event_listener, event: ResponseEvent, method: onKernelResponse }

App\Listener\AuthenticationListener:
tags:
- { name: kernel.event_listener, event: loginSuccessEvent, method: onLoginSuccess }
- { name: kernel.event_listener, event: loginFailureEvent, method: onLoginFailure }

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ services:
volumes:
- db-data:/var/lib/mysql:rw
restart: unless-stopped
mercure:
image: dunglas/mercure
restart: unless-stopped
command: /usr/bin/caddy run --config /etc/caddy/Caddyfile.dev
environment:
SERVER_NAME: ${MERCURE_SERVER_NAME}
MERCURE_PUBLISHER_JWT_KEY: ${MERCURE_JWT_KEY}
MERCURE_SUBSCRIBER_JWT_KEY: ${MERCURE_JWT_KEY}
MERCURE_EXTRA_DIRECTIVES: |
cors_origins ${MERCURE_CORS_ALLOWED_ORIGINS}
ports:
- 81:80

volumes:
db-data: ~
Loading