test: add permission enforcement and NKey integration tests
Fix NKey nonce verification: the NATS client signs the nonce string (ASCII bytes of the base64url-encoded nonce), not the raw nonce bytes. Pass the encoded nonce string bytes to the authenticator for verification.
This commit is contained in:
@@ -99,7 +99,10 @@ public sealed class NatsServer : IMessageRouter, ISubListAccess, IDisposable
|
||||
var clientInfo = _serverInfo;
|
||||
if (_authService.NonceRequired)
|
||||
{
|
||||
nonce = _authService.GenerateNonce();
|
||||
var rawNonce = _authService.GenerateNonce();
|
||||
var nonceStr = _authService.EncodeNonce(rawNonce);
|
||||
// The client signs the nonce string (ASCII), not the raw bytes
|
||||
nonce = Encoding.ASCII.GetBytes(nonceStr);
|
||||
clientInfo = new ServerInfo
|
||||
{
|
||||
ServerId = _serverInfo.ServerId,
|
||||
@@ -109,7 +112,7 @@ public sealed class NatsServer : IMessageRouter, ISubListAccess, IDisposable
|
||||
Port = _serverInfo.Port,
|
||||
MaxPayload = _serverInfo.MaxPayload,
|
||||
AuthRequired = _serverInfo.AuthRequired,
|
||||
Nonce = _authService.EncodeNonce(nonce),
|
||||
Nonce = nonceStr,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user