Contents
- Description
- Nested Class Summary
- Method Summary
- Method Details
- getInstance()
- getProfileServiceClient()
- initialize()
- checkPendingFatalError()
- initializeCredentialStore()
- shutdown()
- logout()
- getGameSession()
- setGameSession(SessionServiceClient.GameSessionResponse)
- getIdentityToken()
- getSessionToken()
- hasIdentityToken()
- hasSessionToken()
- getOAuthAccessToken()
- setServerCertificate(X509Certificate)
- getServerCertificate()
- getServerCertificateFingerprint()
- getServerSessionId()
- getAuthMode()
- isSingleplayer()
- isOwner(UUID)
- getSelectedProfile()
- getTokenExpiry()
- getAuthStatus()
- startFlowAsync(OAuthBrowserFlow)
- startFlowAsync(OAuthDeviceFlow)
- registerCredentialStore(IAuthCredentialStore)
- swapCredentialStoreProvider(AuthCredentialStoreProvider)
- cancelActiveFlow()
- getPendingProfiles()
- hasPendingProfiles()
- selectPendingProfile(int)
- selectPendingProfileByUsername(String)
- clearPendingProfiles()
Class ServerAuthManager
java.lang.Object
com.hypixel.hytale.server.core.auth.ServerAuthManager
Manages the server's authentication credentials for mutual authentication.
Supports multiple authentication modes:
- Singleplayer: Child session tokens from client via CLI, server manages refresh
- External Session: Hosting provider manages tokens externally, server auto-refreshes
- OAuth Browser: Local browser-based PKCE flow for self-hosted servers
- OAuth Device: Device authorization flow for headless/remote servers
- OAuth Store: Refresh/Access token being provided through a programmatically registered store
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAuthentication mode.static enumResult of an OAuth authentication attempt. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCancels any pending OAuth authentication flow.voidChecks for pending fatal errors from token validation.voidClears pending profile selection.static ServerAuthManagerGets the singleton instance.Gets the OAuth access token, refreshing if necessary.Returns the pending profiles awaiting selection, or null if none.Gets the Profile Service client, initializing it lazily if needed.Gets the server's unique session ID, generated at boot.booleanbooleanReturns true if there are pending profiles awaiting selection.booleanvoidInitializes the server auth manager with CLI options and environment.voidInitializes the credential store from config.booleanbooleanvoidlogout()booleanselectPendingProfile(int index) Selects a pending profile by index (1-based).booleanselectPendingProfileByUsername(String username) Selects a pending profile by username.voidvoidsetServerCertificate(X509Certificate certificate) voidshutdown()voidSwaps the credential store to one created by the given provider.
-
Method Details
-
getInstance
Gets the singleton instance. -
getProfileServiceClient
Gets the Profile Service client, initializing it lazily if needed.- Returns:
- The Profile Service client
-
initialize
public void initialize()Initializes the server auth manager with CLI options and environment. Called after Options.parse() completes.Note: Credential store is NOT initialized here - call
initializeCredentialStore()after plugins have had a chance to register custom providers. -
checkPendingFatalError
public void checkPendingFatalError()Checks for pending fatal errors from token validation. If tokens failed validation at startup, shuts down with AUTH_FAILED. -
initializeCredentialStore
public void initializeCredentialStore()Initializes the credential store from config. Called after plugins have had a chance to register custom providers. If the store contains saved credentials, attempts to restore the session. -
shutdown
public void shutdown() -
logout
public void logout() -
getGameSession
-
setGameSession
-
getIdentityToken
-
getSessionToken
-
hasIdentityToken
public boolean hasIdentityToken() -
hasSessionToken
public boolean hasSessionToken() -
getOAuthAccessToken
Gets the OAuth access token, refreshing if necessary. This token can be used to authenticate with services that accept OAuth bearer tokens (e.g., account-data service for game-assets). -
setServerCertificate
-
getServerCertificate
-
getServerCertificateFingerprint
-
getServerSessionId
Gets the server's unique session ID, generated at boot. Used as the JWT audience for player auth tokens to ensure tokens are scoped to this server instance. -
getAuthMode
-
isSingleplayer
public boolean isSingleplayer() -
isOwner
-
getSelectedProfile
-
getTokenExpiry
-
getAuthStatus
-
startFlowAsync
public CompletableFuture<ServerAuthManager.AuthResult> startFlowAsync(@Nonnull OAuthBrowserFlow flow) -
startFlowAsync
-
registerCredentialStore
public CompletableFuture<ServerAuthManager.AuthResult> registerCredentialStore(IAuthCredentialStore store) -
swapCredentialStoreProvider
Swaps the credential store to one created by the given provider. Migrates any existing tokens to the new store.- Parameters:
provider- The provider to create the new store from
-
cancelActiveFlow
public boolean cancelActiveFlow()Cancels any pending OAuth authentication flow.- Returns:
- true if a flow was cancelled, false if none was active
-
getPendingProfiles
Returns the pending profiles awaiting selection, or null if none. -
hasPendingProfiles
public boolean hasPendingProfiles()Returns true if there are pending profiles awaiting selection. -
selectPendingProfile
public boolean selectPendingProfile(int index) Selects a pending profile by index (1-based).- Parameters:
index- 1-based index of the profile to select- Returns:
- true if selection succeeded, false otherwise
-
selectPendingProfileByUsername
Selects a pending profile by username.- Parameters:
username- The username to select- Returns:
- true if selection succeeded, false otherwise
-
clearPendingProfiles
public void clearPendingProfiles()Clears pending profile selection.
-