add lodestone auth, add rate limiting middleware
This commit is contained in:
		| @@ -25,6 +25,13 @@ namespace MareSynchronosServer.Hubs | ||||
|             var ownPairData = await _dbContext.ClientPairs.Where(u => u.User.UID == userid).ToListAsync(); | ||||
|             var auth = await _dbContext.Auth.SingleAsync(u => u.UserUID == userid); | ||||
|  | ||||
|             var lodestone = await _dbContext.LodeStoneAuth.SingleOrDefaultAsync(a => a.User.UID == userid); | ||||
|  | ||||
|             if (lodestone != null) | ||||
|             { | ||||
|                 _dbContext.Remove(lodestone); | ||||
|             } | ||||
|  | ||||
|             while (_dbContext.Files.Any(f => f.Uploader == userEntry)) | ||||
|             { | ||||
|                 await Task.Delay(1000); | ||||
| @@ -130,47 +137,6 @@ namespace MareSynchronosServer.Hubs | ||||
|             MareMetrics.UserPushDataTo.Inc(visibleCharacterIds.Count); | ||||
|         } | ||||
|  | ||||
|         /*[HubMethodName(Api.InvokeUserRegister)] | ||||
|         public async Task<string> Register() | ||||
|         { | ||||
|             using var sha256 = SHA256.Create(); | ||||
|             var user = new User(); | ||||
|  | ||||
|             var hasValidUid = false; | ||||
|             while (!hasValidUid) | ||||
|             { | ||||
|                 var uid = GenerateRandomString(10); | ||||
|                 if (_dbContext.Users.Any(u => u.UID == uid)) continue; | ||||
|                 user.UID = uid; | ||||
|                 hasValidUid = true; | ||||
|             } | ||||
|  | ||||
|             // make the first registered user on the service to admin | ||||
|             if (!await _dbContext.Users.AnyAsync()) | ||||
|             { | ||||
|                 user.IsAdmin = true; | ||||
|             } | ||||
|  | ||||
|             var computedHash = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(GenerateRandomString(64)))).Replace("-", ""); | ||||
|             var auth = new Auth() | ||||
|             { | ||||
|                 HashedKey = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(computedHash))) | ||||
|                     .Replace("-", ""), | ||||
|                 User = user | ||||
|             }; | ||||
|  | ||||
|             _dbContext.Users.Add(user); | ||||
|             _dbContext.Auth.Add(auth); | ||||
|  | ||||
|             _logger.LogInformation("User registered: " + user.UID); | ||||
|  | ||||
|             MareMetrics.UsersRegistered.Inc(); | ||||
|  | ||||
|             await _dbContext.SaveChangesAsync(); | ||||
|             return computedHash; | ||||
|         }*/ | ||||
|  | ||||
|  | ||||
|         [Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)] | ||||
|         [HubMethodName(Api.SendUserPairedClientAddition)] | ||||
|         public async Task SendPairedClientAddition(string uid) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Stanley Dimant
					Stanley Dimant