]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Disable permission checks when no auth plugin exists
authorValerie Pond <redacted>
Tue, 4 Apr 2023 00:15:29 +0000 (01:15 +0100)
committerValerie Pond <redacted>
Tue, 4 Apr 2023 00:15:29 +0000 (01:15 +0100)
This lets people who are not using sql_auth plugin still be able to do things and not worry about setting permissions.

Warning: Not using sql_auth will NOT let you configure user permissions. In other words, anyone you give access will have permission to do everything.

Classes/class-hook.php
Classes/class-paneluser.php
common.php
plugins.php
plugins/sql_auth/sql_auth.php

index 7ebeb1af14f9cb3373dd33645d367808728d23fb..fc7f71ac37ea293baa188dfcdc7e9fc85a44a337 100644 (file)
@@ -132,6 +132,10 @@ define('HOOKTYPE_USER_LOGIN_FAIL', 115);
 define('HOOKTYPE_USER_PERMISSION_LIST', 116);
 
 define('HOOKTYPE_EDIT_USER', 117);
+
+
+
+define('HOOKTYPE_AUTH_MOD', 200);
 /** 
  *  Class for "Hook"
  * This is the main function which gets called whenever you want to use a Hook.
index c813992813780dc57363b7a21000a40e3e906a1f..475819876175f4c127658fe2c3d675b58acb31e4 100644 (file)
@@ -233,6 +233,8 @@ function unreal_get_current_user() : PanelUser|bool
  */
 function current_user_can($permission) : bool
 {
+       if (!is_auth_provided()) // if there is no auth plugin, assume the user handles logins themselves
+               return true;
        $user = unreal_get_current_user();
        if (!$user)
                return false;
index 68c6e0e5dab6aaba062bfa0c785c78e913326a8a..d685538b8d2b55b607fa69f4ae54aa488c5ff504 100644 (file)
@@ -42,19 +42,23 @@ $pages = [
                "IP WHOIS" => "tools/ip-whois.php",
        ],
        "Settings" => [
-               "Panel Access" => "settings",
                "Plugins" => "settings/plugins.php",
        ],
        
-       "News"         => "news.php",
+       "News" => "news.php",
 ];
-$user = unreal_get_current_user();
-if ($user)
+
+if (is_auth_provided())
 {
-       /* Add logout page, if logged in */
-       $pages["Logout"] = "login/?logout=true";
-}
+       $pages["Settings"]["Panel Access"] = "settings";
 
+       $user = unreal_get_current_user();
+       if ($user)
+       {
+               /* Add logout page, if logged in */
+               $pages["Logout"] = "login/?logout=true";
+       }
+}
 Hook::run(HOOKTYPE_NAVBAR, $pages);
 
 /* Example to add new menu item:
index 6d521eb87b6424c2d46778286095018c5a4d6d82..3bf8b9a816b20e56f42e1a04f8bc4ff975f8bb9e 100644 (file)
@@ -121,4 +121,17 @@ function require_plugin($name, $version)
 {
        if (!Plugins::plugin_exists($name,$version))
                die("Missing plugin: $name v$version");
+}
+
+
+
+/* I'm not a fan of globals */
+class AuthModLoaded
+{
+       public static $status = 0;
+}
+
+function is_auth_provided()
+{
+       return AuthModLoaded::$status;
 }
\ No newline at end of file
index ca12f28cdc10c5595132cfaa3a62b1c043145045..20176b7e567b210b89dda60b56869fcbe8c8e22b 100644 (file)
@@ -25,6 +25,7 @@ class sql_auth
                Hook::func(HOOKTYPE_USER_DELETE, 'sql_auth::user_delete');
                Hook::func(HOOKTYPE_EDIT_USER, 'sql_auth::edit_core');
                Hook::func(HOOKTYPE_PRE_OVERVIEW_CARD, 'sql_auth::add_pre_overview_card');
+               AuthModLoaded::$status = 1;
 
                if (defined('SQL_DEFAULT_USER')) // we've got a default account
                {