none
MQTT Authentification in Asp .Net Core 3.1 RRS feed

  • Question

  • Hello can anyone advise how to implement Authentification(username and password FROM DB level) in MQTT platform, currently have few ideas in mind:

    1. Authenticate on every message received from client, problem is database would get huge load just for checking if many users are provide valid login data.

    2. Implement other authentication solution(JWT?), then how to implement in current solution(link to github)

    There are two projects one Asp .Net core MQTT "server" and other .Net Core Console App "client"

    Github link to plain MQTT implementation(Mosquitto config also included if anyone needs it)

    Github

    Thanks for help.

    Monday, March 23, 2020 8:15 PM

All replies

  • ASP.NET Core has a forum in ASP.NET forums.

    http://forums.asp.net/

    Monday, March 23, 2020 9:08 PM
  • Hi speed258,

    Thank you for posting here.

    You can use JWT authentication  to get access token from MQTT to access the protected resource, that will avoid validating credentials on each request .

    You can refer to below articles for how to implement OAUTH2 in MQTT :

    OAuth 2.0 & MQTT - MQTT Security Fundamentals

    Asp.net core provide AddOAuth middleware to help implement authentication using OAuth2 :

    Authenticate with OAuth 2.0 in ASP.NET Core 2.0

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 26, 2020 9:03 AM