mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-18 10:26:11 +08:00
Fix support for enhanced authentication (#2132)
* Implement enhanced authentication for client and server. * Update samples * Add abstraction layer * Merge master * Use dedicated class for public API. * Update release notes * Rename methods to fit naming scheme * Fix unit tests and samples
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
using MQTTnet.Packets;
|
||||
|
||||
namespace MQTTnet.Server.EnhancedAuthentication;
|
||||
|
||||
public static class ExchangeEnhancedAuthenticationResultFactory
|
||||
{
|
||||
public static ExchangeEnhancedAuthenticationResult Create(MqttAuthPacket authPacket)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(authPacket);
|
||||
|
||||
return new ExchangeEnhancedAuthenticationResult
|
||||
{
|
||||
AuthenticationData = authPacket.AuthenticationData,
|
||||
|
||||
ReasonString = authPacket.ReasonString,
|
||||
UserProperties = authPacket.UserProperties
|
||||
};
|
||||
}
|
||||
|
||||
public static ExchangeEnhancedAuthenticationResult Create(MqttDisconnectPacket disconnectPacket)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(disconnectPacket);
|
||||
|
||||
return new ExchangeEnhancedAuthenticationResult
|
||||
{
|
||||
AuthenticationData = null,
|
||||
ReasonString = disconnectPacket.ReasonString,
|
||||
UserProperties = disconnectPacket.UserProperties
|
||||
|
||||
// SessionExpiryInterval makes no sense because the connection is not yet made!
|
||||
// ServerReferences makes no sense when the client initiated a DISCONNECT!
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user