Assaro / DD_Bot

Discord Bot to Control Docker Services via the Docker Socket
GNU General Public License v3.0
29 stars 5 forks source link

Role based permission not working #31

Open nodiaque opened 5 months ago

nodiaque commented 5 months ago

Hello,

I have given a role permission to start and stop some dockers. When a user from this role try to start or stop said docker, it get a permission denied. I must give explicit permission to the user for it to work. I've added the permission using the bot and they are in the config file.

Thank you

Assaro commented 5 months ago

Can you please send me the config file and the IDs of your roles? You can get a role's ID by enabling the developer mode and right-clicking on it in the servers options Also please remove your Bot token and, if you don't want people to see it, the User IDs from the config before sending. Additionally, please try to reproduce the error and send me the log that is produced.

nodiaque commented 5 months ago

Role ID are added automatically by the bot so no need to find them.

{
  "LanguageSettings": {
    "Language": "en"
  },
  "DiscordSettings": {
    "Token": "####",
    "AdminIDs": [
      345946411793252353
    ],
    "UserWhitelist": true,
    "UserIDs": [
      447013276518449162
    ],
    "UsersCanStopContainers": true,
    "AllowedContainers": [],
    "RoleStartPermissions": {
      "1202350616769466418": [
        "All-The-Mods-9"
      ],
      "919408258240901120": [
        "Valheim",
        "Valheim-PTR",
        "ConanExiles",
        "V-Rising",
        "ARKSurvivalEvolved",
        "ConanExiles_IsleofSiptah",
        "7DaysToDie",
        "Palword",
        "Enshrouded"
      ]
    },
    "RoleStopPermissions": {
      "1202350616769466418": [
        "All-The-Mods-9"
      ],
      "919408258240901120": [
        "Valheim",
        "Valheim-PTR",
        "ConanExiles",
        "V-Rising",
        "ARKSurvivalEvolved",
        "ConanExiles_IsleofSiptah",
        "7DaysToDie",
        "Palword",
        "Enshrouded"
      ]
    },
    "UserStartPermissions": {
      "447013276518449162": [
        "Valheim",
        "Valheim-PTR",
        "ConanExiles",
        "V-Rising",
        "ARKSurvivalEvolved",
        "ConanExiles_IsleofSiptah",
        "7DaysToDie",
        "Palword",
        "Enshrouded"
      ]
    },
    "UserStopPermissions": {
      "447013276518449162": [
        "Valheim",
        "Valheim-PTR",
        "ConanExiles",
        "V-Rising",
        "ARKSurvivalEvolved",
        "ConanExiles_IsleofSiptah",
        "7DaysToDie",
        "Palword",
        "Enshrouded"
      ]
    }
  },
  "DockerSettings": {
    "BotName": "GameManBot",
    "Retries": 6,
    "TimeBeforeRetry": 5,
    "ContainersPerMessage": 30
  }
}
Assaro commented 5 months ago

I still need your role IDs from Discord so i can verify they were saved correctly

nodiaque commented 5 months ago

919408258240901120

1202350616769466418 this one for all-of-the-mods-9

Assaro commented 5 months ago

Not a corrupt config then. I will have a look into it

nodiaque commented 5 months ago

Could it be because the user is in the whitelist? I don't even get what the whitelist is for. Before, I had the whitelist with the user and all the container in the whitelist. I think it's 2 years ago I did that. But I saw a couple of days ago I can just use the bot to add/remove permission and that's when I tried doing it with role. I removed all container from the whitelist but not the user.

Assaro commented 5 months ago

The user whitelist is the old and lazy way used before permissions. If you set UserWhitelist to false it should be completely ignored. Try that. It is not used in the latest code though. I removed all of the logic but kept the variables for now.

nodiaque commented 5 months ago

Ah, that did it. Setting whitelist to false made the role working again

nodiaque commented 5 months ago

I would say the next thing that would be nice is when someone use the /list command, it list only the container it can control

Assaro commented 5 months ago

I would say the next thing that would be nice is when someone use the /list command, it list only the container it can control

That is implemented. I have not touched the code in pretty much one year though. Some things in the API may have changed