Class ServerAuthenticator
- Namespace
- FishMMO.Server.Implementation
- Assembly
- FishMMO.Server.dll
SRP-6a server authenticator. Delegates all handshake, channel, worker, and protocol logic to SrpAuthenticatorCore<TConnection> in FishMMO-Auth. This class bridges FishNet broadcast events to the core and provides Unity/DB callbacks.
public class ServerAuthenticator : BaseServerAuthenticator, IServerAuthenticator
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourAuthenticatorServerAuthenticator
- Implements
- Inherited Members
-
Authenticator.InitializedAuthenticator.NetworkManagerAuthenticator.OnRemoteConnection(NetworkConnection)MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Properties
Core
The engine-independent authenticator core. Created by InitializeCoreInstance().
protected override BaseAuthenticatorCore<NetworkConnection> Core { get; }
Property Value
- BaseAuthenticatorCore<NetworkConnection>
LoginServerId
LoginServer database ID embedded in issued tokens.
public long LoginServerId { get; set; }
Property Value
TokenSigningKey
HMAC signing key for token generation. Set by LoginServerSystem after workers start.
public byte[] TokenSigningKey { get; set; }
Property Value
- byte[]
TokenSigningKeyId
Database ID of the HMAC signing key used for issued tokens.
public long TokenSigningKeyId { get; set; }
Property Value
TotpMasterKey
AES-256 master key for TOTP secret decryption. Set by LoginServerSystem after workers start.
public byte[] TotpMasterKey { get; set; }
Property Value
- byte[]
Methods
AtomicSwapSigningKey(byte[], long, byte[])
Atomically swaps the signing key, key ID, and TOTP master key on the core, ensuring concurrent token-issuance reads always see a consistent tuple.
public void AtomicSwapSigningKey(byte[] newKey, long newKeyId, byte[] newTotpMasterKey)
Parameters
Remarks
Key material lifetime: Old key arrays are intentionally NOT zeroed by this method because a concurrent reader thread may hold a reference to them (obtained before the lock). Calling ZeroMemory(byte[]) here would corrupt in-flight auth operations that are still using the old key material. The old arrays will be reclaimed by the garbage collector.
NOTE: Old key arrays remain in heap until GC. An attacker with a memory dump could recover historical signing keys. For defense-in-depth, consider pinning+zeroing old keys after all concurrent readers have completed.
All key material is zeroed during server shutdown via ShutdownWorkers(). Any arrays held exclusively by the core are cleared at that point. If a subclass holds additional references (e.g. backings set before the core existed), it must zero them itself in its shutdown path.
CreateAccountManager()
Creates the appropriate IAccountManager<TConnection> for this authenticator type. SRP authenticators return an SrpAccountManager, token authenticators return a TokenAccountManager.
public override IAccountManager<NetworkConnection> CreateAccountManager()
Returns
- IAccountManager<NetworkConnection>
InitializeCoreInstance()
Creates the protocol-specific core instance. Called at the start of InitializeWorkers() before workers are started. Subclasses must create and store their typed core reference here.
protected override void InitializeCoreInstance()
IsConnectionAwaitingQueueAdmission(NetworkConnection)
Whether this connection is waiting for login-queue admission, and so should be exempt from the handshake timeout. Only the Login Server has a queue; the default is false everywhere else.
protected override bool IsConnectionAwaitingQueueAdmission(NetworkConnection conn)
Parameters
connNetworkConnection
Returns
Remarks
Consults the login queue. A queued client holds an open, unauthenticated connection for the whole wait — which the handshake-timeout sweep would otherwise treat as a client that never handshook and disconnect.
OnUpdate()
Calls TickRateLimits() every frame.
protected override void OnUpdate()
RegisterProtocolHandlers(NetworkManager)
Registers protocol-specific broadcast handlers (e.g., SRP or token auth). Called once during InitializeOnce(NetworkManager).
protected override void RegisterProtocolHandlers(NetworkManager networkManager)
Parameters
networkManagerNetworkManager