You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im using the command line API for my game server... i have several mods and admins sending commands from their client to the game server.
However, i need to check some commands for privileges to prevent abusing those commands.
Currently it looks a bit like this...
/GiveItem -caller AdminName -to PlayerName -... other stuff and the command acesses the caller option to check if the admin has the right to use this type of command... this is a bit ugly. The caller of the command shouldnt be passed as an option, this is also insecure because other admins without those rights could simply parse another admins name in that option to acess it.
Im looking for some type of security validation root.Invoke(command, adminNameOrAccountOrWhatever, other stuff... ) this way the option could do the security validation without having the name passed as an option or argument.
I hope you all understand what i mean, im terrible at describing. Is there something like this build in ?
The text was updated successfully, but these errors were encountered:
I don't really know what and precisely how you want to program, but an idea that comes to my mind is using a ThreadLocal or a AsyncLocal (dependig on whether your control flow is synchronous or asynchronous) to pass necessary data other than commandline arguments into the commandline handler, kinda like this (pseudo code!):
private static ThreadLocal<Whatever> myThreadLocal = new();
void TheApiRequestHandler(...)
{
var stuffThatMatters = get user token/id and whatever else is needed...;
myThreadLocal.Value = stuffThatMatters;
rootCommand.Invoke(normal commandline args);
}
void CommandHandler(normal commandline option and argument parameters)
{
var hereIsTheStuffThatMatters = myThreadLocal.Value;
}
It might also be possible to pass the additional information in properties of a custom object that implements IConsole, because you can pass an IConsole to CommandExtensions.Invoke and read it back from InvocationContext.Console. However:
It would look somewhat strange, although perhaps it makes sense in a game server / chatbot where the console corresponds to a user agent.
Would break if System.CommandLine creates a delegating IConsole instead of passing the original instance.
Im using the command line API for my game server... i have several mods and admins sending commands from their client to the game server.
However, i need to check some commands for privileges to prevent abusing those commands.
Currently it looks a bit like this...
/GiveItem -caller AdminName -to PlayerName -... other stuff
and the command acesses the caller option to check if the admin has the right to use this type of command... this is a bit ugly. The caller of the command shouldnt be passed as an option, this is also insecure because other admins without those rights could simply parse another admins name in that option to acess it.Im looking for some type of security validation
root.Invoke(command, adminNameOrAccountOrWhatever, other stuff... )
this way the option could do the security validation without having the name passed as an option or argument.I hope you all understand what i mean, im terrible at describing. Is there something like this build in ?
The text was updated successfully, but these errors were encountered: