Package com.mcawful

Class PanelPasskeyHandler

java.lang.Object
com.mcawful.PanelPasskeyHandler

public final class PanelPasskeyHandler extends Object
Passkey registration, management and sign-in for panel users.

Registration and management run over the authenticated panel websocket, so a user can only ever touch their own passkeys. Sign-in runs over HTTP so the bot can set the session cookie of PanelSessionManager.

Author:
mcawful
  • Method Details

    • handleWs

      public static void handleWs(ChannelHandlerContext ctx, PanelUser user, JSONObject request, JSONStringer response)
      Handles a passkey query on the panel websocket
      Parameters:
      ctx - the ChannelHandlerContext of the websocket
      user - the authenticated PanelUser
      request - the passkey object of the query, which must have an action
      response - the JSONStringer to write the single result value to
    • handleHttp

      public static void handleHttp(ChannelHandlerContext ctx, FullHttpRequest req)
      Handles a request to /panel/login/passkey/, which the login page uses to sign in with a passkey. These requests are not authenticated
      Parameters:
      ctx - the ChannelHandlerContext of the request
      req - the FullHttpRequest
    • deletePasskeys

      public static void deletePasskeys(String username)
      Removes all passkeys of a panel user and ends their sessions. Must be called when the user is deleted, so a later user with the same name does not inherit them, and when their password is reset, so nobody who had access keeps it
      Parameters:
      username - the user's name
    • renamePasskeys

      public static void renamePasskeys(String username, String newUsername)
      Moves all passkeys of a panel user to a new username and ends their sessions. Must be called when the user is renamed. Passkeys that were left under the new name are removed first, so the user does not inherit them
      Parameters:
      username - the user's current name
      newUsername - the user's new name