File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ security:
33
33
# API does Basic Auth and IP address auth
34
34
api :
35
35
pattern : ^/api
36
+ context : domjudge
36
37
provider : domjudge_db_provider
37
- stateless : true
38
38
user_checker : App\Security\UserChecker
39
39
entry_point : App\Security\DOMJudgeIPAuthenticator
40
40
# SEE NOTE ABOVE IF CHANGING ANYTHING HERE
@@ -45,6 +45,7 @@ security:
45
45
# Provides prometheus metrics
46
46
metrics :
47
47
pattern : ^/prometheus/metrics
48
+ context : domjudge
48
49
provider : domjudge_db_provider
49
50
stateless : true
50
51
user_checker : App\Security\UserChecker
@@ -57,6 +58,7 @@ security:
57
58
# rest of app does form_login
58
59
main :
59
60
pattern : ^/
61
+ context : domjudge
60
62
provider : domjudge_db_provider
61
63
user_checker : App\Security\UserChecker
62
64
entry_point : App\Security\DOMJudgeXHeadersAuthenticator
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+
3
+ namespace App \EventListener ;
4
+
5
+ use Symfony \Component \EventDispatcher \Attribute \AsEventListener ;
6
+ use Symfony \Component \HttpKernel \Event \ResponseEvent ;
7
+
8
+ // The AbstractSessionListener (which sets the cookie) has a priority of -1000, so we need to
9
+ // set a priority of -1001 to run before it.
10
+ #[AsEventListener(priority: -1001 )]
11
+ class NoSessionCookieForApiListener
12
+ {
13
+ public function __invoke (ResponseEvent $ event ): void
14
+ {
15
+ // We do not want to set the session cookie for API requests. Since the firewall is
16
+ // stateful (because we want form logins to allow to access the API), we need to remove
17
+ // the cookie
18
+ $ request = $ event ->getRequest ();
19
+ $ response = $ event ->getResponse ();
20
+ if ($ request ->attributes ->get ('_firewall_context ' ) === 'security.firewall.map.context.api ' ) {
21
+ $ response ->headers ->removeCookie ($ request ->getSession ()->getName ());
22
+ }
23
+ }
24
+ }
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ protected function loginHelper(
143
143
*/
144
144
protected function logIn (): void
145
145
{
146
- $ this ->client ->loginUser ($ this ->setupUser ());
146
+ $ this ->client ->loginUser ($ this ->setupUser (), ' domjudge ' );
147
147
}
148
148
149
149
/**
You can’t perform that action at this time.
0 commit comments