<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Better Practices - Medium]]></title>
        <description><![CDATA[For individual engineers to the largest teams, Better Practices is intended to distill knowledge from the Postman community. This is a place to learn about modern software practices together! Read more: https://medium.com/better-practices/introducing-better-practices-e9cf14cf0c88 - Medium]]></description>
        <link>https://medium.com/better-practices?source=rss----410f2fbc015d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Better Practices - Medium</title>
            <link>https://medium.com/better-practices?source=rss----410f2fbc015d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 11 May 2026 16:47:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/better-practices" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Stop Exposing Secrets! Secure Your APIs in Postman Like a Pro]]></title>
            <link>https://medium.com/better-practices/stop-exposing-secrets-secure-your-apis-in-postman-like-a-pro-cbd6f978aaa8?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/cbd6f978aaa8</guid>
            <category><![CDATA[api-security]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Gbadebo Bello]]></dc:creator>
            <pubDate>Thu, 06 Mar 2025 11:42:44 GMT</pubDate>
            <atom:updated>2025-03-06T11:42:44.331Z</atom:updated>
            <content:encoded><![CDATA[<p>API security is crucial, as it directly impacts your business’s success and safety. How well you secure your APIs can make or mar your product, and it is of utmost importance to spend time thinking about security.</p><p>I have seen developers work in Postman without properly securing their credentials, often leaving API keys exposed in shared environments or logging sensitive data in the console. For example, some developers unknowingly expose credentials when they make their workspaces public, allowing anyone to access sensitive API keys and tokens that are not properly stored.</p><p>In this post, I want to share some tips on how you can protect your data and API in Postman.</p><h3>General Tips for Securing Your APIs in Postman</h3><p>When working with APIs in Postman, taking proactive security measures is essential to prevent data leaks and unauthorized access. Implementing best practices ensures your credentials, tokens, and sensitive data remain protected.</p><h3>1) The secret scanner is your friend</h3><p>The Postman secret scanner is every developer’s knight. It constantly scans your public workspaces and documentation for any exposed secrets. It checks your variables and environments, schemas, etc for exposed secrets and notifies all Team and Workspace admins via emails and in-app notifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aNqaHlTz_i3ZxCau" /></figure><p>Admins are given a link to view all exposed secrets in a dashboard and an option to immediately replace them with a placeholder using a single button click. This helps mitigate security risks faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zYEN0ZTEQRdO1Bt7" /></figure><p>If you do not replace exposed secrets in a timeframe specified in the email, the secret scanner will automatically replace this data with a placeholder for you. For example, authorization secrets can be replaced with {{vault:authorization-secret}}, or &lt;AUTHORIZATION_SECRET&gt;.</p><p><strong>Pro tip 1: </strong>Whenever you want to show an example of some sensitive data, always use placeholder data before making your Workspace public. Maintain a private fork of your collection that you can continue to work in even after making your base collection public.</p><p>There’s a lot more you can do with the secret scanner in Postman. You can mark alerts as ‘false positives’, ‘won’t fix’, etc.</p><p><strong>Pro tip 2: </strong>Don’t ever ignore the secret scanner. While there may be false positives, always check to ensure you’re not exposing anything and staying safe.</p><p><a href="https://learning.postman.com/docs/administration/managing-your-team/secret-scanner/"><strong>Learn more about the secret scanner here</strong></a></p><h3>2) Avoid secret keys in test scripts, headers, params, etc</h3><p>When working with test scripts, depending on your workflow, some developers often prefer to make HTTP calls from pre-request scripts. Some HTTP calls require auth credentials, and these auth credentials can be easily exposed if you’re logging data to the console, passing data to a template for visualization, etc.</p><p>If you need to use sensitive data in your pm scripts, always first store them in a vault, environment, or collection variable, then programmatically access the data from storage.</p><p>In some cases, Postman actively checks for any sensitive data in your scripts and truncates them before logging in to avoid being exposed.</p><p>You should also be very careful when adding request headers, query/path parameters, etc. These are places where we’ve observed a lot of secrets being exposed. Our variable helpers make it easy to store data in the places in the vault or collection/environment variables. Simply highlight the value, and you will see a pop-up that helps you store the data more securely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jkFmfdQHN6pkRHMV" /></figure><p>Here’s a list of places to take note of when making a workspace public:</p><ul><li>Request header</li><li>Collection/Environment/Global Variables</li><li>Query and Path Parameters</li><li>Authorization helpers (API Key, Basic, OAuth, etc)</li><li>Pre-request and Post-response scripts</li><li>Request body</li><li>URL bar</li><li>Postman Console</li></ul><h3>3) Keep your credentials local with Postman Vault</h3><p>Some users worry about storing their credentials in Postman environments and variables because it could potentially sync with Postman cloud depending on how it is stored. While the Postman cloud is safe and secure, we always encourage everyone to store their API secrets in the Postman Vault.</p><p>Postman Vault is a local encrypted storage that only you can access. Data stored in the Postman vault are not synced with the Postman cloud and can only be accessed using a vault key. Your vault key can be stored in your system’s password manager or securely elsewhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y6JcKy3JSEHe2IEi" /></figure><p>You can limit vault secrets to specific API domains, and link them to external password managers like Hashicorp, Azure Vault, 1Password, etc if you intend to share credentials with your team. Vault credentials can be programmatically accessed in Postman scripts similar to how you would access environments and collection variables.</p><p><strong>Pro tip: </strong>When working with authorization helpers in Postman. Always use the Postman Vault.</p><p><a href="https://learning.postman.com/docs/sending-requests/postman-vault/postman-vault-secrets/"><strong>Learn more about Postman Vaults</strong></a></p><h3>4) Help your API consumers stay secure with Guided Auths</h3><p>Guided Auth helps you onboard consumers to your public APIs faster and more efficiently. When you set up Guided Auths for your public APIs in Postman, your API consumers get a step-by-step guide on how they can make their first successful API call as soon as they start typing your domain name in the URL bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZC-tM72JoHklUruh" /></figure><p>They can easily set up different kinds of authentication(OAuth 2.0, Client Credentials, PKCE, etc) depending on how your guided auth is configured.</p><p><a href="https://learning.postman.com/docs/publishing-your-api/setting-up-authentication-for-public-apis/"><strong>Learn how to set up Guided Auths here</strong></a></p><p>Once you have guided auths set up, you can help your API consumers stay secure by choosing to store their credentials after a guided authentication step in Postman Vault. Vault secrets added using Guided Auth are inside double curly braces ({{ }}). The prefix vault: is appended to the vault secret’s name, and a suffix is automatically appended with the authentication type.</p><pre>{{vault:postman-api-key:value}}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DjXvxILXW_Qm2bXw" /></figure><h3>5) Current Values vs Initial Values</h3><p>When using variables in Postman, it’s important to understand the difference between Initial Values and Current Values.</p><ul><li><strong>Initial Values</strong> are synced to the Postman cloud. If you share your collections, your variables become visible to your team and anyone who has access to that workspace.</li><li><strong>Current Values</strong> are only stored locally on your machine and are not shared with others. This makes them ideal for storing sensitive API keys, tokens, or credentials.</li></ul><p><strong>Pro tip:</strong> Always ensure that sensitive data is stored as a <strong>Current Value</strong> to prevent accidental exposure. Use Initial Values to show examples of what the variable value could look like.</p><h3>6) Authorization helpers are there to help</h3><p>Postman provides authorization helpers that let you handle authentication securely without manually adding tokens or credentials in your request headers.</p><ul><li>Instead of manually copying access tokens, use the <strong>OAuth 2.0 helper</strong> to automatically fetch and refresh tokens.</li><li>When using API keys, configure them in the <strong>authorization tab</strong> rather than adding them directly to request URLs.</li></ul><h3>7) Stop ignoring the warnings!</h3><p>Postman does a great job at providing several warnings at different places when it suspects that something may be wrong. This warning can come as a UI popup, a push notification, an email, or status indicators on the UI depending on what it is you are trying to do. Always make sure you pay attention to these warnings and never ignore them.</p><p>It never hurts to double-check to be sure you are not exposing any sensitive information.</p><p>Remember, your data will only be public if you make them public.</p><p><strong>Pro Tip:</strong> When creating a new Workspace, always start with a Private or Team Workspace. Once you’re done making changes, review your work and then make it public. Ensure you always check thoroughly before changing a Workspace visibility to “Public”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9fK2ioiVqmkMQiXl" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OPDdJR-wVrmw5T19" /></figure><h3>7) Enforce the Principle of Lease Privilege(POLP)</h3><p>Workspaces and Teams in Postman have Role-Based Access Control(RBAC) integrated in them. We encourage teams collaborating in Postman to always give access and certain privileges to only those who need them. In a Postman Team, only individuals with super admin and community manager roles are allowed to manage all public elements. Therefore, we encourage you to only assign these roles to necessary people and have a standard review process in place for when Workspaces are being published to the public.</p><p><a href="https://learning.postman.com/docs/collaborating-in-postman/manage-public-elements/"><strong>Learn more about managing public elements in Postman here</strong></a></p><h3>Final Thoughts</h3><p>Securing your APIs is crucial, and Postman provides various tools to help you keep your secrets safe. By leveraging features like <strong>Postman Vault, the Secret Scanner, Guided Auth, and Authorization Helpers</strong>, you can significantly reduce the risk of exposing sensitive data.</p><p>Make sure you implement these best practices and regularly audit your Postman workspaces to ensure that your API security remains strong.</p><p>Got questions? Found any of this helpful? Let me know in the comments!</p><p>Happy coding and stay secure!<br>Cheers!</p><p><strong><em>Originally published on the </em></strong><a href="https://community.postman.com/t/stop-exposing-secrets-secure-your-apis-in-postman-like-a-pro/76420"><strong><em>Postman Community</em></strong></a><strong><em> on March 4, 2025</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbd6f978aaa8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/stop-exposing-secrets-secure-your-apis-in-postman-like-a-pro-cbd6f978aaa8">Stop Exposing Secrets! Secure Your APIs in Postman Like a Pro</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Powering home automation with WebSocket APIs]]></title>
            <link>https://medium.com/better-practices/powering-home-automation-with-websocket-apis-8885a7601523?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/8885a7601523</guid>
            <category><![CDATA[home-assistant]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Joyce Lin]]></dc:creator>
            <pubDate>Thu, 06 Jul 2023 17:04:32 GMT</pubDate>
            <atom:updated>2023-07-06T17:04:32.168Z</atom:updated>
            <content:encoded><![CDATA[<h4>Get started with the Home Assistant WebSocket API</h4><p>In Part 1 of this series, we learned about the <a href="https://learning.postman.com/docs/sending-requests/websocket/websocket/">WebSocket</a> protocol and how to <a href="https://blog.postman.com/set-up-a-websockets-server-in-node-js-postman/">set up our own WebSocket server in Node.js</a>. Next, let’s explore how to use a public WebSocket API to access smart devices around a connected home.</p><h3>REST and WebSockets for a connected home</h3><p>When it comes to transmitting data in a connected home environment, both <a href="https://blog.postman.com/rest-api-examples/">REST</a> and WebSockets are commonly used protocols, but they have different characteristics and use cases.</p><p>REST follows a request-response pattern, where a client sends a request to a server, and the server responds with the requested data. This is useful for accessing and controlling smart devices and services, and works well for scenarios where data updates are not required in real-time. For example, you could use a REST API to turn on a smart light.</p><p>On the other hand, WebSockets enables bidirectional communication between a client and server, enabling real-time data transmission. This is useful for applications that require continuous data updates, such as real-time monitoring of sensor data and displaying live dashboards. For example, you could use a WebSocket API to continuously monitor the temperature in a room over a persistent connection.</p><p>In the next section, let’s take a look at a popular home automation platform that provides both REST and WebSocket APIs.</p><h3>Home Assistant for home automation</h3><p><a href="https://www.home-assistant.io/">Home Assistant</a> is a popular open-source home automation platform that lets you control and monitor smart devices from different brands using a unified interface. Instead of using separate applications to control the kitchen lights, thermostat, and other connected devices all manufactured by different producers, you can manage almost everything from a single Home Assistant web dashboard running on a Raspberry Pi or other dedicated server within your local network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*SV-NQW6-Sz2D9Buh.png" /></figure><p>Home Assistant is ideal for DIY smart-home tinkerers because it supports a wide range of integrations and protocols, allowing you to customize automation scenarios based on events, schedules, and sensor readings.</p><p>Next, let’s take a look at Home Assistant’s WebSocket API.</p><h3>Home Assistant WebSocket API</h3><p>In addition to a <a href="https://developers.home-assistant.io/docs/api/rest/">REST API</a><a href="https://blog.postman.com/rest-api-examples">,</a> Home Assistant also contains a <a href="https://developers.home-assistant.io/docs/api/websocket">WebSocket API</a> to stream information. To learn how to authenticate the WebSockets connection and send saved messages to the Home Assistant server, follow along with this <a href="https://quickstarts.postman.com/guide/home-assistant/index.html?index=..%2F..index#0">step-by-step tutorial</a>, watch the <a href="https://youtu.be/Qk9A0QbG5-I">video</a>, and reference <a href="https://www.postman.com/postman/workspace/program-smart-lights/collection/6481ed9afe7f1bdfaa732408">the sample collection</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQk9A0QbG5-I%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQk9A0QbG5-I&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FQk9A0QbG5-I%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/34e673bfe1fdf0fed8db3e10614f1fad/href">https://medium.com/media/34e673bfe1fdf0fed8db3e10614f1fad/href</a></iframe><p>Using a long-lived token, you can use Postman to establish a connection with our Home Assistant server running locally, and then send and receive messages using the WebSocket API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*xkZhl3eyC8CuvhnJ.png" /></figure><p>You can also configure your own <strong>Saved Messages</strong> to create your own customized themes and sequences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*yxsGpbMOjjNpSBpT.png" /></figure><p>Home Assistant also provides a <a href="https://developers.home-assistant.io/docs/api/rest">REST API</a>. Explore Home Assistant’s WebSocket and REST APIs side-by-side in Postman to better understand the differences between the two protocols.</p><h3>Additional resources</h3><p>You can work in Postman using different API patterns and protocols. Check out these Postman resources to learn more about WebSockets:</p><ul><li><a href="https://www.postman.com/postman/workspace/websockets/documentation/14057978-712d684f-c252-4bd9-a7a6-6a893e41adea">Guide to Postman WebSockets</a> collection</li><li><a href="https://learning.postman.com/docs/sending-requests/websocket/websocket/">Using WebSocket requests</a> docs</li><li><a href="https://youtu.be/H-7EZVj9D-k">WebSocket requests</a> video</li></ul><p>Browse the <a href="https://www.postman.com/postman/workspace/program-smart-lights/overview">Program smart lights</a> public workspace for APIs from other providers, such as Philips Hue and Elgato, to automatically control smart lights in your home or office. And let us know in the comments below what kind of projects you want to learn about, and what you’re doing with WebSockets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8885a7601523" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/powering-home-automation-with-websocket-apis-8885a7601523">Powering home automation with WebSocket APIs</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get started using Google Cloud APIs to manage cloud infrastructure]]></title>
            <link>https://medium.com/better-practices/get-started-using-google-cloud-apis-to-manage-cloud-infrastructure-bace9cac42e1?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/bace9cac42e1</guid>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Joyce Lin]]></dc:creator>
            <pubDate>Wed, 28 Jun 2023 19:03:35 GMT</pubDate>
            <atom:updated>2023-06-28T19:03:34.988Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s not just developers who rely on APIs. DevOps engineers and data engineers also use APIs for many reasons, including to manage cloud infrastructure. For example, you can programmatically manage resources, configure services, and perform operations using APIs.</p><p>Let’s review other reasons to use cloud APIs.</p><h3>Reasons to use cloud APIs</h3><p>In addition to providing a management console and SDKs, most cloud providers also have REST APIs that enable programmatic access to cloud services for more flexibility, automation, and extensibility. Here are some of the benefits of cloud APIs:</p><ul><li><strong>Automation and integration:</strong> Automate tedious tasks and integrate cloud functionality with your own applications and systems.</li><li><strong>Customization and control: </strong>Take advantage of cloud capabilities to suit your specific requirements and build custom workflows or applications</li><li><strong>Multi-cloud and hybrid environments:</strong> If you have a mix of on-premises and cloud resources from multiple providers, you can create unified interfaces for managing and interacting with your infrastructure</li><li><strong>Third-party integrations:</strong> Leverage cloud services within your existing software ecosystem of tools and frameworks.</li></ul><p>In the next section, let’s look at a popular cloud provider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vH0TBiRYXZVyT6zA9iuREQ.jpeg" /></figure><h3>Get started with Google Cloud Platform APIs</h3><p>Google Cloud Platform (GCP) is a suite of cloud computing services provided by Google to build, deploy, and scale applications and services on Google’s infrastructure. There are a wide range of services, including compute, storage, networking, machine learning, and more.</p><p>Fork the example collection to your own workspace and follow <a href="https://quickstarts.postman.com/guide/gcp/index.html?index=..%2F..index#0">this step-by-step tutorial</a> to get started with Compute Engine, Cloud Storage, Resource Manager, and setting up OAuth 2.0 in Postman.</p><p><strong>Use this Run in Postman button to fork the collection:</strong></p><figure><a href="https://god.gw.postman.com/run-collection/13191452-a3a3e4b4-8586-47dc-a8d3-519c547e58c1?action=collection%2Ffork&amp;source=rip_markdown&amp;collection-url=entityId%3D13191452-a3a3e4b4-8586-47dc-a8d3-519c547e58c1%26entityType%3Dcollection%26workspaceId%3D0a0d015d-e451-49cd-87fe-e3772ddae97a"><img alt="" src="https://cdn-images-1.medium.com/max/434/1*ZXUjXtM2Z6u-_0evV9C7Eg.jpeg" /></a></figure><h3>What you’ll learn</h3><ul><li>How to enable Google Cloud APIs</li><li>How to authenticate to Google Cloud APIs</li><li>How to set up cloud instances and storage</li><li>How to troubleshoot unexpected API behavior</li><li>How to grant access to cloud resources</li><li>How to automate API workflows for Google Cloud Platform in Postman</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*do0ZxSLV0D_NJ2fJ.png" /><figcaption>Fork the example collection to your own workspace</figcaption></figure><p>If you are using Google Cloud APIs for the first time, you can follow the steps in <a href="https://quickstarts.postman.com/guide/gcp/index.html?index=..%2F..index#0">this guide</a> to call the APIs using requests sent through the Postman client. You can also use those requests to experiment with an API before you develop your own applications and integrations.</p><p>Find this collection, and others like it, under <strong>New</strong> &gt; <strong>Collection </strong>in Postman. Under the <strong>Overview</strong> tab, browse <strong>More templates</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*QO4QpC1zgJbqxpaY.png" /><figcaption>Browse collection templates to set up cloud infrastructure and other use cases</figcaption></figure><h3>Additional resources</h3><ul><li>Get started with this step-by-step tutorial: <a href="https://quickstarts.postman.com/guide/gcp/index.html?index=..%2F..index#0">Get Started with Google Cloud APIs</a> quickstart</li><li>Walk through the sample collection: <a href="https://www.postman.com/devrel/workspace/cloud-onboarding-collections/collection/13191452-a3a3e4b4-8586-47dc-a8d3-519c547e58c1">Google onboarding collection</a></li><li>Review API reference for other services, such as the <a href="https://www.postman.com/google-maps-platform/workspace/google-maps-platform/overview">Google Maps Platform</a> collection</li></ul><p>If you’re managing a multi-cloud environment, also check out the <a href="https://www.postman.com/devrel/workspace/cloud-onboarding-collections/collection/13191452-92632f93-a0c2-42f3-847e-ff7ffdfe688b">AWS onboarding collection</a> (Azure coming soon). And let us know in the comments below how you’re using infrastructure APIs to manage your own systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bace9cac42e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/get-started-using-google-cloud-apis-to-manage-cloud-infrastructure-bace9cac42e1">Get started using Google Cloud APIs to manage cloud infrastructure</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boost Your Engineering Team’s Velocity with Smart Tool Investments]]></title>
            <link>https://medium.com/better-practices/boost-your-engineering-teams-velocity-with-smart-tool-investments-a0c7dde28bd4?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/a0c7dde28bd4</guid>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[platform]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[engineering-mangement]]></category>
            <dc:creator><![CDATA[Shahar Davidson]]></dc:creator>
            <pubDate>Wed, 26 Apr 2023 16:35:38 GMT</pubDate>
            <atom:updated>2023-04-26T16:35:38.305Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1k-mWxNYERonjiEzTLJT-Q.png" /><figcaption>Ready to take your engineering ship to Warp 9? (by Christopher Chiu-Tabet)</figcaption></figure><p>Nowadays, everyone is examining how to increase efficiencies and cut costs to improve their bottom line. Although it may seem counterintuitive, engineering managers can help increase efficiencies by <strong>investing </strong>in tools for their engineering group that can help increase the team’s velocity and therefore increase efficiencies and the bottom line.</p><p>Think about GitHub or any other modern CI solution that you are currently using; for the price you pay per developer and the pricing for the CI workloads, the ROI is huge. Can you imagine what you would have done without it? How much effort and resources would you have to exert to create a CI system by yourself?</p><p>So why not invest in other tools that can increase development velocity?</p><p>There are so many modern tools and services that can assist with that. Here’s just a small sample:</p><ul><li>AI tools for coding (such as <a href="https://www.tabnine.com/">Tabnine </a>and <a href="https://www.codium.ai/">Codium</a>)</li><li>Services for tracking performance (such as <a href="https://linearb.io/">LinearB</a>, <a href="https://www.acumen.io/">Acumen</a>, <a href="https://www.faros.ai/">Faros.ai</a>)</li><li>Services for optimizing CI (<a href="https://www.redefine.dev/">Redefine.dev</a>)</li><li>API development platforms (<a href="https://www.postman.com/">Postman</a>)</li><li>Tools for internal code documentation (<a href="https://swimm.io/">Swimm</a>)</li><li>Tools for easing local development and on-demand environments (<a href="https://velocity.tech/">Velocity</a>, <a href="https://www.raftt.io/">Raftt</a>, <a href="https://metalbear.co/">MetalBear</a>, <a href="https://www.env0.com/">env0</a>)</li></ul><p>This seems obvious for many engineering leaders, but we often neglect this when setting our priorities and only prioritize it when complaints start pouring in from all directions (executive team, Dev team, product team, etc.)</p><p>Engineering leaders should adopt a more <strong>proactive approach to integrating velocity-increasing development tools</strong>.</p><p><strong>So how should you adopt such a proactive approach?</strong></p><p>Here’s a simple framework:</p><p>(1) First, negotiate with the executive team a reasonable budget (upfront) for such tools, depending on the size of your group (say, $1000 a month for a group of ten engineers).</p><p>(2) Then you <strong>must </strong>ensure you have a good way to measure the effects of such tools on your Dev team (e.g., DORA metrics or any other velocity-related KPIs).</p><p>(3) Next, choose the tool you estimate would bring the highest ROI for your team within a quarter. (more bang for the buck)</p><p>(4) Check the effects of the tool after it has been adopted by the team <strong>for at least one quarter</strong> (sometimes it takes a few weeks to have an effect) by looking at the metrics and quantifying the metrics into $$$.</p><p><strong>There would generally be 2 indications that the tool is effective:</strong></p><ol><li>Quantifying the new metrics into $$$ would prove the ROI. (you are spending $$ on the tool, but by doing so, the company is saving $$$ since development velocity has increased)</li><li>The team expresses dissatisfaction when you tell the team that you intend to pull out the tool — that indicates that they love it because it probably saves them time. 🙂(and they will very likely be able to roughly quantify it as well)</li></ol><p>(5) Finally, check if there’s a budget left for evaluating an additional tool. If so, repeat steps (3) to (5).</p><p><strong>Here’s a simplified example of how to evaluate the efficacy of a new tool:</strong></p><p>You have a team of 10 engineers. The hourly cost of an engineer is about $65/hour. The team identified that they are spending a lot of time spinning up their local development environment — it takes about 8 minutes to compile and spin the env up, and the developers do that at least 5 times a day. A new tool claims to improve the compile time and spin-up time. It costs $20/month per developer and an additional fixed cost of $300/month — total spending of $500/month. You decide to give it a try, and you see that the tool managed to bring the time down from 8 minutes to 4 minutes — it doesn’t seem to be too much, but let’s do the math: that’s 20 minutes a day per developer, meaning 200 minutes a day for the entire team, or about 4000 minutes a month (assuming 20 work days a month), which is about 66 hours — that’s quite a lot!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*OTWi6Fp1mpWcF4ZMTkraTg.png" /></figure><p>The monthly cost of the tool =&gt; $500/month</p><p>Monthly savings in work hours =&gt; 66.66 hours x $65 = $4333</p><p>The ROI is pretty clear — the saved $3933 is translated into other work the team will do. In other words, the team would get more done.</p><p>If you do not see the ROI after a single quarter, pull the tool out and use the budget to try something else.</p><p>It’s that simple. <strong>Allocate </strong>a budget, <strong>integrate</strong>, <strong>assess </strong>whether to adopt or drop, and <strong>repeat</strong>.</p><p>Finally, make sure you track and record the KPIs over time, before and after the tool’s integration. At some point, someone (from the executive team) will ask why you are paying for the tool. You need the be able to present the KPIs before and after the tool’s integration to remind everyone why the tool is in use.</p><p>So head out to seek such tools and help your team move through the gears. 🚀</p><p>That’s all for now. Thank you for reading!</p><p>Found this article insightful? Show your love by adding some applause, and follow me for more articles about team building, software engineering, and technology.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0c7dde28bd4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/boost-your-engineering-teams-velocity-with-smart-tool-investments-a0c7dde28bd4">Boost Your Engineering Team’s Velocity with Smart Tool Investments</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Reusable Tests and Scripts with OpenAPI Reusable Components]]></title>
            <link>https://medium.com/better-practices/create-reusable-tests-and-scripts-with-openapi-reusable-components-1e065fbbc29f?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/1e065fbbc29f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Joyce Lin]]></dc:creator>
            <pubDate>Mon, 13 Feb 2023 16:59:06 GMT</pubDate>
            <atom:updated>2023-02-13T16:59:06.143Z</atom:updated>
            <content:encoded><![CDATA[<h4>Storing Postman scripts within reusable components in an OpenAPI definition</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*crOBs2bpXWoeda4E.jpg" /></figure><p>In programming, “hacking” has historically meant making something do what it wasn’t originally intended to do, like <a href="https://www.popularmechanics.com/technology/a20762221/an-early-hacker-used-a-cereal-box-whistle-to-take-over-phone-lines/">using a whistle from a cereal box prize</a> to play the tone into a pay phone to get free long distance calls. Today, it also refers to finding an inelegant solution to a problem. The word has gotten a bad rap, since it typically implies a nefarious or criminal activity. But many companies offer public APIs, empowering developers to stitch together their own customized solutions, even if the workarounds are a bit of a “hack.”</p><p>For example, if the user interface doesn’t accommodate a specific use case, and you can’t control which features get released and when, it’s time to get resourceful. APIs are an opportunity to create a workaround that suits you.</p><h3>Alternative solutions for reusable tests and scripts</h3><p>Postman users have asked if it’s possible to reuse tests and scripts. There isn’t a button or section in Postman that says, “Store your own reusable scripts here,” but there are many ways to accomplish this.</p><p>Some alternative solutions that might work for your particular circumstances are:</p><ul><li><a href="https://learning.postman.com/docs/writing-scripts/intro-to-scripts/#execution-order-of-scripts">Creating collection-level or folder-level scripts</a> to run with every request within the collection or folder.</li><li>Storing scripts in a <a href="https://learning.postman.com/docs/sending-requests/variables/#variable-scopes">global variable</a> to use within the <a href="https://blog.postman.com/solving-problems-together-with-postman-workspaces/">workspace.</a></li><li>Storing scripts in an environment variable to use alongside different collections.</li><li>Setting utility functions using any scope of Postman variables at the beginning of the collection, which can then be used throughout the collection.</li><li>Accessing your local file system for scripts saved on your machine.</li><li>Storing scripts within reusable components in an OpenAPI definition.</li></ul><p>In this article, we’ll explore the last option in more detail.</p><h3>Storing scripts within reusable components in OpenAPI</h3><p>OpenAPI is the most popular API definition format that’s driving <a href="https://www.postman.com/api-first/">the API-first trend</a>. Reusable components in OpenAPI are a powerful feature in designing and documenting an API. We won’t explore this capability now, but if you’re interested in learning more about it, check out <a href="https://youtu.be/YRzpziA35Mg?t=1696">an example of re-using an error schema</a>.</p><p>In this article, we rely on reusable components to store our scripts and tests, and then use the Postman API to retrieve them when they’re needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPfA-M-uYJPXJPq2FOE6Ig.png" /><figcaption>Create scripts in OpenAPI reusable components and reference the scripts within a collection.</figcaption></figure><h3>Create the script</h3><p>Let’s save our script within a custom component in our API definition.</p><ol><li><a href="https://learning.postman.com/docs/designing-and-developing-your-api/creating-an-api/"><strong>Create an API definition</strong></a>: In Postman, select <strong>APIs</strong> in the sidebar, and then select <strong>+</strong>. Enter a name for your new API, and continue without a repository. Create a new API definition for your API, and author the definition from scratch. Configure the definition as OpenAPI 3.0, YAML format, and check the option to Use a boilerplate (predefined template).</li><li><strong>Create custom components: </strong>Within the generated file called index.yaml, scroll down to the section called components. Create a custom component under components that begins with an x- prefix. Add the name of your script, test, or any other data you want to store. Add a description that is the code you want to store as text for each component. See rows 38 to 49 in <a href="https://www.postman.com/postman/workspace/postman-answers/api/5a01c61f-e5e1-4876-bde6-0c7c924e8282/version/3a97617a-c592-4f12-a766-fde92905d39b?tab=define">this example</a>. Optionally, add a type or other metadata that is used to remind readers and yourself about this code.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uttpLvA7PBV5g5emrTmYSQ.png" /><figcaption>Create custom components using an x- prefix.</figcaption></figure><h3>Reference the script</h3><p>Let’s retrieve the custom script and execute it in a request script.</p><p><strong>Step 1: Enable YAML parsing</strong>: Store the source code for <a href="https://www.npmjs.com/package/js-yaml">this YAML parser for JavaScript</a> in a <a href="https://learning.postman.com/docs/sending-requests/managing-environments/">global variable</a> called yaml-js. In other words, copy and paste <a href="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.13.1/js-yaml.js">this code</a> into the global variables editor:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*EzmJKrLN0xztD92Q.png" /><figcaption>Store source code of external library as a global variable so it can be used in a Postman script.</figcaption></figure><p>Then, under the <strong>Tests</strong> tab of the request, import yaml-js so that it can be used within the script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QxSdSMLz_tQZgpSF22vgpg.png" /><figcaption>Import yaml-js so it can be used within the script.</figcaption></figure><p><strong>Step 2: Retrieve the API definition</strong>: Use <a href="https://learning.postman.com/docs/sending-requests/grpc/postman-sandbox-api/#sending-http-request-from-scripts">pm.sendRequest()</a> to <a href="https://www.postman.com/postman/workspace/postman-public-workspace/request/12959542-748c0367-6e64-4b9c-9f02-a2b8d297dc38">retrieve our API definition using the Postman API</a> created in the previous steps. The example in the screenshot below shows the apiId and postman-api-key stored as collection variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eutf2YSctujxPEyxjGdpOA.png" /><figcaption>Use pm.sendRequest() to retrieve the API definition.</figcaption></figure><p><strong>Step 3: Use the reusable components:</strong> Once we retrieve the reusable components from the API definition, we can use a function like to evaluate JavaScript code represented as a string. <strong>Note</strong>: there is <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval!">a big security risk in using </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval!">eval()</a>, so make sure you know what code you are running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OziIBwpUAcf2ZlS9FNGj9g.png" /><figcaption>Confirm the scripts do what you expect, such as logging to the console, running a test, and incrementing an integer.</figcaption></figure><h3>Try it out in Postman</h3><figure><a href="https://god.gw.postman.com/run-collection/1559645-09569095-9ffb-4aba-bbca-92b2954aabde?action=collection%2Ffork&amp;collection-url=entityId%3D1559645-09569095-9ffb-4aba-bbca-92b2954aabde%26entityType%3Dcollection%26workspaceId%3Daa5fb3b8-0090-4b5e-b3b4-fa5c1f2d080d"><img alt="" src="https://cdn-images-1.medium.com/max/434/1*hrH5xtfjpKmShbbk_8MK0g.png" /></a><figcaption>Fork the collection to your own workspace by clicking the Run in Postman button.</figcaption></figure><ol><li><strong>Fork the collection</strong>: Fork <a href="https://www.postman.com/postman/workspace/postman-answers/collection/1559645-09569095-9ffb-4aba-bbca-92b2954aabde?ctx=documentation">the example collection</a> from above to your own workspace by clicking the “Run in Postman” button.</li><li><strong>Create an API definition</strong>: Create <a href="https://learning.postman.com/docs/designing-and-developing-your-api/creating-an-api/">a new boilerplate API definition</a> in your own workspace, and make sure to include the code from Rows 38 to 49 as seen in <a href="https://www.postman.com/postman/workspace/postman-answers/api/5a01c61f-e5e1-4876-bde6-0c7c924e8282/version/3a97617a-c592-4f12-a766-fde92905d39b?tab=define">this example</a>.</li><li><strong>Define variables</strong>: Add the ID for the API from the previous step and your <a href="https://go.postman.co/settings/me/api-keys">Postman API key</a> as collection variables. Store the <a href="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.13.1/js-yaml.js">source code</a> for <a href="https://www.npmjs.com/package/js-yaml">this YAML parser</a> in a <a href="https://learning.postman.com/docs/sending-requests/managing-environments/">global variable</a> called yaml-js.</li><li><strong>Confirm scripts work as expected</strong>: Send the call Using a script to see the components in action.</li><li>Update the API to customize your functions, or add new ones.<strong>Customize your own components:</strong></li></ol><h3>Assessing the workaround for your use case</h3><h4>What part of this solution works well?</h4><ul><li>You can organize a custom group of scripts using an x- prefix in the OpenAPI definition, such as for functions, tests, and other scripts.</li><li>The OpenAPI definition is in Postman already, so you can add, edit, and run the new code in Postman without switching context.</li><li>You can share these reusable components with team members in a team workspace.</li></ul><h4>What part of this solution does not work well?</h4><ul><li>This is not the intended purpose for reusable components in an OpenAPI definition.</li><li>The reusable components are not written in a text editor, so syntax highlighting and formatting of JavaScript is missing. It’s easier to copy and paste code into the API definition.</li><li>eval() poses <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval!">a major security risk</a> and the user can run malicious code or code with unintended consequences.</li></ul><p>Does this satisfy your particular use case? If not, this was not the only way to solve this problem. For example, the YAML parser was saved as a global variable available within a workspace, but we could have also made a call to a CDN to retrieve the source code for the library. We also used the Postman API to retrieve an API definition containing our reusable components, but we could have accessed our local file system for saved scripts instead.</p><p>Feel free to explore some of the other alternatives listed above. And let us know some of your favorite hacks that you use in Postman in the comments below.</p><p><em>Technical review by Ian Douglas</em></p><p><em>Originally published at </em><a href="https://blog.postman.com/create-reusable-tests-and-scripts-with-openapi-reusable-components/"><em>https://blog.postman.com</em></a><em> on February 9, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e065fbbc29f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/create-reusable-tests-and-scripts-with-openapi-reusable-components-1e065fbbc29f">Create Reusable Tests and Scripts with OpenAPI Reusable Components</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Set Up a WebSockets Server in Node.js]]></title>
            <link>https://medium.com/better-practices/set-up-a-websockets-server-in-node-js-b32da63f4f94?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/b32da63f4f94</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Joyce Lin]]></dc:creator>
            <pubDate>Wed, 01 Feb 2023 16:40:30 GMT</pubDate>
            <atom:updated>2023-02-01T16:40:30.143Z</atom:updated>
            <content:encoded><![CDATA[<h4>And use Postman to send and receive messages across the WebSocket connection</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6DO93c3_KL111OXr.jpg" /></figure><p>The <a href="https://www.rfc-editor.org/rfc/rfc6455">WebSocket protocol</a> provides a way to exchange data between a client and server over a persistent connection. The data can be passed in both directions with low latency and overhead, and without breaking the connection. This means the server can independently send data to the client without the client having to request it, and vice versa.</p><p>WebSockets are great for building real-time functionality into web applications, such as games and chat apps, or for communicating financial trading data or IoT sensor data. More and more people are exploring <a href="https://learning.postman.com/docs/sending-requests/websocket/websocket/">WebSocket APIs in Postman</a>. According to Postman’s <a href="https://www.postman.com/state-of-api/api-technologies/#api-technologies">2022 State of the API report</a>, WebSockets are used by 26% of respondents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tgHSwtqBUwTolNj7pa2uyw.png" /><figcaption>According to the Postman State of the API report, WebSockets are used by 26% of respondents.</figcaption></figure><p>In this tutorial, let’s create a WebSocket server, and use Postman to send and receive messages across the WebSocket connection.</p><h3>Pre-requisites</h3><p>To follow along with this tutorial, you’ll need the following:</p><ul><li><a href="https://nodejs.org/en/download/">Node.js</a> installed on your machine</li><li>A text editor like <a href="https://code.visualstudio.com/download">VSCode</a> installed on your machine</li></ul><h3>Create the Node.js server</h3><p>In your terminal, make a new directory called websockets with the following command:</p><pre>mkdir websockets</pre><p>Then, navigate into the new directory:</p><pre>cd websockets</pre><p>Next, install , a WebSockets library for Node.js:</p><pre>npm install ws</pre><p>Installing the WebSockets library like this also initializes your Node.js project and creates a package where your project files are stored. Open the websockets directory using your preferred text editor, like VSCode. You should see the project files scaffolded as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*W0V1jIyasxCfZe4MlpuhaQ.png" /><figcaption>One sub-directory and two files at the first level of the root directory.</figcaption></figure><p>Look inside the package.json file to see the ws dependency. Add the &quot;type&quot;: &quot;module&quot; to the package.json so we can load an ES module in the next step. Your package.json should look like the following:</p><pre>{<br>  &quot;type&quot;: &quot;module&quot;,<br>  &quot;dependencies&quot;: {<br>    &quot;ws&quot;: &quot;^8.12.0&quot;<br>  }<br>}</pre><p>In the root directory, create a file called index.js and paste the following code from the <a href="https://www.npmjs.com/package/ws">ws</a> documentation for a “Simple server.” This code initializes the WebSockets server. Upon establishing a connection between the client and this server (once running), the server will send the message “something” to the client:</p><pre>import { WebSocketServer } from &#39;ws&#39;;<br><br>const wss = new WebSocketServer({ port: 8080 });<br><br>wss.on(&#39;connection&#39;, function connection(ws) {<br>  ws.on(&#39;message&#39;, function message(data) {<br>    console.log(&#39;received: %s&#39;, data);<br>  });<br><br>  ws.send(&#39;something&#39;);<br>});</pre><p>It’s now time to run our server locally from the command line:</p><pre>node index.js</pre><h3>Send and receive WebSocket messages</h3><p>In Postman, select <strong>New &gt; WebSocket Request</strong> to open a new tab. Enter the WebSocket server URL. A WebSocket URL begins with ws:// or wss:// and our server is running on localhost:8080. Click <strong>Connect</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qWY5zeasY-XUw4QBiRKmjA.png" /><figcaption>Connect to local server and receive a WebSocket message.</figcaption></figure><p>Once Postman establishes the connection to your local server, the <strong>Messages</strong> pane will display a list of messages for the WebSocket connection, including incoming, outgoing, and network messages. You can further inspect the connection details by clicking on “Connected to ws://localhost:8080”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u0OyzDzypULmDAFevhKzBQ.png" /><figcaption>Inspect handshake details.</figcaption></figure><p>The connection we established between the Postman client and local server is bidirectional, which means that in addition to receiving messages, we can also send them. Under the <strong>Message</strong> tab, write your own message and click <strong>Send</strong>.</p><p>If you have good reflexes, you may have seen your outgoing message in the <strong>Messages</strong> pane. If not, filter for the message using the controls or search bar in the <strong>Messages</strong> pane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5brqFYnsAhggDVlii2OYJw.png" /><figcaption>Filter or search for specific messages in the Messages pane.</figcaption></figure><p>Verify the outgoing message was received by your local server:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*etQjq1hJtYTMHjgk.png" /></figure><h3>Send system information</h3><p>Let’s update our WebSockets server to send something a little more interesting, like our computer’s information, using the <a href="https://www.npmjs.com/package/systeminformation">systeminformation</a> node package. Terminate the running server ( <strong>Ctrl + C</strong>) and install the package from the command line:</p><pre>npm install systeminformation</pre><p>Next, import the package by adding the following code to the top of index.js:</p><pre>import si from &quot;systeminformation&quot;;</pre><p>Add the following code immediately after our WebSocket connection sends the string “something”. Every 1,000 milliseconds, we will send a message about the current load on our CPU.</p><pre> setInterval(async () =&gt; {<br>    const cpuTemp = JSON.stringify(await si.currentLoad());<br>    ws.send(cpuTemp);<br>  }, 1000);</pre><p>Save your changes, and restart the local server from the command line:</p><pre>node index.js</pre><p>Return to Postman and <strong>Connect</strong> to the local server. This time, we receive information about our CPU every second!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u5JHdtrndrVpKCwqqwU-yw.png" /><figcaption>Local server sends CPU data every one second.</figcaption></figure><p>Click on a message to expand the message details and further inspect the data sent from our local server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KfA1L9IXgE_A3qG3naNP2g.png" /><figcaption>Expand message details.</figcaption></figure><p>The messages will keep coming until you terminate the connection. Use Postman to <strong>Disconnect</strong> from the server.</p><p>Now that we have a functioning WebSocket server, we can do more things.</p><ul><li>Slow down the messages coming from the local server. Try updating 1000 milliseconds to 3000 milliseconds to see what happens.</li><li>Instead of sending all the data, try sending only the average load. You may want to inspect the messages in Postman to parse the data properly.</li></ul><p>We can write more code to customize our local application. Upon receiving a message from the client, we can do more than logging the message to the console. We can also retrieve data from other sources and perform calculations before sending our messages to the client.</p><h3>Additional resources</h3><p>To follow along with this tutorial, watch the <a href="https://www.youtube.com/watch?v=e__oWJ4wNtw">video</a> and reference the documentation at <a href="https://quickstarts.postman.com/guide/websockets_node/index.html">Postman Quickstarts</a>:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fe__oWJ4wNtw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3De__oWJ4wNtw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fe__oWJ4wNtw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa44197934f96630c70ce723f6ece132/href">https://medium.com/media/fa44197934f96630c70ce723f6ece132/href</a></iframe><p>Check out these Postman resources to learn more about WebSockets:</p><ul><li><a href="https://www.postman.com/postman/workspace/websockets/documentation/14057978-712d684f-c252-4bd9-a7a6-6a893e41adea">Guide to Postman WebSockets</a> collection</li><li><a href="https://learning.postman.com/docs/sending-requests/websocket/websocket/">Using WebSocket requests</a> docs</li><li><a href="https://youtu.be/H-7EZVj9D-k">WebSocket requests</a> video</li></ul><p>In the next post, we will explore how to use our WebSockets server with Internet of Things (IoT) devices and do neat stuff around the home. Let us know in the comments below what kind of projects you want to learn more about, and what you’re doing with WebSockets.</p><p><em>Technical review by Ian Douglas.</em></p><p><em>Originally published at </em><a href="https://blog.postman.com/set-up-a-websockets-server-in-node-js-postman/"><em>https://blog.postman.com</em></a><em> on February 1, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b32da63f4f94" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/set-up-a-websockets-server-in-node-js-b32da63f4f94">Set Up a WebSockets Server in Node.js</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Postman Essentials: Exploring the Collection Format]]></title>
            <link>https://medium.com/better-practices/postman-essentials-exploring-the-collection-format-1a8b08d79fca?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/1a8b08d79fca</guid>
            <category><![CDATA[postman-collections]]></category>
            <category><![CDATA[collection]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Gbadebo Bello]]></dc:creator>
            <pubDate>Fri, 21 Oct 2022 03:44:07 GMT</pubDate>
            <atom:updated>2022-10-21T03:44:07.430Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0Tkt-B9ruk43Bzhx.jpeg" /></figure><p>If you’re one of the <a href="https://blog.postman.com/celebrating-20-million-postman-users/">20 million people who use Postman</a>, then you’ve worked with <a href="https://www.postman.com/collection/">Postman Collections</a> in one way or another. Collections are a great way to organize API requests, and they allow developers to easily create, share, and collaborate on different APIs. Collections can be used for almost any API workflow, whether it’s mocking, monitoring, testing, or documenting an API. But how are collections able to do so much? Let’s take a closer look at what collections really are.</p><blockquote><strong>Note: </strong>The terms “collection” and “collection format” are both used in this article. They mean the same thing, but what makes them seem different is the context in which we use them. For instance, we use the word “collection” when working within Postman, but we use the phrase “collection format” when discussing exported collections.</blockquote><h3>What is the collection format?</h3><p>The collection format is an open-source <a href="https://github.com/postmanlabs/schemas">JSON format</a> that lets us organize API requests and work seamlessly across the <a href="https://blog.postman.com/api-lifecycle-blueprint/">API lifecycle</a>. Collections provide machine- and human-readable representations of APIs that are portable, shareable, and executable. You can also define different parameters and aspects of your API. This is similar to what you can do with other API definition formats, such as <a href="https://blog.postman.com/postman-now-supports-openapi-3-1/">OpenAPI</a> and RAML, except that the collection format lets you create workflows for your APIs and work across its lifecycle. It can be helpful to think of a collection as an API engine-one that helps you drive an API across its entire lifecycle.</p><p>Most of the time, we don’t need to think about how collections work unless we need to do a low-level task. For instance, if you’ve ever <a href="https://learning.postman.com/docs/getting-started/importing-and-exporting-data/#exporting-postman-data">exported a collection</a> from within Postman, you will notice that the exported JSON file contains all the information about your collection. Importing this file back into Postman helps you pick up where you left off with your requests, documentation, environments, variables, mocks, request headers, tests, and pre-request scripts.</p><p>The collection structure is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*-Rn0w8vNc80FCEpl.png" /><figcaption>Basic Structure of a Collection</figcaption></figure><p>A very basic collection in JSON will look like this:</p><pre>{<br>  &quot;information&quot;: {<br>    &quot;name&quot;: &quot;My Collection&quot;,<br>    &quot;description&quot;: &quot;This is a demo collection.&quot;,<br>    &quot;schema&quot;: &quot;https://schema.postman.com/collection/json/v2.1.0/draft-07/collection.json&quot;<br>   },<br>  &quot;item&quot;: []<br>}</pre><p>At the top level, collections have two main properties: “information” and “item.” The “information” property contains the general metadata about the collection, such as its name, description, and <a href="https://schema.postman.com/">schema</a>. An “item” is the basic building block of a collection. It allows you to specify a request, its corresponding response, and related metadata. An item can be an object or an array of different items. When it is an array, it contains some additional metadata and is called an “item-group.” You can think of an “item-group” as a folder of items that optionally has its own name, description, and events.</p><pre>{<br>  &quot;id&quot;: &quot;an-item-example&quot;,<br>  &quot;name&quot;: &quot;First Folder&quot;,<br>  &quot;description&quot;: &quot;This is an ItemGroup(folder) that contains two items&quot;,<br>  &quot;item&quot;: [<br>    {<br>      &quot;id&quot;: &quot;1&quot;,<br>      &quot;name&quot;: &quot;Item A&quot;,<br>      &quot;request&quot;: &quot;https://postman-echo.com/get&quot;<br>    },<br>    {<br>      &quot;id&quot;: &quot;2&quot;,<br>      &quot;name&quot;: &quot;Item B&quot;,<br>      &quot;request&quot;: &quot;https://postman-echo.com/headers&quot;<br>    }<br>  ]<br>}</pre><p>In the snippet above, the “request” property of the item has a URL as its value. However, the value of an item’s “request” property is much more than just a URL; it is an object that can be used to represent other parts of an API request, such as the request headers, body, and anything else that is needed to successfully make an API request. The snippet below shows the basic structure of a request:</p><pre>{<br>  &quot;description&quot;: &quot;This is a sample POST request&quot;,<br>  &quot;url&quot;: &quot;https://postman-echo.com/post&quot;,<br>  &quot;method&quot;: &quot;POST&quot;,<br>  &quot;header&quot;: [<br>    {<br>      &quot;key&quot;: &quot;Content-Type&quot;,<br>      &quot;value&quot;: &quot;Application/JSON&quot;<br>    },<br>    {<br>      &quot;key&quot;: &quot;host&quot;,<br>      &quot;value&quot;: &quot;postman-echo.com&quot;<br>    }<br>  ],<br>  &quot;body&quot;: {<br>    &quot;mode&quot;: &quot;urlencoded&quot;,<br>    &quot;urlencoded&quot;: [<br>      {<br>        &quot;key&quot;: &quot;some-variable&quot;,<br>        &quot;value&quot;: &quot;Something awesome!&quot;<br>      }<br>    ]<br>  }<br>}</pre><p>We’ve covered a basic example of what a request looks like in JSON, but there’s a lot more that can be represented with collections, such as API responses, tests, and documentation.</p><h3>Why are collections useful?</h3><p>Collections have a lot of use cases that vary depending on the environment in which they are run and the needs of the person running them. Here are some of the reasons why Postman Collections have become essential to so many developers:</p><p>An API contract is a formal business agreement between producers and consumers of an API. It is a shared understanding of what an API is expected to provide. Collections are the foundation of every API contract in Postman, as their simplicity, readability, and ease-of-use makes them well-suited to serve this purpose.</p><p>If you’ve ever used the <a href="https://www.postman.com/api-first/">API-first</a> approach, you will understand that the ability to easily work across the lifecycle of an API is very crucial to the quality of the APIs you build. Collections give you this ability and provide a unique interface for you to easily represent different stages of your API.</p><h4>Collections are highly portable</h4><p>Collections have an intuitive structure and an extremely portable format that can be shared and used in different environments without losing functionality. Part of the reason collections are so portable is that everything in a collection is divided into subunits that can be reused elsewhere in the collection.</p><h4>Collections work across different specs</h4><p>With the help of tooling, collections are very interoperable. You can convert a collection to an OpenAPI definition and vice versa. In Postman’s <a href="https://learning.postman.com/docs/designing-and-developing-your-api/the-api-workflow/">API Builder</a>, you can import your API definitions in a variety of formats, such as OpenAPI and GraphQL, and use them to generate collections for different purposes, including mocking, documentation, and testing.</p><h3>How can you run collections?</h3><p>The interoperability and portability of collections, which we discussed above, allows them to be run in any environment with a variety of tools. For instance, collections can be run:</p><h4>On the command line, using Newman or the Postman CLI</h4><p><a href="https://github.com/postmanlabs/newman">Newman</a> is a command-line interface (CLI) tool that allows you to run collections in a command-line environment. You can use it to run tests and integrate it with your CI/CD pipelines. Newman can also be run as a JavaScript library.</p><p>Alternatively, you can use the <a href="https://learning.postman.com/docs/postman-cli/postman-cli-overview/">Postman CLI</a>, which enables you to run your collections, perform governance and security checks, and easily test your APIs from the command line. It syncs with your Postman account and uploads your run reports back to Postman, allowing you to do all your automation testing and pipeline runs in one place.</p><h4>In your code, using the Postman Runtime</h4><p>The <a href="https://github.com/postmanlabs/postman-runtime">Postman Runtime</a> is an open source NodeJS library used internally at Postman that allows developers to work seamlessly with collections. It is much more low level than Newman; in fact, Newman was built on top of it. The Postman Runtime allows you to run collections while giving you the ability to specify parameters for timeout, strict SSL, host lookups, agents, proxies, certificate lists, and more. The Postman Runtime is also used by the <a href="https://learning.postman.com/docs/running-collections/intro-to-collection-runs/">Collection Runner</a> in Postman to run your collections.</p><h4>With the Postman API and webhooks</h4><p>You can use the <a href="https://www.youtube.com/watch?v=wdLvXKkXhLk">Postman API</a> to create a webhook that lets you initiate a collection run by sending a request to it. This is particularly useful if you have some automation running and you want to trigger a collection run in response to a specific event.</p><p>Collections can do much more than most people think; there is so much that can be built and achieved with the format. The schema is completely open source and can be found on <a href="https://github.com/postmanlabs/schemas">GitHub</a>.</p><p><em>Originally published at </em><a href="https://blog.postman.com/postman-essentials-exploring-the-collection-format/"><em>https://blog.postman.com</em></a><em> on September 29, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a8b08d79fca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/postman-essentials-exploring-the-collection-format-1a8b08d79fca">Postman Essentials: Exploring the Collection Format</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To Build (an SDK), or not to Build — that is the question!]]></title>
            <link>https://medium.com/better-practices/to-build-an-sdk-or-not-to-build-that-is-the-question-142aab534e6b?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/142aab534e6b</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[sdk]]></category>
            <dc:creator><![CDATA[Shahar Davidson]]></dc:creator>
            <pubDate>Tue, 09 Aug 2022 17:41:19 GMT</pubDate>
            <atom:updated>2022-08-09T17:41:19.094Z</atom:updated>
            <content:encoded><![CDATA[<h3>To Build (an SDK), or not to Build — that is the question!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/0*ZYHU9F8LrS6ybtJK" /></figure><p>If you are building a SaaS product, you most likely also provide an API for your product.</p><p>At some point, you will probably consider whether you should also provide your customers with an <a href="https://en.wikipedia.org/wiki/Software_development_kit">SDK</a> for the API.</p><p>In this article, I will list the advantages of supporting SDKs and the challenges of developing them.</p><h3>Advantages</h3><p>The most prominent argument for building SDKs is that SDKs deliver <strong>a better developer experience</strong>. A better developer experience means higher adoption and usage of the API the company is offering, which means increased usage of the product, which in turn contributes to growth.</p><p>The reasons that SDKs offer a better developer experience are:</p><ul><li>Without an SDK, the developers would have to develop by themselves the functions for calling the API. Such a task is perceived as lacking challenge and mundane by developers, and they would prefer to avoid it (although creating a high-quality SDK has its challenges). In addition, the SDK would have to be maintained to be up to date with the latest API changes and additions, and that’s something that clients would prefer to avoid.</li><li>In many APIs, a single API call will not accomplish the operation that the developer intends to program — in some cases, more than one API call is required to perform an operation. For example, authentication token renewal — SDKs that are built correctly will be able to abstract this operation, and the token renewal could be done seamlessly, whereas if an SDK would not have been available, then the developer would have to develop a mechanism that can identify when the token has expired and trigger a renewal call before continuing to make the wanted API call.</li><li>SDKs usually come with documentation that includes examples of how to make certain operations, and developers love examples on which they can rely. They say “a picture is worth a thousand words”; for developers, a single code example is worth a thousand words.</li></ul><p>The more your customers use your product’s API for integration with their product, the more likely their satisfaction will increase if you provide them with an SDK, which will lead to more growth.</p><h3>Challenges</h3><p>If your product comes with an API and you are thinking about starting to develop an SDK for your customers, then there are some challenges that you must be aware of.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/0*lh-qVjpSpQtrsGqz" /></figure><ol><li><strong>Initial creation and ramp-up</strong> <strong>time </strong>— For each of the languages that you plan to provide an SDK, keep in mind that you will have to build a CI/CD pipeline end-to-end, just as with any service or library that you are maintaining — that will take some time to build and get right: generating or writing the code, triggering tests, updating the documentation for each language and releasing the SDK.</li><li><strong>Ongoing maintenance and development </strong>— Maintaining SDKs will require more effort than you may imagine. As you release your SDKs and customer adoption of the SDK increases, customers will start reporting issues and bugs which you will have to handle. In addition, you will need to update the SDKs with every API change or enhancement. That’s quite a lot of effort. Just to give you some perspective, mid-sized startups (~100 employees) may have a team of 3–5 developers to maintain the SDKs. In Fortune 500 companies, you might find a group of 10–20 engineers dedicated to SDK development and maintenance. Therefore, you should regard the SDK as another product in the line of products that you are offering and allocate resources accordingly.</li><li><strong>Release management</strong> — Release management of SDKs is challenging. Assume you provide SDKs to your customers in 5 different languages. Given a new update to the API, ask yourself how do you time and control the release of a new change for all these SDKs? How do you know that all SDKs are ready for release and of high quality?<br>End of life is also challenging because you cannot force clients to switch SDKs, and convincing them to upgrade their SDK version is also challenging. So given that you support 5 SDKs and you have released 10 changes to the SDKs (following 10 API updates) then you in fact need to track <strong>50 different versions of your SDKs</strong>. Tracking the SDK version used by each client is also challenging once you get to tens of customers or upwards (each one is using a different SDK version for a different language). <br>As you may understand, this may get really complicated, and you will sooner or later find yourself appointing or taking on the role of a release manager.</li></ol><h3>Should you build it?</h3><p>If your product is an API-driven product, meaning the provided API is at the core of your product offering, a.k.a. <a href="https://www.postman.com/lp/api-first-company/"><em>API-first</em></a><em> product</em> (such as Stripe, Twilio, etc.), then the answer is a definite “<strong>Yes!</strong>”. As a company building an API-first product, your customers expect you to provide an SDK.</p><p>There are other cases where you might not be building an API-first product but you should consider providing an SDK. Such cases are when your product might need a minimal API integration with the customer’s application, such as in their web client, in order to operate correctly, but they are required to perform a series of API operations for the integration. In such cases, not providing an SDK that wraps that series of calls will result in customers spending time with your technical support team, or engineering team, to complete the integration properly. This would lead to customer dissatisfaction and a lot of effort for your support team and your customers.</p><p>An SDK will immensely increase the integration experience and preserve your company’s reputation.</p><p>Otherwise, do not go for an SDK unless you feel that it is a deal enabler, meaning a prospect will buy your product (preferably writing a big check) if it comes with an SDK for the language of their choice. But keep in mind that once you provide support for one customer, other customers or prospects may follow suit and also ask for an SDK for their language of choice.</p><p>Some companies choose to create an open source SDK and release it with a disclaimer saying that the SDK is maintained by the community, but this should be thoroughly considered because not doing any maintenance or neglecting the open source may somewhat affect your reputation as a company.</p><p>Finally, keep in mind that in some cases, you can delegate the creation of the SDK to the client by providing a complete and well-structured <a href="https://www.openapis.org/">OpenAPI</a> schema. By doing so, clients can use open source SDK generators such as <a href="https://openapi-generator.tech/">OpenaAPI-generator</a> to create an SDK for their own use.</p><h3>Summary</h3><p>Building an SDK will increase customer satisfaction by providing a better developer experience, and help product adoption.</p><p>Providing SDKs has become a standard for <a href="https://blog.postman.com/how-do-you-become-api-first-company/">companies building API-first products</a>.</p><p>Building and maintaining SDKs requires considerable effort, and any company which does not build API-first products should thoroughly assess the cost-effectiveness of building and supporting SDKs.</p><p><strong>Feel free to share any tips or tools you have learned from building SDKs in the past in the comments.</strong></p><p>Thank you for taking the time to read this article. I hope you found it helpful. If so, show your love and add some claps.</p><p>Follow me for more articles about team building, software engineering, technology, and technology-enabled business opportunities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=142aab534e6b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/to-build-an-sdk-or-not-to-build-that-is-the-question-142aab534e6b">To Build (an SDK), or not to Build — that is the question!</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How complex can Authorization get?]]></title>
            <link>https://medium.com/better-practices/how-complex-can-authorization-get-5011c9dfb0fa?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/5011c9dfb0fa</guid>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[access-control]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[identity-and-access]]></category>
            <category><![CDATA[access-management]]></category>
            <dc:creator><![CDATA[Manoj Vignesh K M]]></dc:creator>
            <pubDate>Wed, 23 Mar 2022 16:13:25 GMT</pubDate>
            <atom:updated>2022-03-20T14:12:17.983Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*on8uU-OVzSFIyLB2gRk2nw.jpeg" /><figcaption>source: <a href="https://www.freeimages.com/download/private-property-no-trespassing-1205389">https://www.freeimages.com/download/private-property-no-trespassing-1205389</a></figcaption></figure><p><strong>I</strong>dentity and <strong>A</strong>ccess <strong>M</strong>anagement system deals with “who” should get “what” level of access to an object (entity) or a function. The subsystem that defines “who” is called Authentication (Identity), while the subsystem that defines “what” level of access is called <strong>Authorization</strong> (Access).</p><p>Building an IAM system can get very complex quickly. No wonder “Broken Authentication” and “Broken Authorization” are listed in <a href="https://owasp.org/www-project-top-ten/">OWASP Top Ten WebApp Security risks</a> and <a href="https://owasp.org/www-project-api-security/">OWASP Top Ten API Security risks</a>. Security risks in IAM system arises due to flawed or missed logic, or due to gap in the implementation and design due to it’s complexity.</p><p>This article explains the evolution of the Authorization component of an IAM system with the growth of the software. Let us consider a content management system (such as <a href="https://medium.com">Medium</a>) for example while we build it up. Here,</p><ul><li>Let <em>V1</em> be the visitor (unauthenticated) user, and <em>M1 … M3</em> be the member (authenticated) users.</li><li>Let <em>B1 … B5</em> be the Blog entities</li><li>Let Read (<em>R</em>), Write (<em>W</em>) and Clap (<em>C</em>) be the actions that can be performed on the entities</li></ul><p>The notation:</p><pre>{u, v} can {a, b} on {m, n}</pre><p>Implies, a nested Cartesian product:</p><pre>{Set of users} can (perform) {Set of actions} on {Set of Entities}</pre><pre><strong>u</strong> can <strong>a</strong> on <strong>m</strong>, <strong>u</strong> can <strong>a</strong> on <strong>n</strong>, <strong>u</strong> can <strong>b</strong> on <strong>m</strong>, <strong>u</strong> can <strong>b</strong> on <strong>n, v</strong> can <strong>a</strong> on <strong>m</strong>, <strong>v</strong> can <strong>a</strong> on <strong>n</strong>, <strong>v</strong> can <strong>b</strong> on <strong>m</strong>, <strong>v</strong> can <strong>b</strong> on <strong>n</strong></pre><h3>Unprotected systems</h3><p>Let us begin from zero. A system in which anyone has access to anything. There is no authentication nor authorization in place. A system with such characteristics defines the starting point for IAM. IAM does not exist or does nothing in such a system.</p><p>The CMS in this state has all the blogs readable, writable and clap-able by any visitor and/or member.</p><pre>{V1, M1, M2, M3} can {R, W, C} on {B1, B2, B3, B4, B5}</pre><h3>All-or-Nothing</h3><p>In such systems, there are two access levels for entities: public and private. Certain entities may be tagged public which implies that this entity can be acted upon by any user. While, certain entities can be tagged private which implies that this entity can be acted only upon by a specific user. To identify a specific user authentication is required.</p><p>Let, blog <em>B1</em> be a private blog to <em>M1</em>,<em> B2</em> be a private blog to <em>M2</em> while the rest be public. Then,</p><pre>{V1, M1, M2, M3} can {R, W, C} on {B3, B4, B5}, or<br>{<strong>M1</strong>} can {R, W, C} on {<strong>B1</strong>}, or<br>{<strong>M2</strong>} can {R, W, C} on {<strong>B2</strong>}</pre><h3>Controlled Sharing</h3><p>This is where IAM starts to become complex. To enable collaboration and feedback, restricting access levels for entities to only public and private may not be valuable. To better understand the build up of controlled sharing let us break it down into the multiple sub-phases.</p><h4>Controlled Sharing: All-or-Nothing</h4><p>Customers of CMS complain that private blogs are too restrictive. They want to be able to share the blog(s) only to a certain specific set of users for collaboration.</p><p>In such systems, there are three access levels for entities: public, shared and private. Public and private continue to hold the definitions from All-or-Nothing system. A shared entity is an entity that can be acted upon only by a specific set of users.</p><p>Let <em>B1</em> be a private blog to <em>M1</em>, <em>B2</em> be a private blog to <em>M2</em>, <em>B3</em> be a shared blog to <em>M2</em> and <em>M3</em>, while the rest be public. Then,</p><pre>{V1, M1, M2, M3} can {R, W, C} on {B4, B5}, or<br>{M1} can {R, W, C} on {B1}, or<br>{<strong>M2</strong>} can {R, W, C} on {B2, <strong>B3</strong>}, or<br>{<strong>M3</strong>} can {R, W, C} on {<strong>B3</strong>}</pre><h4>Nested Controlled Sharing</h4><p>Customers now complain of shared blogs being too open to the authorized set of users. They want to be able to restrict the set of actions a specific subset of the authorized users can perform. For example, “while I have full access to the blog, I want my peer(s) to only read it and not be able to edit it.”</p><p>In such systems, there again exists three levels of access: public, private and shared, with private and public continuing to hold it’s definition from All-or-Nothing system. The shared access level, which used to deal with only one parameter i.e Entity, now deals with two parameters i.e. Action and Entity. <strong>Side Note</strong>: The (Action, Entity) tuple is called a permission.</p><p>Let <em>B1</em> be a private blog to <em>M1</em>, <em>B2</em> be a private blog to <em>M2</em>, <em>B3</em> be a shared blog to <em>M2</em> and <em>M3</em>, with <em>M2</em> having the ability to perform only <em>R</em>, and <em>C</em> actions, while <em>M3</em> be able to perform <em>R</em>, <em>W</em> and <em>C</em> actions on it. Meanwhile, let the rest of the entities be public. Then,</p><pre>{V1, M1, M2, M3} can {R, W, C} on {B4, B5}, or<br>{M1} can {R, W, C} on {B2}, or<br>{M2} can {R, W, C} on {B2}, or<br>{<strong>M2</strong>} can {<strong>R, C</strong>} on {<strong>B3</strong>}, or<br>{<strong>M3</strong>} can {<strong>R, W, C</strong>} on {<strong>B3</strong>}</pre><h4>Dynamic Nested Controlled Sharing</h4><p>All this while we have been looking at static rules to define authorization. It would be unmanageable and cumbersome to contact the service provider to edit the authorization rules with new entities, new users and new requirements (changing users/entities).</p><p>This introduces a new action, Grant (<em>G</em>), on actions that can be performed on an entity. For example, Grant Read (<em>GR</em>) is defined as the ability to grant read access to the entity in reference to any other user.</p><p>Consider the same scenario as mentioned in the Nested Controlled Sharing case. The new set of authorization rules would then be,</p><pre>{V1, M1, M2, M3} can {R, W, C, <strong>GR, GW, GC</strong>} on {B4, B5}, or<br>{M1} can {R, W, C, <strong>GR, GW, GC</strong>} on {B2}, or<br>{M2} can {R, W, C, <strong>GR, GW, GC</strong>} on {B2}, or<br>{M2} can {R, C} on {B3}, or<br>{M3} can {R, W, C, <strong>GR, GW, GC</strong>} on {B3}</pre><h4>Conclusion on Controlled Sharing</h4><p>At this point, it is worth mentioning about different Access Control schemes.</p><ul><li><strong>Discretionary Access Control (DAC)</strong>: The owner (creator) of the entity possess grant permissions (Recall, permission is (Action, Entity) tuple).<br>For example, in the CMS system with {V1, M1, M2, M3} users, {R, W, C} actions and {} blogs, when <em>M1</em> creates a blog <em>B1</em>, the authorization rules are:</li></ul><pre>{V1, M1, M2, M3} can {R, W, C, GR, GW, GC} on {}, or<br>{<strong>M1</strong>} can {<strong>R, W, C, GR, GW, GC</strong>} on {<strong>B1</strong>}</pre><ul><li><strong>Mandatory Access Control (MAC)</strong>: A specific administrator has access to grant permissions.<br>For example, in the CMS system with {V1, M1, M2, M3} users, {R, W, C} actions and {} blogs, and <em>M1</em> being the administrator, when <em>M2</em> creates a blog <em>B1</em>, the authorization rules are:</li></ul><pre>{V1, M1, M2, M3} can {R, W, C, GR, GW, GC} on {}, or<br>{<strong>M1</strong>} can {<strong>GR, GW, GC</strong>} on {<strong>B1</strong>}<br>{<strong>M2</strong>} can {<strong>R, W, C</strong>} on {<strong>B1</strong>}</pre><ul><li><strong>Role-Based Access Control (RBAC)</strong>: A complex access control scheme that includes Role as an Entity, in addition to blog. The actions on the Role are: assume (A) (For simplicity) (Other actions on the role includes read, write, update, delete etc.). Similar to any other actions, assume action can also be granted (GA). In this scheme, a user/role cannot act independently on entities. A user can independently only assume a role. A user on assuming a role can act on an entity, including another role.<br>For example, in the CMS system with {V1, M1, M2, M3} users, {R, W, C} actions on blogs and {A} actions on roles, {} blogs and {R1, R2} roles.<br>Let <em>R1 </em>be a role that can perform anything to any role, while <em>R2</em> be a role that can perform anything on any blog. Let <em>R1 </em>be assumable only by <em>M1</em>, <em>R2 </em>be assumable by any authenticated user, <em>M2</em> assumes <em>R2</em> and creates a blog <em>B1</em>.</li></ul><pre>{<strong>R1</strong>} can {<strong>GA</strong>} on {<strong>R1, R2</strong>}<br>{<strong>R2</strong>} can {<strong>R, W, C, GR, GW, GC</strong>} on {<strong>B1</strong>}, or<br>---<br>{V1} can {R, W, C, A} on {}, or<br>{M1, M2, M3} can {R, W, C} on {}, or<br>{<strong>M1, M2, M3</strong>} can {<strong>A</strong>} on {<strong>R2</strong>}, or<br>{<strong>M1</strong>} can {<strong>A</strong>} on {<strong>R1</strong>}</pre><h3>User-programmed controlled sharing</h3><p>So far we have been looking at permissions to those entities that are stored. Consider the case when the CMS wants to display the total number of blogs that exists in their system be it public, shared or private to any visitor/member. Further, it wants to display the total number of public, private and shared blogs individually. Though a visitor (unauthenticated) user is not allowed to access the private and shared blogs, he/she should be able to see the above statistics. Moreover, these statistics may or may not be stored. It may be calculated on demand. Access control to such “actions” on such “entities” are categorized into User-programmed controlled sharing.</p><p><strong>Side note</strong>: Hence there exists two different security risks in OWASP top ten, namely: Broken “object” level authorization and broken “function” level authorization.</p><p><strong>Attribute Based Access Control</strong> <strong>(ABAC)</strong> is an access control scheme that involves user-programmed controlled sharing. Consider the case when access to a specific object is given only during a certain time period, say between 9 am to 5 pm IST. And/Or, access to a specific object is given only when the user is located in a specific area, say in a circle with center at (37.7858846, -122.4074781) coordinates and radius 250 m.</p><h3>Conclusion</h3><p>Designing an access control system highly depends on the customer’s needs. Most mature products have dynamic nested controlled sharing capabilities while there are certain features that uses User-programmed controlled sharing. However, critical systems such as military, government, healthcare and finance technology software do have advanced access control systems implemented and enforced. One such advanced access control is “<a href="https://csrc.nist.gov/glossary/term/separation_of_duty">Separation of duty</a>”: A single user cannot individually execute a critical action.</p><p>The complexity in designing an access control system is present in identifying:</p><ul><li>The access control scheme (DAC, MAC, RBAC, ABAC, hybrid or custom?)</li><li>The entities and the granularity to which it needs to be access controlled</li><li>The actions that can be performed on the entity</li><li>The storage schema for the identified entities, actions, and users</li><li>Sequence flow to perform authorization rule check, and</li><li>Other system design choices</li></ul><h3>Reference</h3><p>J. H. Saltzer and M. D. Schroeder, “<a href="https://ieeexplore.ieee.org/document/1451869">The protection of information in computer systems</a>,” in Proceedings of the IEEE, vol. 63, no. 9, pp. 1278–1308, Sept. 1975, doi: 10.1109/PROC.1975.9939.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5011c9dfb0fa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/how-complex-can-authorization-get-5011c9dfb0fa">How complex can Authorization get?</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build a Jamstack application in Postman]]></title>
            <link>https://medium.com/better-practices/how-to-build-a-jamstack-application-in-postman-99aba45a572b?source=rss----410f2fbc015d---4</link>
            <guid isPermaLink="false">https://medium.com/p/99aba45a572b</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[jamstack]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Joyce Lin]]></dc:creator>
            <pubDate>Mon, 31 Jan 2022 16:07:46 GMT</pubDate>
            <atom:updated>2022-01-31T16:03:21.941Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn to JAM with scripts, mock servers, and the visualizer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KSMBMo2Mzyrqgdqk.jpg" /></figure><p>Jamstack originally referenced a web architecture composed of JAM: JavaScript, APIs, and Markup. Websites could be delivered statically, such as serving HTML from static hosting, while providing dynamic content and an interactive experience through JavaScript and APIs.</p><blockquote>“A modern web development architecture based on client-side JavaScript, reusable APIs, and prebuilt Markup”</blockquote><blockquote>— Mathias Biilmann (CEO &amp; Co-founder of Netlify)</blockquote><p>This type of architecture decouples the frontend from the backend. So instead of running on a backend web server, a Jamstack site typically deploys to a content delivery network (CDN) so web content can be delivered quickly from edge servers that are close to the end users and API endpoints can be hosted on serverless architecture.</p><p>Over the last few years, Jamstack has grown beyond just sites to serve static content, and has led to <a href="https://remotesynthesis.com/blog/jamstack-in-2021">colorful debate</a> about what constitutes Jamstack and even opinions about its capitalization. Regardless of your criteria, these static web apps are becoming very popular among hobbyists and global enterprises alike. And their growth is further driven by the booming API economy that can offer any variety of third-party services and turnkey solutions.</p><p>For developers who are new to Jamstack, let’s walk through a simplified example in Postman to see how each part of the JAM works.</p><h3>4 steps to build a Jamstack application in Postman</h3><p>The modular and decoupled nature of Jamstack architecture means there are a bunch of tools available to help you with each part of the implementation. For example, most Jamstack applications are developed using JavaScript web frameworks like <a href="https://nextjs.org/">Next.js</a> and <a href="https://www.gatsbyjs.com/">Gatsby</a>. And then they’re deployed using services like <a href="https://vercel.com/">Vercel</a> and <a href="https://www.netlify.com/">Netlify</a> and hosted on a content delivery network (CDN).</p><p>Let’s build and host a simplified Jamstack application in Postman, using code samples from <a href="https://learning.postman.com/docs/sending-requests/visualizer/">the Postman documentation for the visualizer</a>. And then we will take a closer look at the JAM.</p><h4><strong>1: Create a collection</strong></h4><p>In Postman, create a new collection named Jamstack. Then add a GET request to the collection named API call with the request URL {{url}}/data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*voLt6hBoyEdbLp41v2JgmA.png" /><figcaption>Create a collection</figcaption></figure><h4><strong>2: Add an example response</strong></h4><p>Select the overflow menu (…) of the request to add an example response (e.g.) called Example data. This example response is what will be returned from our mock server. Under the <strong>Body</strong> tab of the example response (on the bottom), select the JSON data type from the dropdown menu. Then add the following placeholder JSON.</p><pre>[</pre><pre>  {</pre><pre>    &quot;name&quot;: &quot;Alice&quot;,</pre><pre>    &quot;email&quot;: &quot;alice@example.com&quot;</pre><pre>  },</pre><pre>  {</pre><pre>    &quot;name&quot;: &quot;Jack&quot;,</pre><pre>    &quot;email&quot;: &quot;jack@example.com&quot;</pre><pre>  }</pre><pre>]</pre><p>If you’re copying from the Postman documentation, make sure to remove the commented row beginning with // and preceding , character so that the JSON is valid.</p><p>Under the <strong>Headers</strong> tab of the example response (still on the bottom), add a header with a key Content-type and value application/json. Lastly, add a response status code of 200 OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ufWpx9u79HC6dpRqa2PdkA.png" /><figcaption>Add an example response</figcaption></figure><h4><strong>3. Add a mock server</strong></h4><p>Select the overflow menu (…) of the collection Jamstack to <a href="https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/setting-up-mock/#creating-a-mock-from-a-collection">add a new mock server</a> called Mock data to the collection. Once Postman finishes creating the mock server, select the new environment created by Postman also called Mock data. Hover on {{url}} in the request URL to see the value being read from the actively-selected environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EckuU7lblqCvgDrWa_MYPw.png" /><figcaption>Add a mock server to the collection</figcaption></figure><h4><strong>4. Visualize the data</strong></h4><p>Select the request API call, and send the request to see the example data returning from the mock server. To update the data returned from the mock server, you can edit the example response body (e.g.). We will continue using code samples from <a href="https://learning.postman.com/docs/sending-requests/visualizer/">the Postman documentation for the visualizer</a>. Under the <strong>Tests</strong> tab, add the following code for an HTML table represented as a template string.</p><pre>var template <strong>=</strong> `</pre><pre>  &lt;table bgcolor=&quot;#FFFFFF&quot;&gt;</pre><pre>    &lt;tr&gt;</pre><pre>      &lt;th&gt;Name&lt;/th&gt;</pre><pre>      &lt;th&gt;Email&lt;/th&gt;</pre><pre>    &lt;/tr&gt;</pre><pre>    {{#each response}}</pre><pre>      &lt;tr&gt;</pre><pre>        &lt;td&gt;{{name}}&lt;/td&gt;</pre><pre>        &lt;td&gt;{{email}}&lt;/td&gt;</pre><pre>      &lt;/tr&gt;</pre><pre>    {{/each}}</pre><pre>  &lt;/table&gt;</pre><pre>`;</pre><p>And then add the following code to pass the response data to render in the template string and instantiate the visualization.</p><pre>// Set visualizer</pre><pre>pm.visualizer.<strong>set</strong>(template, {</pre><pre>  // Pass the response body parsed as JSON as `data`</pre><pre>  response: pm.response.json()</pre><pre>});</pre><p>Save your changes. And then send the call, and toggle over to the <strong>Visualize</strong> tab of the response to see our table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*onSxy_ydY8QhfxDw150Hfw.png" /><figcaption>visualize the response data</figcaption></figure><p>If you want to skip ahead to the finished product, fork this example collection and environment to your own workspace.</p><figure><a href="https://god.gw.postman.com/run-collection/13191452-9e1d8008-416a-476b-8e84-6650cfbd6f87?action=collection%2Ffork&amp;collection-url=entityId%3D13191452-9e1d8008-416a-476b-8e84-6650cfbd6f87%26entityType%3Dcollection%26workspaceId%3D02d1963b-f4c4-49cc-bd6b-13f7015dd726#?env%5BMock%20data%5D=W3sia2V5IjoidXJsIiwidmFsdWUiOiJodHRwczovL2Y3OTNiYWU1LTliNjMtNGYzMC1iOWU3LTNkYTkwMTVhYmQ2Ny5tb2NrLnBzdG1uLmlvIiwiZW5hYmxlZCI6dHJ1ZSwidHlwZSI6InRleHQiLCJzZXNzaW9uVmFsdWUiOiJodHRwczovL2Y3OTNiYWU1LTliNjMtNGYzMC1iOWU3LTNkYTkwMTVhYmQ2Ny5tb2NrLnBzdG1uLmlvIiwic2Vzc2lvbkluZGV4IjowfV0="><img alt="" src="https://cdn-images-1.medium.com/max/600/1*xd57I4ClmglxBQgTfprVrA.png" /></a><figcaption>fork the sample code</figcaption></figure><p>In the next section, let’s dissect the JAM in this example, and think about ways to enhance each component.</p><h3>A closer look at the JAM</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wXARMGvwCwTtGieDjiSC3A.png" /><figcaption>Build a complete Jamstack application in Postman</figcaption></figure><h4><strong>JavaScript</strong></h4><p>The <a href="https://learning.postman.com/docs/sending-requests/visualizer/">visualization</a> is instantiated using the pm.visualizer.set() function invoked in a test script. The <a href="https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/">Postman sandbox</a> provides access to other JavaScript functions and libraries that can be used in pre-request or test scripts. Furthermore, external CDN libraries can be imported using a function like pm.sendRequest() among <a href="https://community.postman.com/t/adding-external-libraries-to-postman/1971/6">other ways of using external libraries</a>.</p><h4><strong>APIs</strong></h4><p>We stored our data using a mock server hosted on Postman cloud, accessing the data with a call to our mock API. This allows us to quickly edit the data and “deploy” our updates by saving our changes to Postman. If we find a third-party service we like, or create our own custom API, we can swap out the API to call. In fact, we can call as many APIs as we wish, synthesize the data and perform calculations to create our own custom services.</p><h4><strong>Markup</strong></h4><p>We visualized an HTML template string that can be styled with CSS. You can also use Handlebars templating language to generate HTML. If you don’t feel like writing your own Markup, search for <a href="https://go.postman.co/search?q=visualizer&amp;scope=all&amp;type=all">other visualizations</a> created by other members of the Postman community. And once again, external CDN libraries can be imported, this time using script tags within the template string.</p><h3>Extend this to production-level applications</h3><p>We did it! It is possible to develop, deploy, and host a complete Jamstack application in Postman. But this was a simplified example. At some point, you may choose to swap out your mock data with a third-party service or your own API hosted on serverless architecture. Or you may decide not to visualize the HTML in Postman, but in a web browser instead. There are a bunch of tools, technologies, and workflows to support your Jamstack applications.</p><p>The Jamstack architecture lets you get creative with your implementation. JavaScript and APIs allow you to pull data dynamically with interactivity limited only by your imagination. And the thriving API economy means your options for this dynamic behavior are growing fast.</p><p>If you want to see more examples of Jamstack applications in Postman, browse <a href="https://go.postman.co/search?q=visualizer&amp;scope=all&amp;type=all">other examples</a> created by members of the Postman community.</p><h3>Watch and learn</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxyOIWGPUeR4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxyOIWGPUeR4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FxyOIWGPUeR4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f8e29c25e8d26db1bef41f0ba64c398/href">https://medium.com/media/9f8e29c25e8d26db1bef41f0ba64c398/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99aba45a572b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-practices/how-to-build-a-jamstack-application-in-postman-99aba45a572b">How to build a Jamstack application in Postman</a> was originally published in <a href="https://medium.com/better-practices">Better Practices</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>