Before asking for help please read "Requesting Help and Suggestions" by clicking on that tab above here.
  • Page:
  • 1
  • 2

TOPIC:

Embed "on this day" in an iframe on another website 3 months 1 week ago #1

  • viktor_sc
  • viktor_sc's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
Hi there,
I'm running webtrees 2.0.17 on my NAS at home with no external access. On the same NAS I'm running another system (glpi) that has a dashboard. On this dashboard I'd like to add an iframe that shows the "on this day" events from webtrees.
The iframe itself is not an issue, I successfully integrated other websites.

But
1. webtrees refuses the connection once it's opened in an iframe and not directly from the browser itself
2. I'm looking for a way to iframe just the "on this day" section and not the whole website.

Is that possible? Any hints?


Thanks in advance,
Viktor

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 3 months 1 week ago #2

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 15173
> webtrees refuses the connection once it's opened in an iframe and not directly from the browser itself

webtrees sets an HTTP header to control iframes:

X-Frame-Options: SAMEORIGIN

The code is here:
github.com/fisharebest/webtrees/blob/mai.../SecurityHeaders.php

So, to allow your site (or parts of it) to be included in an iframe on a different domain name, you'd need to create your own module which adds this header.

There is an example of a module which modifies headers here:

github.com/webtrees/example-module-middleware

Just edit it, and add your own logic.

Note that there isn't an "X-Frame-Options: allow" header. But setting an empty or invalid value should probably work.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 3 months 1 week ago #3

  • viktor_sc
  • viktor_sc's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
Hi,
Thanks for your quick response.
So, there's no really simple way like changing a value somewhere in the file?

But that should help, I guess. I'll have a look at it.

Thanks

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 3 months 1 week ago #4

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 15173
> So, there's no really simple way like changing a value somewhere in the file?

You could delete the "X-Frame-Origin` line in the file in my first link.

But you'd need to do this after every upgrade.
And it would allow anyone to include your site in an iframe on their site.

If you want a permanent change that will not be overwritten by ugprades, and if you want some conditional logic (only allow embedding for certain requests), then you'll need a module.

But it is really pretty simple.

Copy/paste the files from the example module onto your own site.
Delete the bits that aren't relevant:

github.com/webtrees/example-module-middl...ddleware.php#L22-L25
github.com/webtrees/example-module-middl...ddleware.php#L50-L55
github.com/webtrees/example-module-middl...ddleware.php#L67-L84

Change this line to add your own `X-Frame-Origin` header
github.com/webtrees/example-module-middl...leMiddleware.php#L62
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 3 months 1 week ago #5

  • viktor_sc
  • viktor_sc's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
Awesome, thanks!

Looks actually easier than I thought :)

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #6

Hi I have the same problem.
I have a joomla 4 family website and I want to add genealogy on it on a frame
So this is what I did:
copy example-middleware.disable directory to middleware directory
and I don't anderstand what to do next
What to do on lines 22-25?
I think there is nothing to do on lines 50-55
Idem on lines 67-84
I don't understand what to do with the line 62.
Do I have something to do to my website ?
Please can you help me?
Regards
Gilbert

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #7

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 15173
> What to do on lines 22-25?
> I think there is nothing to do on lines 50-55
> Idem on lines 67-84

These are examples of things you *could* do.
But they aren't relevant to you.
Delete them.

> I don't understand what to do with the line 62.

This line shows you how to add an HTTP header.

You need to add an HTTP header "X-Frame-Origin", with a value of "ALLOW".

So just change that line.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #8

Thanks for this quick response
So on webtrees/modules_v4/middleware directory I have change on the file module.php the line 89 like that: $response = $response->withHeader('X-Frame-Origin', 'Allow');

I have kept the others lines

Is that correct?
Regards
Gilbert

Please Log in or Create an account to join the conversation.

Do you need a web hosting solution for your webtrees site?
If you prefer a host that specialises in webtrees, the following page lists some suppliers able to provide one for you: 

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #9

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 15173
> I have kept the others lines

These other lines block local access to your site.

If this is what you want, then keep them.

Otherwise, I suggest you delete them.

> the line 89

The example file only has 85 lines. There is no line 89.

As I said previously, you need to change line 62:
github.com/webtrees/example-module-middl...leMiddleware.php#L62
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #10

Hi
done with the new contente in modules_v4 directory but no succes
regards
Gilbert

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #11

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 15173
Perhaps post the URL of your site so we can see?
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #12

Sorry for this late response:
testjoomla.prestaopen.com/index.php/genealogie
regards
Gilbert

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #13

You can test with this new website : test.prestaopen.com/test.php
it's a simple website with a php file:
<?php echo "<iframe src='webtrees.marin-fr.com/'>"; ?>

there is no joomla files
I think the problem is coming from webtrees or from ionos

regards
Gilbert

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #14

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 15173
If I look at the response from webtrees.marin-fr.com/index.php?route=%2Ftree%2Fbrentot_marin
I see the HTTP header:

X-Frame-Options: SAMEORIGIN

If your module was running correctly, I would expect to see ALLOW instead of SAMEORIGIN
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #15

HI
here is my configuration:
/webtrees/modules_v4/example-middleware/module.php

<?php

/**
* An example module to demonstrate middleware.
*/

declare(strict_types=1);

namespace ExampleNamespace;

use Fisharebest\Webtrees\Module\AbstractModule;
use Fisharebest\Webtrees\Module\ModuleCustomInterface;
use Fisharebest\Webtrees\Module\ModuleCustomTrait;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;

class ExampleModuleMiddleware extends AbstractModule implements ModuleCustomInterface, MiddlewareInterface {
use ModuleCustomTrait;

/**
* How should this module be identified in the control panel, etc.?
*
* @return string
*/
public function title(): string
{
return 'Example module';
}

/**
* Code here is executed before and after we process the request/response.
* We can block access by throwing an exception.
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
*
* @return ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
// Code here is executed before we process the request/response.



// Generate the response.
$response = $handler->handle($request);

// Code here is executed after we process the request/response.
// We can also modify the response.
$response = $response->withHeader('X-Frame-Options', 'Allow');

return $response;
}

}

Can you tell me if this is a good configuration?
Regards
Gilbert

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #16

Hi it's ok now
to add a module you to validate it on the configuration tab
regards
Gilbert

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 3 weeks ago #17

in fact it's not because because there is no directive ALLOW for X-FRAME-OPTIONS
so I have another errors and I can't login on the iframe
Regards
Gilbert

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 2 weeks ago #18

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
  • Posts: 2549
Is it a block from a private tree??
stamboom.BertKoor.nl runs on webtrees v1.7.13

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 2 weeks ago #19

I don't understand the question
I just want to add my family tree inside a family web site: into an iframe
With the module middleware I can see the public view of the tree
But I can't login to webtrees in the iframe.
When I look the web analazer: invalid x-frame-options header encoutntered when loading http..... ALLOW is not a recognized directive. The header wil be igonred
Regards
Gilbert

Please Log in or Create an account to join the conversation.

Embed "on this day" in an iframe on another website 2 months 2 weeks ago #20

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
  • Posts: 2549
When you cannot see any data unless one is logged in, then the visibility of the tree is set to "private".

I can understand when login within an iframe is prohibited. There are some security risks and inconveniences associated with using iframes.

Perhaps a solution is to avoid subdomains, eg use www.yourdomain.com/joomla and www.yourdomain.com/webtrees. Then the request for the iframe comes from the same domain and is considered much more safe.
stamboom.BertKoor.nl runs on webtrees v1.7.13

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Powered by Kunena Forum