fanningert / webtrees_simpleautologin

This module provides a simple way to add a SSO auto login for webtrees in combination with a authentication proxy (like oauth2-proxy).
GNU Affero General Public License v3.0
9 stars 0 forks source link

Only works after pressing login button #2

Closed DaniHaag closed 3 months ago

DaniHaag commented 2 years ago

Hi, I was glad to find your plugin, which helps me integrating webtrees into my existing webpage. I have a very simple setup with a static home page hosten on nginx and a webtrees instance 2.1.2, I installed the plugin version 0.0.4.

I followed the installation instructions and it all works in principle, but it has a strange behaviour, which is think is wrong, and probably I did something wrong in the setup.

Did you ever experience this behaviour? Is there anything I can do about it, or can you give me a hint where to look at the issue?

` Class 'Fisharebest\Webtrees\Carbon' not found …/modules_v4/webtrees_simpleautologin/src/Modules/SimpleAutoLoginPage.php:79

0 …/app/Http/Middleware/RequestHandler.php(54): at\fanninger\WebtreesModules\SimpleAutoLogin\Modules\SimpleAutoLoginPage->handle()

1 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\RequestHandler->process()

2 …/app/Module/HitCountFooterModule.php(154): Middleland\Dispatcher->handle()

3 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Module\HitCountFooterModule->process()

4 …/app/Http/Middleware/CheckCsrf.php(76): Middleland\Dispatcher->handle()

5 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CheckCsrf->process()

6 …/vendor/oscarotero/middleland/src/Dispatcher.php(118): Middleland\Dispatcher->handle()

7 …/app/Webtrees.php(265): Middleland\Dispatcher->dispatch()

8 …/app/Http/Middleware/Router.php(153): Fisharebest\Webtrees\Webtrees::dispatch()

9 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\Router->process()

10 …/app/Http/Middleware/BootModules.php(60): Middleland\Dispatcher->handle()

11 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BootModules->process()

12 …/app/Http/Middleware/RegisterGedcomTags.php(54): Middleland\Dispatcher->handle()

13 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\RegisterGedcomTags->process()

14 …/app/Http/Middleware/LoadRoutes.php(75): Middleland\Dispatcher->handle()

15 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\LoadRoutes->process()

16 …/app/Http/Middleware/UseTransaction.php(45): Middleland\Dispatcher->handle()

17 …/vendor/illuminate/database/Concerns/ManagesTransactions.php(29): Fisharebest\Webtrees\Http\Middleware\UseTransaction::Fisharebest\Webtrees\Http\Middleware{closure}()

18 …/app/Http/Middleware/UseTransaction.php(46): Illuminate\Database\Connection->transaction()

19 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseTransaction->process()

20 …/app/Http/Middleware/DoHousekeeping.php(73): Middleland\Dispatcher->handle()

21 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\DoHousekeeping->process()

22 …/app/Http/Middleware/UseTheme.php(69): Middleland\Dispatcher->handle()

23 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseTheme->process()

24 …/app/Http/Middleware/CheckForMaintenanceMode.php(51): Middleland\Dispatcher->handle()

25 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CheckForMaintenanceMode->process()

26 …/app/Http/Middleware/UseLanguage.php(71): Middleland\Dispatcher->handle()

27 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseLanguage->process()

28 …/app/Http/Middleware/UseSession.php(78): Middleland\Dispatcher->handle()

29 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseSession->process()

30 …/app/Http/Middleware/UpdateDatabaseSchema.php(57): Middleland\Dispatcher->handle()

31 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UpdateDatabaseSchema->process()

32 …/app/Http/Middleware/UseDatabase.php(118): Middleland\Dispatcher->handle()

33 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseDatabase->process()

34 …/app/Http/Middleware/BadBotBlocker.php(233): Middleland\Dispatcher->handle()

35 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BadBotBlocker->process()

36 …/app/Http/Middleware/CompressResponse.php(73): Middleland\Dispatcher->handle()

37 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CompressResponse->process()

38 …/app/Http/Middleware/ContentLength.php(40): Middleland\Dispatcher->handle()

39 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ContentLength->process()

40 …/vendor/middlewares/client-ip/src/ClientIp.php(65): Middleland\Dispatcher->handle()

41 …/app/Http/Middleware/ClientIp.php(47): Middlewares\ClientIp->process()

42 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ClientIp->process()

43 …/app/Http/Middleware/HandleExceptions.php(90): Middleland\Dispatcher->handle()

44 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\HandleExceptions->process()

45 …/app/Http/Middleware/BaseUrl.php(79): Middleland\Dispatcher->handle()

46 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BaseUrl->process()

47 …/app/Http/Middleware/ReadConfigIni.php(68): Middleland\Dispatcher->handle()

48 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ReadConfigIni->process()

49 …/app/Http/Middleware/SecurityHeaders.php(48): Middleland\Dispatcher->handle()

50 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\SecurityHeaders->process()

51 …/app/Http/Middleware/EmitResponse.php(57): Middleland\Dispatcher->handle()

52 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\EmitResponse->process()

53 …/vendor/oscarotero/middleland/src/Dispatcher.php(118): Middleland\Dispatcher->handle()

54 …/app/Webtrees.php(265): Middleland\Dispatcher->dispatch()

55 …/app/Webtrees.php(252): Fisharebest\Webtrees\Webtrees::dispatch()

56 …/index.php(51): Fisharebest\Webtrees\Webtrees->httpRequest()

57 {main}

`

AlexBocken commented 8 months ago

The Error message can be fixed by patching the corresponding file /modules_v4/webtrees_simpleautologin/src/Modules/SimpleAutoLoginPage.php and replace 'Fisharebest\Webtrees\Carbon' with 'Carbon\Carbon'.

I have found a workaround to be able to have an automatic login on reaching webtrees: In your control panel go to Modules -> Other -> CSS and JS and add to the "Add content to the end of the \<body> element." field the following code:

<script>
document.querySelector("li.nav-item.menu-login > a")?.click()
</script>

This will automatically click on the login button for you. It's a bit hacky but works. If you want people to not be able to logout (and of course be instantly logged in again) you can add the following to the "Add content to the end of the \<head> element." block:

<style>
li.nav-item.menu-logout{
display:none;
}
</style>

This will simply hide the Logout button. (Note that this is done client-side so you could manually enable it again. Should not be an issue and prevents us from having to modify the template itself on the server.

Edit: simplified selectors for higher reliability in case of updates.

fanningert commented 5 months ago

@AlexBocken I don't have the described problem in the current webtrees version. It's needed to the the dependence to 'Carbon\Carbon'?

AlexBocken commented 5 months ago

I can confirm that the issue has been solved for me with the release of 0.0.5. I do no longer need to manually change it to 'Carbon\Carbon'. But i still need to click the login button and need to hide the logout button. This should not have changed, right? Apologies, I'm not quite sure what your question is pertaining to.

Thanks very much for the update!