File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use OCA \Assistant \Capabilities ;
6
6
use OCA \Assistant \Listener \BeforeTemplateRenderedListener ;
7
+ use OCA \Assistant \Listener \CSPListener ;
7
8
use OCA \Assistant \Listener \FreePrompt \FreePromptReferenceListener ;
8
9
use OCA \Assistant \Listener \SpeechToText \SpeechToTextReferenceListener ;
9
10
use OCA \Assistant \Listener \TaskFailedListener ;
20
21
use OCP \AppFramework \Bootstrap \IRegistrationContext ;
21
22
use OCP \AppFramework \Http \Events \BeforeTemplateRenderedEvent ;
22
23
use OCP \Collaboration \Reference \RenderReferenceEvent ;
24
+ use OCP \Security \CSP \AddContentSecurityPolicyEvent ;
23
25
use OCP \TaskProcessing \Events \TaskFailedEvent ;
24
26
use OCP \TaskProcessing \Events \TaskSuccessfulEvent ;
25
27
@@ -55,6 +57,8 @@ public function register(IRegistrationContext $context): void {
55
57
$ context ->registerEventListener (TaskFailedEvent::class, TaskFailedListener::class);
56
58
57
59
$ context ->registerNotifierService (Notifier::class);
60
+
61
+ $ context ->registerEventListener (AddContentSecurityPolicyEvent::class, CSPListener::class);
58
62
}
59
63
60
64
public function boot (IBootContext $ context ): void {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace OCA \Assistant \Listener ;
6
+
7
+ use OCP \AppFramework \Http \ContentSecurityPolicy ;
8
+ use OCP \EventDispatcher \Event ;
9
+ use OCP \EventDispatcher \IEventListener ;
10
+ use OCP \Security \CSP \AddContentSecurityPolicyEvent ;
11
+
12
+ /**
13
+ * @template-implements IEventListener<AddContentSecurityPolicyEvent>
14
+ */
15
+ class CSPListener implements IEventListener {
16
+
17
+ public function __construct (
18
+ ) {
19
+ }
20
+
21
+ public function handle (Event $ event ): void {
22
+ if (!($ event instanceof AddContentSecurityPolicyEvent)) {
23
+ return ;
24
+ }
25
+
26
+ $ csp = new ContentSecurityPolicy ();
27
+ $ csp ->addAllowedWorkerSrcDomain ('blob: ' );
28
+ $ event ->addPolicy ($ csp );
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments