ConsoleTokenPatches
A static class in TavernLib, TavernLib.Patches.
Harmony patches on the game's websocket console (ServerConsoleManager, WebSocketCommandHandler, CommandPart, CommandResult) that put TavernLib's console tokens in charge of logins, named token limits and the token log. Server only.
- Listed in TavernLib.Patches
- Nested types
RefusedLoginFilter - Attributes
HarmonyPatch
Fields
3 private and internal fields
| Member | What it is |
|---|---|
private static WebSocketCommandHandler _authorizing | The websocket handler currently inside ProcessAuthorization on this thread, or null. |
private static bool? _verdict | This thread's login verdict from CheckConsoleLogin, which KeepConsoleVerdict writes back over the result. |
private static readonly FieldInfo ConnectionField | Reflection handle on the private connection field of WebSocketCommandHandler, used to close a session. |
Methods
| Member | What it is |
|---|---|
static bool CheckConsoleLogin(JwtSecurityToken token, ref Task<bool> __result) | Prefix on ServerConsoleManager.ValidateConsoleToken that skips it and checks the token with ConsoleAuth.Validate, logging refusals without the token. |
static void GateNamedTokens(CommandPart __instance, CommandContext context, ref bool __result) | Postfix on CommandPart.RequirementsAreMet that turns it false for a command or module a named token wasn't given, so it can't run or see it. |
static void KeepConsoleVerdict(ref Task<bool> __result) | Postfix on ValidateConsoleToken that puts TavernLib's verdict back, so another mod's prefix can't change it. |
static void LogConsoleCommand(WebSocketCommandHandler __instance, string command, bool wasSuccessful, ref string output) | Prefix on WebSocketCommandHandler.TryLogConsoleCommandExecutionWithEventStream: redacts tokens from the output and writes the command to the token log. |
static void MarkWebSocketLogin(WebSocketCommandHandler __instance) | Prefix on WebSocketCommandHandler.ProcessAuthorization that remembers, on this thread, which websocket handler is logging in. |
static bool QuietTokenResults(CommandResult __instance) | Prefix on CommandResult.Log that skips it for commands in the token module, so token text stays out of the game's log. |
static void UnmarkWebSocketLogin() | Finalizer on ProcessAuthorization that clears the login remembered by MarkWebSocketLogin. |
8 private and internal methods
| Member | What it is |
|---|---|
private static string AddressOf(IRemoteConsoleHandler handler) | The session's remote address without the port, or null if it isn't a websocket session. |
private static int Close(Func<IRemoteConsoleHandler, bool> which, string whose) | Closes every connected websocket session the filter picks and returns how many it closed. |
internal static int CloseOwnerSessions(WebSocketCommandHandler keep) | Internal: closes every websocket console session logged in with the owner token, except the one given. Returns how many it closed. |
internal static int CloseSessions(string id) | Internal: closes every websocket console session of the named token with that id. Returns how many. Used by token revoke. |
private static IRemoteConsoleHandler[] ConnectedHandlers() | Copies the list of connected console handlers, retrying when the game changes it from another thread. |
internal static int CountSessions(string id) | Internal: how many connected console sessions are logged in with the named token with that id. |
internal static void Start() | Internal, server: writes console connects and disconnects to the token log and adds RefusedLoginFilter to NLog once the app has started. |
private static bool WouldMatchUnrestricted(string command, UserInfoWithPermissions user) | True when the command would be found if the named token's own limits were left out, which makes a failure count as refused. |