/// <summary> /// 开启白名单 /// </summary> /// <param name="type">白名单类型,USERNAME 为用户名、Email 为邮箱、Phone 为手机号。</param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task Enable(WhitelistType type, CancellationToken cancellationToken = default) { var config = new RegisterWhiteListConfigInput(); switch (type) { case WhitelistType.USERNAME: config.UsernameEnabled = true; break; case WhitelistType.EMAIL: config.EmailEnabled = true; break; case WhitelistType.PHONE: config.PhoneEnabled = true; break; default: throw new AuthingException("不支持的白名单类型"); } var param = new UpdateUserpoolParam(new UpdateUserpoolInput() { Whitelist = config, }); await client.GetAccessToken(); await client.Request <UpdateUserpoolResponse>(param.CreateRequest(), cancellationToken); }
public static void Register(WhitelistType type, int itemID) { switch (type) { case WhitelistType.AlchemyIngredient: AlchemistBagWhitelist.Add(itemID); break; case WhitelistType.Ore: OreWhitelist.Add(itemID); break; case WhitelistType.Explosive: ExplosiveWhitelist.Add(itemID); break; case WhitelistType.Fishing: FishingWhitelist.Add(itemID); break; case WhitelistType.Seed: SeedWhitelist.Add(itemID); break; } }
private static void DeleteSyncRow(WhitelistType whitelistType, string Ip, BatchQueryBuilder batchQueryBuilder) { var command = new MySqlCommand($"DELETE FROM FamilyRpServerAccess.{schemaTable[whitelistType]} WHERE IP = @IP;"); command.Parameters.AddWithValue("IP", Ip); batchQueryBuilder.AppendSqlCommand(command); }
/// <summary> /// 获取白名单 /// </summary> /// <param name="type">白名单类型,USERNAME 为用户名、Email 为邮箱、Phone 为手机号。</param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <IEnumerable <WhiteList> > List(WhitelistType type, CancellationToken cancellationToken = default) { var param = new WhitelistParam(type); var res = await client.Request <WhitelistResponse>(param.CreateRequest(), cancellationToken); return(res.Result); }
private static void UpdateSyncStatus(WhitelistType whitelistType, string Ip, string targetState, BatchQueryBuilder batchQueryBuilder) { var command = new MySqlCommand($"UPDATE FamilyRpServerAccess.{schemaTable[whitelistType]} SET State = @State WHERE IP = @IP;"); command.Parameters.AddWithValue("State", targetState); command.Parameters.AddWithValue("IP", Ip); batchQueryBuilder.AppendSqlCommand(command); }
private static void RemoveUserFromFirewall(WhitelistType whitelistType, string Ip, BatchQueryBuilder batchQueryBuilder) { Console.WriteLine($"Removing IP {Ip} as {whitelistType}"); // TODO: Delete IP from server here // Use Config.MasterIps and whitelistType to map to correct server // If success: DeleteSyncRow(whitelistType, Ip, batchQueryBuilder); }
/// <summary> /// 移除白名单 /// </summary> /// <param name="type">白名单类型,USERNAME 为用户名、Email 为邮箱、Phone 为手机号。</param> /// <param name="list">白名单列表,请注意邮箱不区分大小写。</param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <IEnumerable <WhiteList> > Remove( WhitelistType type, IEnumerable <string> list, CancellationToken cancellationToken = default) { var param = new RemoveWhitelistParam(type, list); await client.GetAccessToken(); var res = await client.Request <RemoveWhitelistResponse>(param.CreateRequest(), cancellationToken); return(res.Result); }
private static void AddUserToFirewall(WhitelistType whitelistType, string Ip, BatchQueryBuilder batchQueryBuilder) { Console.WriteLine($"Adding IP {Ip} as {whitelistType}"); // TODO: Delete IP from server here // Example: // var ci = new CsfInterface.Client(); // await ci.LoginToCsf("username", "password", "baseUrl"); // await ci.AddTempWhiteListIp(Ip, "", "30124", 200); // Use Config.MasterIps and whitelistType to map to correct server // If success: UpdateSyncStatus(whitelistType, Ip, "Keep", batchQueryBuilder); }
private static Dictionary <string, string> FetchIps(WhitelistType whitelistType, WhitelistActionFilter whitelistActionFilter) { using (var conn = new MySqlConnection(config.ConnString)) { conn.Open(); MySqlCommand command = new MySqlCommand($"SELECT IP, State FROM FamilyRpServerAccess.{schemaTable[whitelistType]}{qualifiers[whitelistActionFilter]};", conn); var reader = command.ExecuteReader(); Dictionary <string, string> result = new Dictionary <string, string>(); while (reader.Read()) { result.Add(Convert.ToString(reader["IP"]), Convert.ToString(reader["State"])); } reader.Dispose(); return(result); } }
/// <summary> /// 开启白名单 /// </summary> /// <param name="type">白名单类型,USERNAME 为用户名、Email 为邮箱、Phone 为手机号。</param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task Enable(WhitelistType type, CancellationToken cancellationToken = default) { var config = new RegisterWhiteListConfigInput { EmailEnabled = type == WhitelistType.EMAIL, PhoneEnabled = type == WhitelistType.PHONE, UsernameEnabled = type == WhitelistType.USERNAME, }; var param = new UpdateUserpoolParam(new UpdateUserpoolInput() { Whitelist = config, }); await client.Request <UpdateUserpoolResponse>(param.CreateRequest(), cancellationToken); // TODO: 缺少返回类型 }
/// <summary> /// Return a JSON representation of this object. /// </summary> /// <param name="CustomTokenSerializer">A delegate to serialize custom token JSON objects.</param> /// <param name="CustomEnergyContractSerializer">A delegate to serialize custom energy contract JSON objects.</param> public JObject ToJSON(CustomJObjectSerializerDelegate <Token> CustomTokenSerializer = null, CustomJObjectSerializerDelegate <EnergyContract> CustomEnergyContractSerializer = null) { var JSON = JSONObject.Create( new JProperty("country_code", CountryCode.ToString()), new JProperty("party_id", PartyId.ToString()), new JProperty("uid", Id.ToString()), new JProperty("type", Type.ToString()), new JProperty("contract_id", ContractId.ToString()), VisualNumber.IsNotNullOrEmpty() ? new JProperty("visual_number", VisualNumber) : null, new JProperty("issuer", Issuer), GroupId.HasValue ? new JProperty("group_id", GroupId.ToString()) : null, new JProperty("valid", IsValid), new JProperty("whitelist", WhitelistType.ToString()), UILanguage.HasValue ? new JProperty("language", UILanguage.ToString()) : null, DefaultProfile.HasValue ? new JProperty("default_profile_type", DefaultProfile.ToString()) : null, EnergyContract.HasValue ? new JProperty("energy_contract", EnergyContract.Value.ToJSON(CustomEnergyContractSerializer)) : null, new JProperty("last_updated", LastUpdated.ToIso8601()) ); return(CustomTokenSerializer != null ? CustomTokenSerializer(this, JSON) : JSON); }
public static void Register(WhitelistType type, int itemID) { switch (type) { case WhitelistType.AlchemyIngredient: if (!AlchemistBagWhitelist.Contains(itemID)) { AlchemistBagWhitelist.Add(itemID); } break; case WhitelistType.Ore: if (!OreWhitelist.Contains(itemID)) { OreWhitelist.Add(itemID); } break; case WhitelistType.Explosive: if (!ExplosiveWhitelist.Contains(itemID)) { ExplosiveWhitelist.Add(itemID); } break; case WhitelistType.Fishing: if (!FishingWhitelist.Contains(itemID)) { FishingWhitelist.Add(itemID); } break; case WhitelistType.Seed: if (!SeedWhitelist.Contains(itemID)) { SeedWhitelist.Add(itemID); } break; } }