private async Task ValidateIdentity(ApiKeyValidateIdentityContext context) { if (ApiKeyController.IsValidKey(context.ApiKey)) { context.Validate(); } }
private void reloadApiKeysButton_Click(object sender, EventArgs e) { ApiKeyController.LoadApiKeys(); MessageBox.Show("API Keys Reloaded"); }
public ManagerMainForm() { InitializeComponent(); _commandLineHistory = new List <string>(); if (!Directory.Exists(Constants.SettingsFolderName)) { Directory.CreateDirectory(Constants.SettingsFolderName); } ApiKeyController.Init(Path.Combine(Constants.SettingsFolderName, Constants.ApiKeyFileName)); //TODO logic //List<AvorionServerCommandDefinition> tmpDefinitions = new List<AvorionServerCommandDefinition>(); //AvorionServerCommandDefinition tmpSaveDefinition = new AvorionServerCommandDefinition(); //tmpSaveDefinition.ExecutionType = CommandExecutionTypes.Lua; //tmpSaveDefinition.DisplayName = "Save"; //tmpSaveDefinition.HasParameters = false; //tmpSaveDefinition.InternalId = 1; //tmpSaveDefinition.InternalName = "Server():save"; //AvorionServerCommandDefinition tmpStopDefintion = new AvorionServerCommandDefinition(); //tmpStopDefintion.ExecutionType = CommandExecutionTypes.Lua; //tmpStopDefintion.DisplayName = "Stop"; //tmpStopDefintion.HasParameters = false; //tmpStopDefintion.InternalId = 2; //tmpStopDefintion.InternalName = "Server():stop"; //AvorionServerCommandDefinition tmpBroadcastDefinition = new AvorionServerCommandDefinition(); //tmpBroadcastDefinition.ExecutionType = CommandExecutionTypes.Lua; //tmpBroadcastDefinition.DisplayName = "Broadcast Chat Message"; //tmpBroadcastDefinition.HasParameters = true; //tmpBroadcastDefinition.InternalId = 3; //tmpBroadcastDefinition.InternalName = "Server():broadcastChatMessage"; //AvorionServerCommandParameterDefinition tmpsenderParameterDefinition = new AvorionServerCommandParameterDefinition(); //tmpsenderParameterDefinition.DisplayName = "Sender"; //AvorionServerCommandParameterDefinition tmpMessageTypeParameterDefinition = new AvorionServerCommandParameterDefinition(); //tmpMessageTypeParameterDefinition.DisplayName = "Message Type"; //AvorionServerCommandParameterDefinition tmpMessageParameterDefinition = new AvorionServerCommandParameterDefinition(); //tmpMessageParameterDefinition.DisplayName = "Message"; //tmpBroadcastDefinition.AddParameterDefinition(tmpsenderParameterDefinition); //tmpBroadcastDefinition.AddParameterDefinition(tmpMessageTypeParameterDefinition); //tmpBroadcastDefinition.AddParameterDefinition(tmpMessageParameterDefinition); //tmpDefinitions.Add(tmpSaveDefinition); //tmpDefinitions.Add(tmpStopDefintion); //tmpDefinitions.Add(tmpBroadcastDefinition); //#region AddAdminCommand //AvorionServerCommandDefinition tmpAddAdmin = new AvorionServerCommandDefinition(); //tmpAddAdmin.ExecutionType = CommandExecutionTypes.Console; //tmpAddAdmin.DisplayName = "Add Admin"; //tmpAddAdmin.HasParameters = true; //tmpAddAdmin.InternalName = "/admin --add"; //List<AvorionServerCommandParameterDefinition> tmpAddAdminParameters = new List<AvorionServerCommandParameterDefinition>(); //AvorionServerCommandParameterDefinition tmpNameParameter = new AvorionServerCommandParameterDefinition(); //tmpNameParameter.DisplayName = "Player Name"; //tmpNameParameter.Prefix = "--name"; //tmpAddAdminParameters.Add(tmpNameParameter); //AvorionServerCommandParameterDefinition tmpIdParameter = new AvorionServerCommandParameterDefinition(); //tmpIdParameter.DisplayName = "Player Steam64 Id"; //tmpIdParameter.Prefix = "--id"; //tmpAddAdminParameters.Add(tmpIdParameter); //tmpAddAdmin.ParameterDefinitions = tmpAddAdminParameters; //tmpDefinitions.Add(tmpAddAdmin); //#endregion //#region RemoveAdminCommand //AvorionServerCommandDefinition tmpRemoveAdmin = new AvorionServerCommandDefinition(); //tmpRemoveAdmin.ExecutionType = CommandExecutionTypes.Console; //tmpRemoveAdmin.DisplayName = "Remove Admin"; //tmpRemoveAdmin.HasParameters = true; //tmpRemoveAdmin.InternalName = "/admin --remove"; //tmpRemoveAdmin.ParameterDefinitions = tmpAddAdminParameters; //tmpDefinitions.Add(tmpRemoveAdmin); //#endregion //#region Blacklist ////Add //AvorionServerCommandDefinition tmpAddBlacklist = new AvorionServerCommandDefinition(); //tmpAddBlacklist.ExecutionType = CommandExecutionTypes.Console; //tmpAddBlacklist.DisplayName = "Add to Blacklist"; //tmpAddBlacklist.HasParameters = true; //tmpAddBlacklist.InternalName = "/blacklist --add"; //tmpAddBlacklist.ParameterDefinitions = tmpAddAdminParameters; //tmpDefinitions.Add(tmpAddBlacklist); ////Remove //AvorionServerCommandDefinition tmpRemoveBlacklist = new AvorionServerCommandDefinition(); //tmpRemoveBlacklist.ExecutionType = CommandExecutionTypes.Console; //tmpRemoveBlacklist.DisplayName = "Remove From Blacklist"; //tmpRemoveBlacklist.HasParameters = true; //tmpRemoveBlacklist.InternalName = "/blacklist --remove"; //tmpRemoveBlacklist.ParameterDefinitions = tmpAddAdminParameters; //tmpDefinitions.Add(tmpRemoveBlacklist); //#endregion //#region accessMode //AvorionServerCommandDefinition tmpActivateWhitelist = new AvorionServerCommandDefinition(); //tmpActivateWhitelist.ExecutionType = CommandExecutionTypes.Console; //tmpActivateWhitelist.DisplayName = "Activate Whitelist"; //tmpActivateWhitelist.HasParameters = false; //tmpActivateWhitelist.InternalName = "/whitelist --activate"; //tmpDefinitions.Add(tmpActivateWhitelist); //AvorionServerCommandDefinition tmpActivateBlacklist = new AvorionServerCommandDefinition(); //tmpActivateBlacklist.ExecutionType = CommandExecutionTypes.Console; //tmpActivateBlacklist.DisplayName = "Activate Blacklist"; //tmpActivateBlacklist.HasParameters = false; //tmpActivateBlacklist.InternalName = "/blacklist --activate"; //tmpDefinitions.Add(tmpActivateBlacklist); //#endregion //#region Kick // AvorionServerCommandDefinition tmpKickCommand = new AvorionServerCommandDefinition(); // tmpKickCommand.ExecutionType = CommandExecutionTypes.Console; // tmpKickCommand.DisplayName = "Kick Player"; // tmpKickCommand.HasParameters = true; // tmpKickCommand.InternalName = "/kick"; // AvorionServerCommandParameterDefinition tmpKickNameParameter = new AvorionServerCommandParameterDefinition(); // List<AvorionServerCommandParameterDefinition> tmpKickParameters = new List<AvorionServerCommandParameterDefinition>(); //tmpKickNameParameter.DisplayName = "Player Name"; // AvorionServerCommandParameterDefinition tmpKickReasonParameter = new AvorionServerCommandParameterDefinition(); // tmpKickReasonParameter.DisplayName = "Reason"; // tmpKickParameters.Add(tmpKickReasonParameter); // tmpKickParameters.Add(tmpKickNameParameter); // tmpKickCommand.ParameterDefinitions = tmpKickParameters; //tmpDefinitions.Add(tmpKickCommand); //#endregion //File.WriteAllText(Path.Combine(Constants.SettingsFolderName, Constants.CommandDefinitonsFileName), JsonConvert.SerializeObject(tmpDefinitions, Formatting.Indented)); //AvorionServerCommand tmpCommand = new AvorionServerCommand(tmpBroadcastDefinition,new List<AvorionServerCommandParameter> { new AvorionServerCommandParameter { Content="WebRequestTestSender"}, new AvorionServerCommandParameter { Content = "0" }, new AvorionServerCommandParameter { Content = "Hello From Webrequest" } }); //File.WriteAllText(Path.Combine(Constants.SettingsFolderName, "Broadcast.json"), JsonConvert.SerializeObject(tmpCommand, Formatting.Indented)); //AvorionServerCommand tmpStopCommand = new AvorionServerCommand(tmpStopDefintion); //File.WriteAllText(Path.Combine(Constants.SettingsFolderName, "Save.json"), JsonConvert.SerializeObject(tmpStopCommand, Formatting.Indented)); //AvorionServerCommand tmpKickExportCommand = new AvorionServerCommand(tmpKickCommand, new List<AvorionServerCommandParameter> { new AvorionServerCommandParameter { Content="targetPlayer"}, new AvorionServerCommandParameter { Content = "Reason"} }); //File.WriteAllText(Path.Combine(Constants.SettingsFolderName, "Kick.json"), JsonConvert.SerializeObject(tmpKickExportCommand, Formatting.Indented)); }