mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 19:58:57 +08:00
Fix wrong password handling (string -> byte[])
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using IronPython.Runtime;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -22,6 +23,12 @@ namespace MQTTnet.Server.Mqtt
|
||||
{
|
||||
try
|
||||
{
|
||||
string passwordString = null;
|
||||
if (context.Password != null)
|
||||
{
|
||||
passwordString = Encoding.UTF8.GetString(context.Password);
|
||||
}
|
||||
|
||||
var pythonContext = new PythonDictionary
|
||||
{
|
||||
{ "client_id", context.ClientId },
|
||||
@@ -29,6 +36,7 @@ namespace MQTTnet.Server.Mqtt
|
||||
{ "is_secure_connection", context.IsSecureConnection },
|
||||
{ "username", context.Username },
|
||||
{ "password", context.Password },
|
||||
{ "password_string", passwordString },
|
||||
{ "result", PythonConvert.Pythonfy(context.ReturnCode) }
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ def on_validate_client_connection(context):
|
||||
context["result"] = "connection_refused_not_authorized"
|
||||
return
|
||||
|
||||
if context["password"] != "secret":
|
||||
if context["password_string"] != "secret":
|
||||
context["result"] = "connection_refused_not_authorized"
|
||||
|
||||
print(context)
|
||||
|
||||
Reference in New Issue
Block a user