Refactoring using Claims more, add Server Side Messaging (#20)
* add some refactoring based on claims, handle chara ident inside claim, fix discord userid in log * improve authentication responses, add server side messaging * update server to mainline api Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
		| @@ -1,4 +1,4 @@ | ||||
| using System.Security.Claims; | ||||
| using MareSynchronosServer.Hubs; | ||||
| using Microsoft.AspNetCore.SignalR; | ||||
|  | ||||
| namespace MareSynchronosServer.Utils; | ||||
| @@ -7,6 +7,6 @@ public class IdBasedUserIdProvider : IUserIdProvider | ||||
| { | ||||
|     public string GetUserId(HubConnectionContext context) | ||||
|     { | ||||
|         return context.User!.Claims.SingleOrDefault(c => string.Equals(c.Type, ClaimTypes.NameIdentifier, StringComparison.Ordinal))?.Value; | ||||
|         return context.User!.Claims.SingleOrDefault(c => string.Equals(c.Type, MareClaimTypes.Uid, StringComparison.Ordinal))?.Value; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -22,12 +22,12 @@ public class MareHubLogger | ||||
|     public void LogCallInfo(object[] args = null, [CallerMemberName] string methodName = "") | ||||
|     { | ||||
|         string formattedArgs = args != null && args.Length != 0 ? "|" + string.Join(":", args) : string.Empty; | ||||
|         _logger.LogInformation("{uid}:{method}{args}", _hub.AuthenticatedUserId, methodName, formattedArgs); | ||||
|         _logger.LogInformation("{uid}:{method}{args}", _hub.UserUID, methodName, formattedArgs); | ||||
|     } | ||||
|  | ||||
|     public void LogCallWarning(object[] args = null, [CallerMemberName] string methodName = "") | ||||
|     { | ||||
|         string formattedArgs = args != null && args.Length != 0 ? "|" + string.Join(":", args) : string.Empty; | ||||
|         _logger.LogWarning("{uid}:{method}{args}", _hub.AuthenticatedUserId, methodName, formattedArgs); | ||||
|         _logger.LogWarning("{uid}:{method}{args}", _hub.UserUID, methodName, formattedArgs); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 rootdarkarchon
					rootdarkarchon