Skip to content

Instantly share code, notes, and snippets.

@bbrewer97202
Created August 10, 2012 18:20
Show Gist options
  • Save bbrewer97202/3316425 to your computer and use it in GitHub Desktop.
Save bbrewer97202/3316425 to your computer and use it in GitHub Desktop.
Simple htaccess authentication on Heroku with cedar/php

Create an .htaccess file in the webroot:

AuthUserFile /app/www/.htpasswd
AuthType Basic
AuthName "Restricted Access"
Require valid-user

Create a .htpasswd file:

htpasswd -c /app/www/.htpasswd [username]
@kevinarrieta
Copy link

You can also use the /app/Providers/RouteServiceProvider.php and the "auth.basic" middleware for that:

protected function mapWebRoutes(Router $router)
{
    $middlewares = ['web', 'hasTeam'];
    if(env('AUTH_BASIC', 0)){
        array_push($middlewares, "auth.basic");
    }
    $router->middleware($middlewares)
           ->namespace($this->namespace)
           ->group(base_path('routes/web.php'));
}

https://laravel.com/docs/5.8/authentication#http-basic-authentication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment