Skip to content

Instantly share code, notes, and snippets.

@carlcs
Last active March 20, 2019 19:13
Show Gist options
  • Save carlcs/d8f92a1d1de0dded3b7a4e2b851d6bf5 to your computer and use it in GitHub Desktop.
Save carlcs/d8f92a1d1de0dded3b7a4e2b851d6bf5 to your computer and use it in GitHub Desktop.

Securely enable devmode in live environments

Original idea from: https://github.com/pixelandtonic/craftnet

.env

DEV_MODE_SECRET="my-password"

config/general.php

return [
    // Global settings
    '*' => [
        'devMode' => isset($_REQUEST['secret']) && $_REQUEST['secret'] === getenv('DEV_MODE_SECRET'),
    ],

    // Dev environment settings
    'dev' => [
        'devMode' => true,
    ],
];

Using get

http://example.com/about?secret=my-password

Using cookie

php.ini see http://php.net/request-order

request_order = "GPC"

Browser JS console

document.cookie="secret=my-password"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment