Reading auth0 credentials from db on laravel project

Hi guys my app is working nice but now I need to read auth0 credentials from db instead of config/auth0.php file?
To provide more details:
Im buildding a multitenant application.
Tenant should use different auth0 credentials.
Tenant is identified based on requested url.

Does the sdk natively support this feature ?
I tryed modfing the auth0.php file to read values directly from database but laravel throws an exception informing that db connection is not ready at this time.

Any ideas ?

Hi there!

We don’t have any built-in support for doing that for you. I would suggest handling pulling the configuration details you need from your database within your own application logic, and updating the SDK’s configuration dynamically as needed.

// Specific changes:
app('auth0')->getConfiguration()->setCustomDomain('an.example.com');
// Overwriting the configuration completely:
$yourConfiguration = new \Auth0\SDK\Configuration\SdkConfiguration([
   'your' => 'settings'
]);

app('auth0')->setConfiguration($yourConfiguration);

You can reference the SdkConfiguration options available from the underlying PHP SDK.

Thanks !!!
I understand that basically I will need to find out where is the sdk initialized to bring the config array from db.

Leandro.

Ok this is what i didi:
in the class definition at (vendor/auth0/login/src/Auth0.php)
I modified the get sdk method like:

    public function getSdk(): \Auth0\SDK\Auth0
    {
        if ($this->sdk === null) {
            $this->sdk = new \Auth0\SDK\Auth0([

                'strategy' => env('AUTH0_STRATEGY', 'webapp'),
                'customDomain' => env('AUTH0_CUSTOM_DOMAIN'),
                'domain' => \App\Helpers\ClassAuth0Creds::get_AUTH0_KEY('AUTH0_DOMAIN'),
                'clientId' => \App\Helpers\ClassAuth0Creds::get_AUTH0_KEY('AUTH0_CLIENT_ID'),
                'redirectUri' => \App\Helpers\ClassAuth0Creds::get_AUTH0_KEY('AUTH0_REDIRECT_URI'),
                'clientSecret' => \App\Helpers\ClassAuth0Creds::get_AUTH0_KEY('AUTH0_CLIENT_SECRET'),
                'audience' => \Auth0\Laravel\Configuration::stringToArrayOrNull(env('AUTH0_AUDIENCE')),
                'scope' => \Auth0\Laravel\Configuration::stringToArrayOrNull(env('AUTH0_SCOPE')),
                'organization' => \Auth0\Laravel\Configuration::stringToArrayOrNull(env('AUTH0_ORGANIZATION')),
                'cookieSecret' => env('AUTH0_COOKIE_SECRET', env('APP_KEY')),
                'cookieExpires' => env('COOKIE_EXPIRES', 0),
                'cookieDomain' => env('AUTH0_COOKIE_DOMAIN'),
                'cookiePath' => env('AUTH0_COOKIE_PATH'),
                'cookieSecure' => \Auth0\Laravel\Configuration::stringToBoolOrNull(env('AUTH0_COOKIE_SECURE'), false),
                'routes' => [
                    'home' => env('AUTH0_ROUTE_HOME', '/'),
                    'login' => env('AUTH0_ROUTE_LOGIN', 'login')
                ]

            ]);



            $this->setSdkTelemetry();
        }

        return $this->sdk;
    }

then , the:

 \App\Helpers\ClassAuth0Creds

Is where I read the credentials on the db.
Perhaps it is not the most elegant solution but it works.
Any suggestion is wellcome.
thanks.