Added a new config.php setting DISABLE_AUTH to be able to disable authentication / the login screen (closes #246)

This commit is contained in:
Bernd Bestel
2019-07-06 18:29:18 +02:00
parent 8c205941c7
commit 09b23847b5
5 changed files with 16 additions and 2 deletions

View File

@@ -40,6 +40,15 @@ require_once __DIR__ . '/vendor/autoload.php';
require_once GROCY_DATAPATH . '/config.php'; require_once GROCY_DATAPATH . '/config.php';
require_once __DIR__ . '/config-dist.php'; //For not in own config defined values we use the default ones require_once __DIR__ . '/config-dist.php'; //For not in own config defined values we use the default ones
// Definitions for disabled authentication mode
if (GROCY_DISABLE_AUTH === true)
{
if (!defined('GROCY_USER_ID'))
{
define('GROCY_USER_ID', 1);
}
}
// Setup base application // Setup base application
$appContainer = new \Slim\Container([ $appContainer = new \Slim\Container([
'settings' => [ 'settings' => [

View File

@@ -9,3 +9,4 @@
- Items can now be switched between lists (there is a shopping list dropdown on the item edit page) - Items can now be switched between lists (there is a shopping list dropdown on the item edit page)
- Items can now be marked as "done" (new check mark button per item, when clicked, the item will be displayed greyed out, when clicked again the item will be displayed normally again) - Items can now be marked as "done" (new check mark button per item, when clicked, the item will be displayed greyed out, when clicked again the item will be displayed normally again)
- Improved that products can now also be consumed as spoiled from the stock overview page (option in the more/context menu per line) - Improved that products can now also be consumed as spoiled from the stock overview page (option in the more/context menu per line)
- Added a new `config.php` setting `DISABLE_AUTH` to be able to disable authentication / the login screen

View File

@@ -41,6 +41,10 @@ Setting('STOCK_BARCODE_LOOKUP_PLUGIN', 'DemoBarcodeLookupPlugin');
# set this to true # set this to true
Setting('DISABLE_URL_REWRITING', false); Setting('DISABLE_URL_REWRITING', false);
# Set this to true if you want to disable authentication / the login screen,
# places where user context is needed will then use the default (first existing) user
Setting('DISABLE_AUTH', false);

View File

@@ -22,7 +22,7 @@ class ApiKeyAuthMiddleware extends BaseMiddleware
$route = $request->getAttribute('route'); $route = $request->getAttribute('route');
$routeName = $route->getName(); $routeName = $route->getName();
if (GROCY_IS_DEMO_INSTALL || GROCY_IS_EMBEDDED_INSTALL) if (GROCY_IS_DEMO_INSTALL || GROCY_IS_EMBEDDED_INSTALL || GROCY_DISABLE_AUTH)
{ {
define('GROCY_AUTHENTICATED', true); define('GROCY_AUTHENTICATED', true);
$response = $next($request, $response); $response = $next($request, $response);

View File

@@ -25,7 +25,7 @@ class SessionAuthMiddleware extends BaseMiddleware
{ {
$response = $next($request, $response); $response = $next($request, $response);
} }
elseif (GROCY_IS_DEMO_INSTALL || GROCY_IS_EMBEDDED_INSTALL) elseif (GROCY_IS_DEMO_INSTALL || GROCY_IS_EMBEDDED_INSTALL || GROCY_DISABLE_AUTH)
{ {
$user = $sessionService->GetDefaultUser(); $user = $sessionService->GetDefaultUser();
define('GROCY_AUTHENTICATED', true); define('GROCY_AUTHENTICATED', true);