Protect Shopware Stage/Test Instances aka Shopware and Basic Auth

Viewed 30
2 Answers

IP whitelisting

You can enable the maintenance mode for a sales channel and then whitelist IPs to allow access to the storefront.

Workaround for basic auth

It is possible to secure the storefront with basic auth but for the administration you'll have to exclude the api paths, which shouldn't be a problem as they require authentication anyways.

Apache:

AuthType Basic
AuthName 'Authentication required'
AuthUserFile /www/htdocs/shopware/.htpasswd
# Allow access to excluded path
SetEnvIf Request_URI /api noauth=1

  Require env noauth
  Require env REDIRECT_noauth
  Require valid-user

Nginx:

server {
    location ~ .php$ {
        set $auth “Restricted”;
        if (request\_uri ~ /api/.\*){
                set $auth “off”;
        }
        auth_basic $auth;
        auth_basic_user_file /www/htdocs/shopware/.htpasswd;
    }
}

Worth mentioning, you can also setup Authelia, which adds a login screen in front of your installation and will set a cookie for authentication.

I think it's mostly used in Dockerized environments.

Related