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

error: secret key is missing in the request #7

Open
rish002 opened this issue Mar 27, 2018 · 8 comments
Open

error: secret key is missing in the request #7

rish002 opened this issue Mar 27, 2018 · 8 comments

Comments

@rish002
Copy link

rish002 commented Mar 27, 2018

The error is coming only in the Update Segment Cron Job and the rest 2 basic ones are running beautifully.

Here is Job Output:

error: secret key is missing in the request

Here are the Job Request Headers:

{
	"server": "nginx",
	"date": "Mon, 26 Mar 2018 10:03:47 GMT",
	"content-type": "text/plain; charset=UTF-8",
	"transfer-encoding": "chunked",
	"connection": "keep-alive",
	"cache-control": "private, must-revalidate",
	"pragma": "no-cache",
	"expires": "-1",
	"set-cookie": [
		"b4056ca99da47b1e98d9a97cc3d74070=smat7n7bhtlrn83j799qit8pd6; path=/; secure; HttpOnly"
	],
	"host-header": "192fc2e7e50945beb8231a492d6a8024"
}

I think this error is generated by the PublicController.php file in the Controller folder.

Here is the code which generates this error.
I think the 1st elseif condition after the if condition renders the error.

/**
 * Class PublicController.
 */
class PublicController extends CommonController
{
    /*
     * @param string $command
     */
    public function triggerAction($command)
    {
        $response  = new Response();
        $secretKey = $this->request->query->get('secret_key');
        $config    = $this->factory->getParameter('cronfig');
        $logger    = $this->get('monolog.logger.mautic');

        if (empty($config['secret_key'])) {
            $response->setStatusCode(Codes::HTTP_FORBIDDEN);
            $output = 'error: secret key is missing in the configuration';
            $logger->log('error', 'Cronfig: secret key is missing in the configuration');
        } elseif (!$secretKey) {
            $response->setStatusCode(Codes::HTTP_FORBIDDEN);
            $output = 'error: secret key is missing in the request';
            $logger->log('error', 'Cronfig: secret key is missing in the request');
        } elseif ($config['secret_key'] === $secretKey) {
            $command    = explode(' ', urldecode($command));
            $errorCount = $this->request->get('error_count', 0);
            $args       = array_merge(['console'], $command);


Now, it will be easy for you to look at the problem. I also contacted to my server guys and they told me that there is something in a script that may need to be fixed.

Thank you in advance for your help.

@escopecz
Copy link
Contributor

Try to delete the task and create it again.

@rish002
Copy link
Author

rish002 commented Mar 27, 2018

Thank you so much @escopecz. It worked perfectly.

You are a true hero! 👍

@escopecz
Copy link
Contributor

Awesome! I'll have to figure out why it's having problems in the first place. But I'm glad you can get going now :)

@rish002
Copy link
Author

rish002 commented Mar 27, 2018

Yes, thank you for your valuable support! :)

@paulonogarol
Copy link

@escopecz thank you, its worked here

@Rol-a
Copy link

Rol-a commented Aug 29, 2020

@escopecz. Well, John I don't think I agree with you to the point that cronfig is just dumb and more complicated than it should've been. And the reason why is simple. First because everything is relative in life, and second because you are comparing "now and before". Obviously, as human being we always have preference when we compare two things. Anyway, enough rumbling here. Good job and thank you very much for this instead.

I am actually getting this same "secret key missing" error and I was wondering if this comes from the fact that the installation documentation does not at some point change the owner of the CronfigBundle folder to www-data?
Thanks again!

@escopecz
Copy link
Contributor

@Rol-a thanks. Could you double-check that this did not work for you?:

Try to delete the tasks, log out of Cronfig, log out of Mautic, log back in to both and create the jobs again.

@Rol-a
Copy link

Rol-a commented Sep 2, 2020

@escopecz. It works now.
Thanks again.

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

No branches or pull requests

4 participants