craigk5n / webcalendar

WebCalendar is a PHP application used to maintain a calendar for a single user or an intranet group of users. It can also be configured as an event calendar.
http://www.k5n.us/webcalendar.php
GNU General Public License v2.0
149 stars 71 forks source link

Allow opt-in for placing webcalendar within iframe #383

Closed Tharrington86 closed 10 months ago

Tharrington86 commented 11 months ago

I just upgraded to version 1.9.1 and I can no longer deploy the calendar across our network embedded into an iframe.

Console error is as follows: Refused to frame 'My URL' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".

Is this intended behavior? I need the ability to embed the calendar via iframe on our company intranet site.

craigk5n commented 11 months ago

Yes, this is an intended behavior for security reasons. I'll change the title of this to opting in to allow this.

Tharrington86 commented 10 months ago

That would be a great option to include, especially for us legacy users that are embedding the calendars in other webpages.

I am unfamiliar with php but if you could point me in the right direction, I will see what I can come up with.

craigk5n commented 10 months ago

Version 1.9.8 now has an option in Admin Setting under "Site security" where you can set the CSP value to allow use of iframes.

Tharrington86 commented 10 months ago

I just tried to upgrade to v1.9.8 and everything went smooth except I still cannot get the calendar to display in an iframe. After I ran the installation wizard, I logged in to the calendar via the direct URL and selected to allow any site to iframe and disabled the origin checking. When trying to view the embedded calendar nothing is displayed and the following is displayed in the console: {IntranetURL} blocked a frame with origin {webCalURL} from accessing a cross-origin frame.

Upon regressing to v1.3.0 the iframe properly displays the calendar again.

craigk5n commented 10 months ago

Can you the Chrome developer tools to inspect the HTTP response header? I'm curious if it is sending the correct headers.

Tharrington86 commented 10 months ago

Screenshot 2023-09-18 161952 Screenshot 2023-09-18 162153 Screenshot 2023-09-18 162227

craigk5n commented 10 months ago

Forgot about that bit of code... Hopefully latest commit will fix this: 5e5d0e5a70a590f5809530dcbf9735bbdfa9500a

Tharrington86 commented 10 months ago

I can confirm that this change does work. I made the modifications and the calendar is now working in an iframe. Thank you!

craigk5n commented 10 months ago

Glad to hear it's working 👍