<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jeferson Moura</title>
    <description>The latest articles on DEV Community by Jeferson Moura (@jefmoura).</description>
    <link>https://dev.to/jefmoura</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F218656%2F752d5da3-72d9-4a5f-9a76-aff4d7fdeb27.jpeg</url>
      <title>DEV Community: Jeferson Moura</title>
      <link>https://dev.to/jefmoura</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jefmoura"/>
    <language>en</language>
    <item>
      <title>LDAP Auth in Buildly Core</title>
      <dc:creator>Jeferson Moura</dc:creator>
      <pubDate>Wed, 05 Feb 2020 09:26:10 +0000</pubDate>
      <link>https://dev.to/buildly/ldap-auth-in-buildly-core-420</link>
      <guid>https://dev.to/buildly/ldap-auth-in-buildly-core-420</guid>
      <description>&lt;p&gt;Several enterprise companies ask engineers to integrate their application authentication with LDAP (Lightweight Directory Access Protocol) or Active Directory (AD), Microsoft’s proprietary solution for storing user or employee information. The focus of this article is to explain how to integrate Buildly with an LDAP server.&lt;/p&gt;

&lt;h1&gt;
  
  
  LDAP
&lt;/h1&gt;

&lt;p&gt;LDAP, the Lightweight Directory Access Protocol, is a mature, flexible, and well supported standards-based mechanism for interacting with directory servers. It’s often used for authentication and storing information about users, groups, and applications, but an LDAP directory server is a fairly general-purpose data store and can be used in a wide variety of applications.&lt;a href="https://ldap.com/"&gt;[1]&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LDAP can define permissions, set by the admin to permit just certain individuals to access the LDAP database, and schema, to describe the format and properties of data in the server.&lt;/p&gt;

&lt;h1&gt;
  
  
  Active Directory
&lt;/h1&gt;

&lt;p&gt;Active Directory is used to store user information. It helps to work with interconnected, complex and different network resources.&lt;/p&gt;

&lt;p&gt;A directory service, such as Active Directory Domain Services (AD DS), provides the methods for storing directory data and making this data available to network users and administrators. For example, AD DS stores information about user accounts, such as names, passwords, phone numbers, and so on, and enables other authorized users on the same network to access this information.&lt;a href="https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/get-started/virtual-dc/active-directory-domain-services-overview"&gt;[2]&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Configure Buildly LDAP connection
&lt;/h1&gt;

&lt;p&gt;Before start&lt;br&gt;
In our example, we’re using OpenLDAP as the LDAP server, so we also need an instance of it up and running. There are a couple of tutorials on the internet of how to start a LDAP server, so we’re not going to explain how to do it here but share some links that should help you. You can also use Azure Active Directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  OpenLDAP
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.tecmint.com/install-openldap-server-for-centralized-authentication/"&gt;How To Install OpenLDAP Server for Centralized Authentication&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.linux.com/tutorials/how-install-openldap-ubuntu-server-1804/"&gt;How to Install OpenLDAP on Ubuntu Server 18.04&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Active Directory
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/deploy/virtual-dc/adds-on-azure-vm"&gt;Install a new Active Directory forest using Azure CLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/active-directory-domain-services/tutorial-create-instance"&gt;Create and configure an Azure Active Directory Domain Services instance&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Configure Buildly
&lt;/h2&gt;

&lt;p&gt;First of all, we need to have a Buildly Core instance up and running locally, so we can safely expose our services and use an LDAP server to retrieve users’ data for authentication. To know how to quickly have a local instance of Buildly Core, go through the Quickstart documentation.&lt;/p&gt;

&lt;p&gt;Now, we need to configure Buildly Core to connect to our LDAP server, so we have to have the URI, username, password and base domain name for the user search in hands. Buildly Core uses specific environment variables to configure its LDAP connection. These are the environment variables with our LDAP server values:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Eo54Nx5k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-41-09.950Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Eo54Nx5k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-41-09.950Z.png" alt="ldap config"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can specify each parameter using -e, –env, and/or –env-file flags to set simple (non-array) environment variables when running docker containers but if you are running Buildly Core with docker compose, you can update the &lt;em&gt;docker-compose.yml&lt;/em&gt; file with the new environment variables.&lt;/p&gt;

&lt;p&gt;Let’s run Buildly Core with the new configuration and test the authentication. But first of all, we are going to list all users from our current Buildly Core instance using superuser powers.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yLN0gfut--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-56-58.111Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yLN0gfut--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-56-58.111Z.png" alt="get superuser"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see in the response below, currently, there’s no other user besides the superuser.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_T7epGFp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-58-52.795Z-613x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_T7epGFp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-58-52.795Z-613x1024.png" alt="superuser data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have already added a user called Rick Sanchez to our LDAP server with username rick and password admin. We will send the following request to Buildly Core to authenticate with it:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--djb6F_lH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-43-15.042Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--djb6F_lH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-43-15.042Z.png" alt="auth rick"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Buildly Core responded with an access token for our user:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8e8ai72I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-44-49.707Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8e8ai72I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-44-49.707Z.png" alt="rick oauth token"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since this user didn’t exist in the Buildly database before, it should be created now. Let’s check that.&lt;/p&gt;

&lt;p&gt;Example of request:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PKB-MsP---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-45-49.847Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PKB-MsP---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-45-49.847Z.png" alt="get rick"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Buildly returns all information about my user:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tVbhoVtz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-47-01.455Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tVbhoVtz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-47-01.455Z.png" alt="rick data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, I will change the first and last name of the user in our LDAP server, then authenticate with it again and check if its name was updated in the Buildly Core database.&lt;/p&gt;

&lt;p&gt;This is the data of the user in the LDAP server.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8-nroAMU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/jOz0qI8_XW08S3kGGNcwhGSAVHlgGiD7R0dL93r80IbZhodSWeXl_XqaicXDoJW0Yd2f18jJnKJjvslE7gLc-em2MVCC9yICv6kzuU_rqoTjSH-Q-WkLZbbZE3hOQ-qh2ll9SGcr" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8-nroAMU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/jOz0qI8_XW08S3kGGNcwhGSAVHlgGiD7R0dL93r80IbZhodSWeXl_XqaicXDoJW0Yd2f18jJnKJjvslE7gLc-em2MVCC9yICv6kzuU_rqoTjSH-Q-WkLZbbZE3hOQ-qh2ll9SGcr" alt="server data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s authenticate to Buildly Core again:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o8em9OVV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-48-21.184Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o8em9OVV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-48-21.184Z.png" alt="auth again"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s retrieve the user data:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o-XixPpq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-49-35.095Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o-XixPpq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-49-35.095Z.png" alt="get rick data again"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IXgXZysO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-50-11.050Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IXgXZysO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://buildly.io/wp-content/uploads/2020/02/Firefox_Screenshot_2020-02-04T14-50-11.050Z.png" alt="update rick data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything worked and the user data was updated in the Buildly Core database based on the information we have in our LDAP server. Buildly authenticates users against LDAP server, creates and updates users based on the data retrieved from the server.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;We connected Buildly Core to an OpenLDAP server in this tutorial but you can connect to Active Directory as well. To connect to an Active Directory Domain Service (AD DS) you would need to update the user search filter in the config, to the AD field that you would define as the username in your AD user data.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;code&gt;LDAP_USERNAME_FIELD_SEARCH: “sAMAccountName”&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Reference
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;LDAP – &lt;a href="https://ldap.com/"&gt;https://ldap.com/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Active Directory Domain Service – &lt;a href="https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/get-started/virtual-dc/active-directory-domain-services-overview"&gt;https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/get-started/virtual-dc/active-directory-domain-services-overview&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>openldap</category>
      <category>ldap</category>
      <category>buildly</category>
      <category>activedirectory</category>
    </item>
    <item>
      <title>How to connect IoT devices to Buildly</title>
      <dc:creator>Jeferson Moura</dc:creator>
      <pubDate>Tue, 14 Jan 2020 22:52:34 +0000</pubDate>
      <link>https://dev.to/jefmoura/how-to-connect-iot-devices-to-buildly-47co</link>
      <guid>https://dev.to/jefmoura/how-to-connect-iot-devices-to-buildly-47co</guid>
      <description>&lt;p&gt;As we have talked in one of our previous blog posts, most applications on the internet work synchronously but this has been changing in the last few years, especially because of IoT. In this post, we’re going to show you how to create a “micro”service responsible for publishing messages to an MQTT broker and connect it to Buildly Core. This service will receive command specifications from Buildly Core and send it to the broker, so IoT devices can subscribe to them. The main idea is that we have an event producer, a message broker, and a consumer. If you want to know more about this type of architecture, have a look at the &lt;a href="https://buildly.io/event-driven-architecture-explained/"&gt;Event-driven Architecture post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Up7OUziz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/664/0%2AFJmALPAMMA8Mx4lF" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Up7OUziz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/664/0%2AFJmALPAMMA8Mx4lF" alt="iot_diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Before starting
&lt;/h1&gt;

&lt;p&gt;First of all, we need to have a Buildly Core instance up and running, so we can safely expose our IoT service and possibly connect other services to publish commands to other brokers our trigger different actions, processes, etc. To know how to quickly have an instance of Buildly Core, go through the &lt;a href="https://buildly-core.readthedocs.io/en/latest/quickstart.html"&gt;Quickstart documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In our example, we’re using Mosquitto as the MQTT broker, so we also need an instance of it up and running. There are a couple of tutorials on the internet of how to start a Mosquitto server, so we’re not going to explain how to do it here. Eclipse Mosquitto is an open-source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers. [1]&lt;/p&gt;

&lt;p&gt;You can find the code of the service we’re going to create in this tutorial on GitHub. &lt;a href="https://github.com/Buildly-Marketplace/iot_service"&gt;https://github.com/Buildly-Marketplace/iot_service&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Create the IoT Service
&lt;/h1&gt;

&lt;p&gt;Now, the fun part will start. We need to know which programming languages have an official Mosquitto client, so we can choose which one we’ll pick to build our service. In our case, we chose Python because we have a Buildly CLI tool that generates a simple and configured Django application ready to be used with Buildly Core.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OU26PkC5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1168/0%2AWzVnyCzmbhy_1Duh" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OU26PkC5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1168/0%2AWzVnyCzmbhy_1Duh" alt="service_generate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To connect to the Mosquitto server we need to install the Python library called paho-mqtt, so we added it to the application requirements. The Eclipse Paho project provides open-source client implementations of MQTT and MQTT-SN messaging protocols aimed at new, existing, and emerging applications for the Internet of Things (IoT). [2]&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect to a Mosquitto server
&lt;/h2&gt;

&lt;p&gt;After running the service and verifying that everything is working we need to implement the logic that will connect our IoT service to the broker and publish commands sent to it. We have to define a topic in the broker, so messages(commands) can be published. Therefore, we decided to call our topic: hello/world.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GMow__Vv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/513/0%2Aa4q-P_3X6FmYeBXC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GMow__Vv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/513/0%2Aa4q-P_3X6FmYeBXC.png" alt="mqtt_client_class"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To test our implementation above we need to have a Mosquitto server running and subscribe to the same topic that we’re going to publish messages. Therefore, we added another function to the MQTTClient class to perform the topic subscription.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dUoPkQ2o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/507/0%2AAO29xyLru-WGf2DB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dUoPkQ2o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/507/0%2AAO29xyLru-WGf2DB.png" alt="mqtt_subscribe"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we have the IoT service and a broker running, we need to test the connection and see if we can send and receive messages via our Mosquitto server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uy8U_iEM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1169/0%2AXxQH3Hy_TkcQUXnx" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uy8U_iEM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1169/0%2AXxQH3Hy_TkcQUXnx" alt="mqtt_subscribe"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Implement an endpoint
&lt;/h2&gt;

&lt;p&gt;Last but not least, we need to implement an endpoint to receive command specifications in HTTP requests and send them to the broker. Our implementation will be super simple, so we aren’t going to process the body of incoming requests but just send them directly to the Mosquitto server. But you can add more logic to your service, e.g, structure messages before publishing them, define a list of commands that can be published to the broker, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ukjoDoAH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/506/0%2ADJhzus6jfbE732y5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ukjoDoAH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/506/0%2ADJhzus6jfbE732y5.png" alt="iot_endpoint"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tsx4QzZp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1031/0%2A85At3qmLFjgqiyTg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tsx4QzZp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1031/0%2A85At3qmLFjgqiyTg" alt="iot_swagger"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect the new service to Buildly Core
&lt;/h2&gt;

&lt;p&gt;Now that we have our IoT Service connected to a Mosquitto server and ready to be connected to Buildly Core, we’re going to it then. First, we need to have an instance of Buildly Core and our IoT service, then we send the following POST request to Buildly Core with our Admin credentials, so the service is registered to it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2DCBF2aX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/507/0%2Amntxn3i0D149gexT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2DCBF2aX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/507/0%2Amntxn3i0D149gexT.png" alt="register_service"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s check the Buildly Core Swagger specification, so we can see if the IoT service is accessible via Buildly Core.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IU_RbLwf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/655/0%2AsdJ-AsjbzWFc_DMV" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IU_RbLwf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/655/0%2AsdJ-AsjbzWFc_DMV" alt="buildly_swagger"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Testing everything together
&lt;/h1&gt;

&lt;p&gt;We connected all the pieces and everything is running, so we need to test it now. We are going to send a request to Buildly Core with a command specification to be redirected to our IoT service. Therefore, the Mosquitto server should have the specified command queued. To retrieve the message from the Mosquitto server we are using the Mosquitto Client to subscribe to the hello/world topic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mfPSuBFX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/573/0%2AgNtigJH3ztqlpUDR" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mfPSuBFX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/573/0%2AgNtigJH3ztqlpUDR" alt="final_result"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Awesome! Everything is working and we can send command specifications to Buildly and they will be published to a Mosquitto server.&lt;/p&gt;

&lt;h1&gt;
  
  
  And now what?
&lt;/h1&gt;

&lt;p&gt;Now, we can create consumers and connect them to the Mosquito server to consume messages(commands), in other words, we can send HTTP requests to Buildly Core specifying which command should be performed by an IoT device and these requests will be redirected to a service responsible for handling and publishing them to a broker using MQTT protocol.&lt;/p&gt;

&lt;p&gt;There’s a diagram at the beginning of the post showing a database connected to and an event subscription done by the IoT Service. It means that the IoT Service could also subscribe to the broker to receive information from IoT devices, and use a database to store this kind of data.&lt;/p&gt;

&lt;h1&gt;
  
  
  Resource
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Eclipse Mosquitto — &lt;a href="https://mosquitto.org/"&gt;https://mosquitto.org/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Eclipse Paho — &lt;a href="https://www.eclipse.org/paho/"&gt;https://www.eclipse.org/paho/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Buildly Core Documentation — &lt;a href="https://buildly-core.readthedocs.io/en/latest/"&gt;https://buildly-core.readthedocs.io/en/latest/&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>mqtt</category>
      <category>mosquitto</category>
      <category>django</category>
      <category>iot</category>
    </item>
    <item>
      <title>Event-driven Architecture Explained</title>
      <dc:creator>Jeferson Moura</dc:creator>
      <pubDate>Tue, 17 Sep 2019 17:35:26 +0000</pubDate>
      <link>https://dev.to/buildly/event-driven-architecture-5el8</link>
      <guid>https://dev.to/buildly/event-driven-architecture-5el8</guid>
      <description>&lt;p&gt;Most applications on the internet work synchronously but this has been changing quickly in the last few years, especially because of IoT, self driving cars, etc. Synchronous applications receive requests to perform an action and the actor waits until everything is done, he/she waits for a response. However, there are situations when we don't need to wait for a response but only send a request. It’s very useful when you just want to inform something or trigger a process and maybe check it later if everything went well.&lt;/p&gt;

&lt;h1&gt;
  
  
  Concept
&lt;/h1&gt;

&lt;p&gt;Event-Driven Architectures (EDAs) are usually broker-centric, so there’s a producer that generates events/sends messages, a broker that receives the events and redirect to consumers, and a consumer that connects to the broker and waits for events.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BfGuOkz3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/30wl7o1cnzxqcj8u3vn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BfGuOkz3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/30wl7o1cnzxqcj8u3vn0.png" alt="eventdriven"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Producer &amp;amp; Consumer
&lt;/h2&gt;

&lt;p&gt;As explained in the first sentence above, a producer (aka publisher) is an application that sends messages to the broker and a consumer (aka listener) is an application that connects to the broker, manifests interest in type of messages, and leaves the connection open so the broker can push messages to them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Message broker
&lt;/h2&gt;

&lt;p&gt;A message broker (aka integration broker) is an application/software that translates a message from the formal messaging protocol of producers to the formal messaging protocol of consumers. There are a couple of famous brokers out there, like Redis, RabbitMQ, Kafka, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Message
&lt;/h2&gt;

&lt;p&gt;As mentioned above, publishers send messages to a broker, and this message will be redirected and received by all the interested consumers. The message payload can be anything but they are frequently cataloged as events and commands. To clarify, events are used to communicate things to consumers and commands are used to ask consumers to do things.&lt;/p&gt;

&lt;h2&gt;
  
  
  Protocols
&lt;/h2&gt;

&lt;p&gt;As we have HTTP and HTTPS, for example, used by REST APIs, there are also some protocols used by Async APIs. And these are some of them:&lt;/p&gt;

&lt;h3&gt;
  
  
  AMQP
&lt;/h3&gt;

&lt;p&gt;Advanced Message Queuing Protocol (aka AMQP) is an open standard for passing business messages between applications or organizations.  It connects systems, feeds business processes with the information they need and reliably transmits onward the instructions that achieve their goals. [1]&lt;/p&gt;

&lt;h3&gt;
  
  
  MQTT
&lt;/h3&gt;

&lt;p&gt;MQTT is a machine-to-machine/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. [2]&lt;/p&gt;

&lt;h3&gt;
  
  
  Websocket
&lt;/h3&gt;

&lt;p&gt;The WebSocket Protocol enables two-way communication between a client running untrusted code in a controlled environment to a remote host that has opted-in to communications from that code. The security model used for this is the origin-based security model commonly used by web browsers. [3]&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Now, we know a bit about event-driven architectures (EDAs) and that they promote the production, detection, consumption of, and reaction to events. A piece of external information about them is that they are also extremely loosely coupled and well distributed.&lt;br&gt;
We also know that there's a big variety of protocols and to decide which one we should use is highly dependent on our specific use case and codebase.&lt;/p&gt;

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;p&gt;1 - &lt;a href="https://www.amqp.org/about/what"&gt;https://www.amqp.org/about/what&lt;/a&gt;&lt;br&gt;
2 - &lt;a href="http://mqtt.org/"&gt;http://mqtt.org/&lt;/a&gt;&lt;br&gt;
3 - &lt;a href="https://tools.ietf.org/html/rfc6455"&gt;https://tools.ietf.org/html/rfc6455&lt;/a&gt;&lt;/p&gt;

</description>
      <category>async</category>
      <category>iot</category>
      <category>architecture</category>
      <category>eventdriven</category>
    </item>
    <item>
      <title>Developing APIs based on OpenAPI Specification</title>
      <dc:creator>Jeferson Moura</dc:creator>
      <pubDate>Mon, 16 Sep 2019 09:14:19 +0000</pubDate>
      <link>https://dev.to/buildly/developing-apis-based-on-openapi-specification-2knl</link>
      <guid>https://dev.to/buildly/developing-apis-based-on-openapi-specification-2knl</guid>
      <description>&lt;p&gt;APIs have been around for a really long time connecting different logical units together but they were not meant to be used by a lot of people in the past. Nowadays, APIs are not constrained to the Backend side of applications anymore and are more consumer-driven.&lt;br&gt;
The universe of APIs is regularly one of contending standards, interests, and arrangements. Standards help give a common framework of communication and development and ground us in picking the correct tools dependent on a particular need.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is OpenAPI?
&lt;/h2&gt;

&lt;p&gt;I really like the explanation from OpenAPI website: "The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.".[1]&lt;br&gt;
Summarizing, OpenAPI Specification is a solution that produces machine-readable documentation for REST APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Developing APIs based on OpenAPI spec
&lt;/h2&gt;

&lt;p&gt;As Test-driven development (TDD) that combines test-first development where you write a test before you write a solution code to fulfill that test and refactor it, we can also specify endpoints of an API using the OpenAPI framework before starting coding them and refactor. So, prior to beginning to build the business logic of an API, test it, or any other lifecycle, we create the API's interface, specifying the accurate requests and responses endpoints will display.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Pzaa1Sw2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0vove5f87li0ka623rx6.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Pzaa1Sw2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0vove5f87li0ka623rx6.jpeg" alt="development-based-on-openapi"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why OpenAPI spec-driven development?
&lt;/h2&gt;

&lt;p&gt;A significant advantage of developing APIs based on OpenAPI specifications is that it enables independence between teams, e.g, Frontend, Backend and QA Engineers know how the API is supposed to do, so they are all aligned on it. Removing these dependencies will also speed up the release process because different teams can do their tasks at a much faster pace.&lt;br&gt;
Another advantage of using this approach is the improvement of Developer experience. Developer experience is about delivering robust functionality that is stable, speedy, and visually intuitive.[2] If you're thinking about how it can improve the developer experience, you just need to remember that developers will consume your API and having a well defined/documented API will have a great impact on it. You can focus on the API consumer's needs beforehand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As I said at the beginning APIs were not meant to be used by a lot of people in the past but nowadays, they are not limited to the Backend side of applications anymore and are more consumer-driven. So, we need people to comprehend what APIs do, which is the reason a consumer-driven perspective on APIs is quick getting on and the OpenAPI Specification helps us to build APIs while guaranteeing a good developer experience through a definition driven methodology.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;1 - &lt;a href="https://swagger.io/specification/"&gt;https://swagger.io/specification/&lt;/a&gt;&lt;br&gt;
2 - &lt;a href="https://hackernoon.com/developer-experience-dx-devs-are-people-too-6590d6577afe"&gt;https://hackernoon.com/developer-experience-dx-devs-are-people-too-6590d6577afe&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>restapi</category>
      <category>openapi</category>
    </item>
    <item>
      <title>Microservice Architecture in a Nutshell</title>
      <dc:creator>Jeferson Moura</dc:creator>
      <pubDate>Sun, 08 Sep 2019 16:57:28 +0000</pubDate>
      <link>https://dev.to/buildly/microservice-architecture-in-a-nutshell-38o0</link>
      <guid>https://dev.to/buildly/microservice-architecture-in-a-nutshell-38o0</guid>
      <description>&lt;p&gt;We have been building applications and getting better at it for years and a variety of technologies, architectural patterns, and best practices have been developed along this period. Microservices is an architectural pattern that has emerged during those years, especially because of containers. Docker is the main actor of all these changes because it has popularized containers and helped us containerizing our applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concept
&lt;/h2&gt;

&lt;p&gt;Microservice architecture is a variant of the service-oriented architecture that organizes an application as a collection of loosely coupled services. These services are responsible for specific tasks and can communicate with each other through simple APIs to solve a larger complex business issue. Summarizing, microservices are a particular technique for developing software systems that attempt to concentrate on structuring single-function modules with well-defined interfaces and operations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sfvKWKSm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/mk9gr3ffvx4gpzvz0u2g.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sfvKWKSm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/mk9gr3ffvx4gpzvz0u2g.jpg" alt="microservices"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros &amp;amp; Cons
&lt;/h2&gt;

&lt;p&gt;Microservices are used to speed up development, feature release, ease scalability; they offer improved fault isolation, etc. If you are developing an application and it has to support a variety of different clients including desktop, mobile browsers, and native mobile applications, you must consider implementing your application using microservice architecture.&lt;/p&gt;

&lt;p&gt;Microservices also bring complexity to network, testing, deploying, monitoring, etc. Team communication can be hard without using automation and Agile methodology. You also might have to introduce CI/CD tool, configuration management, and application-deployment tool, service mesh, and API gateway to help you with testing, building, shipping, discovering and connecting all services.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Along all these years we have improved the way we develop systems and we’ll keep doing it. If you automate and do everything in the right way, you probably won’t face issues and will love microservices. All software architectural patterns and styles have their pros and cons and microservices architecture isn’t different but it helps us to be more agile.&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>architecture</category>
      <category>microservices</category>
      <category>agile</category>
    </item>
  </channel>
</rss>
