Package com.mcawful
Class PanelSessionManager
java.lang.Object
com.mcawful.PanelSessionManager
Panel login sessions that are started by signing in with a passkey.
The browser holds a random session ID in a cookie. Only the SHA-256 of the ID is kept here, and only in memory, so every session ends when the bot restarts.
- Author:
- mcawful
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA panel login session. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateSession(String username, String origin, String passkey, long lifetime) Starts a sessionstatic PanelSessionManager.SessiongetSession(HttpHeaders headers) Finds the session of a requeststatic voidrevokePasskey(String passkey) Ends all sessions that were started with a passkeystatic booleanrevokeSession(HttpHeaders headers) Ends the session of a request, if it has one and the request comes from the origin the user signed in on.static voidrevokeUser(String username) Ends all sessions of a user
-
Field Details
-
COOKIE
Name of the cookie that holds the session ID- See Also:
-
-
Method Details
-
createSession
Starts a session- Parameters:
username- the name of the user who signed inorigin- the origin the user signed in onpasskey- the primary key of the passkey that was usedlifetime- how long the session lasts, in milliseconds- Returns:
- the session ID to send to the browser in the
COOKIEcookie
-
getSession
Finds the session of a request- Parameters:
headers- theHttpHeadersof the request- Returns:
- the
PanelSessionManager.Session;nullif there is no valid session
-
revokeSession
Ends the session of a request, if it has one and the request comes from the origin the user signed in on. Other sites must not be able to sign the user out- Parameters:
headers- theHttpHeadersof the request- Returns:
trueif a session was ended
-
revokePasskey
Ends all sessions that were started with a passkey- Parameters:
passkey- the primary key of the passkey
-
revokeUser
Ends all sessions of a user- Parameters:
username- the user's name
-