Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some checks don't work in a multitenancy app #40

Closed
RobertCordes opened this issue Feb 13, 2021 · 2 comments · Fixed by #43
Closed

Some checks don't work in a multitenancy app #40

RobertCordes opened this issue Feb 13, 2021 · 2 comments · Fixed by #43
Labels
enhancement New feature or request

Comments

@RobertCordes
Copy link

Versions

  • PHP version: 7.4.12
  • Laravel version: 8.25.0
  • Enlightn version: 1.9.0 OSS

Description

Hi, I'm trying to run Enlightn in a multitenancy setup. I'm using the laravel-multitenancy package from Spatie. Some checks just don't seem to work with this kind of setup.

Steps to Reproduce

Nothing special. Just set up a Laravel app with the multitenancy package as per documentation.

Expected behavior:
For all the checks to work I guess 😇 Although I don't really expect this to work out of the box. For example Invoker has a feature where you can define some preload code. So the expected behavior would probably be some way to configure this.

Actual behavior:
When I run Enlightn some checks just throw an exception with Target class [currentTenant] does not exist. In the OSS version of Enlightn the following checks don't work:

  • Session Driver Analyzer
  • CSRF Analyzer
  • Encrypted Cookies Analyzer
  • HTTP Only Cookie Analyzer
@paras-malhotra
Copy link
Member

paras-malhotra commented Feb 13, 2021

Hi @RobertCordes, after reading through the docs of the Multitenancy package, I reckon you may be calling app('currentTenant') in some of the config files or middleware. So, you may need to set the current tenant before Enlightn runs its checks, so that the config is set accordingly.

Can you check if adding the following code to your AppServiceProvider's register method works?

use Enlightn\Enlightn\Inspection\Inspector;

$this->app->afterResolving(Inspector::class, function ($inspector) {
        // Add preload code to set current tenant here
});

If this does work, then I can make a PR to provide a more elegant way of doing this using a callback like:

Enlightn::beforeRunning(function () {
        // Preload code here
});

@paras-malhotra paras-malhotra added the enhancement New feature or request label Feb 13, 2021
@RobertCordes
Copy link
Author

Hey @paras-malhotra, thanks for the quick reply. This works perfectly! Can't wait for the PR 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants