<?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[Stories by James Hickey on Medium]]></title>
        <description><![CDATA[Stories by James Hickey on Medium]]></description>
        <link>https://medium.com/@james_hickey_procedureflow?source=rss-2b11a8df877b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*giQQ5RABByPtB1TgSCxxiA.png</url>
            <title>Stories by James Hickey on Medium</title>
            <link>https://medium.com/@james_hickey_procedureflow?source=rss-2b11a8df877b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 04:05:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@james_hickey_procedureflow/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How We Do Software Engineering At ProcedureFlow]]></title>
            <link>https://medium.com/procedureflow-engineering/how-we-do-software-engineering-at-procedureflow-873fded2d221?source=rss-2b11a8df877b------2</link>
            <guid isPermaLink="false">https://medium.com/p/873fded2d221</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[James Hickey]]></dc:creator>
            <pubDate>Fri, 01 Apr 2022 14:35:26 GMT</pubDate>
            <atom:updated>2022-04-01T14:35:26.539Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*htjFJVL9bW0MJaA2XgROoQ.jpeg" /></figure><p>We are a SaaS startup based out of Canada with a team of 5 fully remote software engineers. We’re growing our team this year - <a href="https://jobs.procedureflow.com/">we’re hiring</a>!</p><p>We know that it’s hard to get an idea of what a prospective company’s culture is like: how they work and what they value. This article highlights what the software engineering culture is like at ProcedureFlow.</p><h3>Our Tech Stack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*etSVeIO6PVEZVwmtiqZu4g.png" /><figcaption>Our Tech Stack</figcaption></figure><p>Our tech stack is very similar to <a href="https://stackoverflow.blog/2008/09/21/what-was-stack-overflow-built-with/">Stack Overflow’s</a>:</p><ul><li>.NET framework and C# for our backend web servers and background process workers</li><li>We’re using React for any non-trivial frontend code, with some older jQuery and Backbone code that we’re converting to React over time</li><li>PostgreSQL is our database our choice</li><li>We’re using Redis for all sorts of things like caching, rate-limiting, distributed locks, async messaging, etc.</li><li>All our web servers run on AWS with load balancing, edge security, etc.</li></ul><p>While microservices are all the rage these days, they aren’t always the best choice. As <a href="https://martinfowler.com/articles/microservice-trade-offs.html">Martin Fowler puts it</a>:</p><blockquote>Monoliths and microservices are not a simple binary choice. Both are fuzzy definitions that mean many systems would lie in a blurred boundary area… no sensible architect treats them as a comprehensive partitioning of the architectural space.</blockquote><p>As far as monoliths go, <a href="https://www.infoq.com/articles/github-monolith-microservices/">GitHub was a monolith up until recently</a>, <a href="https://shopify.engineering/shopify-monolith">Shopify</a> has used a monolithic architecture for their core services and <a href="https://m.signalvnoise.com/the-majestic-monolith/">Basecamp</a> is what one might call a <a href="https://www.blog.jamesmichaelhickey.com/How-To-Build-Modular-Monoliths-With-NETCore-Razor-Class-Libraries/">“modular monolith.”</a></p><p>This architecture works for us because of reasons like operational simplicity (e.g. deployments and automation are easy). This helps our company and team of developers iterate and build things quickly.</p><h3>Security!</h3><p>Security is a big deal for us. You’ve more than likely worked at companies that have poor or no real security practices. I’ve personally worked at places that stored passwords in plain-text 😅.</p><p>However, at ProcedureFlow we’re <a href="https://procedureflow.com/security">SOC 2 certified</a>. We have annual penetration tests and monthly vulnerability scans conducted by third parties. We have policies that we need to follow and document, which are audited on a regular basis.</p><p>We’ve built our production infrastructure with things like redundancy and high availability in mind. All our code is reviewed.</p><p>We’ve written an <a href="https://medium.com/procedureflow-engineering/building-api-authentication-at-procedureflow-4d1fe78bb293">entire article on how we chose to do API authentication</a> for the foundation of our new API infrastructure. This might give you some specific insights into how we work and how we value security.</p><p>For more on this topic, you can check out <a href="https://procedureflow.com/security">the security page</a> on our website.</p><h3>How We Integrate Code</h3><p>For storing, managing and reviewing our code we use <a href="https://gitlab.com/">GitLab</a>.</p><p>All the code that ends up in production goes through a code review. Getting a second pair of eyes on our work has the benefit of double-checking things related to performance, testing, code conventions, etc. This not only includes application code but also important documentation like architectural decisions records.</p><p>We try to keep our pull/merge requests large enough to be meaningful yet small enough to be able to review well and in a timely manner.</p><p>Here’s a general example of how we use Git:</p><ul><li>We might spike a larger feature on a certain branch X with commits per logical piece of the feature.</li><li>If we need to go back and update part 2 of 3, for example, we might interactively rebase part 2 using Git.</li><li>Once we’re done a spike, we can start creating individual branches from each of those commits and create separate MRs for each smaller piece of work.</li><li>Our merge requests are reviewed and merged into `master`. We also have a `production` branch to keep track of what is deployed.</li><li>We use feature flags quite often too. This helps to keep MRs small. We can push non-active code to master. Later, we can enable new features for specific customers using the same flags.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-y_yf1ExsDYRkPdCOoCnpw.png" /><figcaption>How Some Of Our Team Manages Branches In Progress</figcaption></figure><h3>How We Test Code</h3><p>Our code has been built from the beginning with testing in mind. As best as possible, all code that we write will have appropriate unit tests included.</p><p>We use a combination of unit and integration tests for our backend code. We also have a frontend test suite for our JavaScript code.</p><p>Our codebase has convenient tools so that our tests can easily hook into a real database to make integration-like testing straightforward. We can easily build integration tests by making our test class inherit from a special base class which exposes a database session to work against. Kind of like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b6efe4f9cb01e2bd7bf59f815ace976/href">https://medium.com/media/3b6efe4f9cb01e2bd7bf59f815ace976/href</a></iframe><p>For these kinds of tests, the database is cleared after each test. This means that each individual test will have its own context that can be built up and changed as needed. We don’t have to worry about pre-existing users, objects, sessions, etc. in our database tests!</p><p>We also have custom command-line tools that help us to run all of our tests with one command: backend tests, frontend tests, linting, package security monitoring, code compilation checks, etc. These tools help with deployments too.</p><h3>How We Deploy Code</h3><p>Deployments are automated through our own custom command line tooling. With one command we can trigger a full pipeline of testing, building and deployments. We have all the benefits of continuous code integration and quick-and-easy deployments.</p><p>We use other tools like <a href="https://www.terraform.io/">Terraform</a> to deploy our infrastructure to AWS. By using infrastructure-as-code we get many benefits like immutable deployments, documented infrastructure and the ease of being able to configure new infrastructure.</p><p>We can, for example, create some new API infrastructure in our staging environment via Terraform. Once everything is working and tested, we can deploy the same consistent configuration in production without having to manually turn on servers, configure load-balancers by hand, etc. each time we deploy our new infrastructure.</p><p>Feature flags are a tool we love to use. This enables us to push smaller chunks of code while keeping features that are not available hidden from sight until finally released. We have the option to release specific features to specific customers too. This helps us to be able to beta test new features and products 😊.</p><h3>How We Plan And Work Together</h3><h4>Daily Planning</h4><p>We don’t do daily stand-ups. Let’s get that out of the way 😅.</p><p>Well, we kinda do. On Slack each morning, we literally just list out bullet points of what we expect to be working on that day. This just helps to get an idea of what everyone is working on. We all know that the typical “stand-up” usually provides zero benefits at the cost of 20 minutes of wasted time. It’s great that our team has the flexibility to do what works for us.</p><h4>Cycles, Planning And Retrospectives</h4><p>Every 3 weeks we do a retrospective of how things went for each engineer. We have a chance to ask each other questions and demonstrate some of the cool stuff we’ve been working on. Since we aren’t all working on the same features most of the time, it’s nice to have dedicated time to see how other parts of the product and codebase are changing.</p><p>At the beginning of each 3-week cycle, we do a little bit of planning. Nothing crazy, but generally we take a broad look at what larger features and tasks are in scope for the next 3 weeks. We discuss what we think we’ll be able to accomplish in the 3 weeks and make sure we are ready to coordinate on any tasks that need coordination.</p><h4>Planning And Performing Maintenance</h4><p>When we have major maintenance that needs to be done we work closely together. We make sure to plan and document as much as we can up-front. This “game plan” will give us the steps that we’ll need to follow when performing the real maintenance.</p><p>A full run-through of this game plan will first happen against a test environment that closely matches production (remember how Terraform gives us the ability to re-create our shared infrastructure really easily?).</p><p>When we perform maintenance together, we like to use the <a href="https://en.wikipedia.org/wiki/Pointing_and_calling">pointing and calling method</a> to make sure things go well. This method ensures that each action performed during maintenance — like buttons that are clicked, commands that are executed, etc. — are double-checked and verified by at least one other person in real-time. This just helps to reduce the chances of human error and mistakes.</p><h4>Documenting Our Work</h4><p>We are <a href="https://procedureflow.com/security">SOC 2 certified</a>, which means we document almost everything we work on. This helps satisfy our auditors but also keeps us accountable. It really helps when we don’t remember if we completed a certain task —we just go check the documentation!</p><p>For example, we document seemingly simple things like giving email or application access to a new employee. While it seems mundane and pointless, it records:</p><ul><li>The fact that certain security policies we enacted in a timely manner</li><li>Who performed the work</li><li>Other tasks, issues or merge requests that are relevant</li><li>Other documentation, when needed, can be associated with any body of work we do</li></ul><p>As mentioned already, we use <a href="https://adr.github.io/">Architecture Decision Records</a> to document important architectural decisions. These are stored as markdown files in version control (e.g. Git). These help us to refine and ensure our pre-code decisions make sense. Documenting these important decisions also helps give us context when looking back at “why did we choose to do X that way?”</p><h3>How We Decide What Products And Features To Work On</h3><p>Our company works closely with our customers. We think deeply about any patterns that appear from the needs of customers. For example, we try our best to detect if multiple customer needs are pointing in the same direction and would warrant the same “feature” to solve those problems.</p><p>Because we work in small iterations, we get early feedback from our customers on what works and what doesn’t. All of this is made possible because of our philosophy of product planning and how we are able to work in small chunks. This is made possible by everything you just read above — a simple tech stack (not <em>simplistic </em>though), collaborative teamwork, feature flags, small chunks of work being reviewed, code convention consistency, etc.</p><p>In the end, this is the goal of all the technical “stuff’ that we do — improve the lives and work of our customers!</p><p>We are driven by building things that our customers really need and would truly benefit from. There’s nothing more satisfying for our software engineers than to know that the thing they just shipped to our customers is making our customers excited about using our product!</p><h3>The End</h3><p>We hope this article gave you an accurate and informative look at how we do things at ProcedureFlow. By being flexible and agile in how we work, we are able to ship value to our customers quickly and iterate on our features using their immediate feedback.</p><p>If this sounds like the kind of environment you’d want to be a part of and work that you love to do — <a href="https://procedureflow.com/jobs">we’re hiring!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=873fded2d221" width="1" height="1" alt=""><hr><p><a href="https://medium.com/procedureflow-engineering/how-we-do-software-engineering-at-procedureflow-873fded2d221">How We Do Software Engineering At ProcedureFlow</a> was originally published in <a href="https://medium.com/procedureflow-engineering">ProcedureFlow Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building API Authentication At ProcedureFlow]]></title>
            <link>https://medium.com/procedureflow-engineering/building-api-authentication-at-procedureflow-4d1fe78bb293?source=rss-2b11a8df877b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d1fe78bb293</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[iteration]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[agile]]></category>
            <dc:creator><![CDATA[James Hickey]]></dc:creator>
            <pubDate>Thu, 09 Dec 2021 17:45:43 GMT</pubDate>
            <atom:updated>2021-12-09T18:23:15.683Z</atom:updated>
            <content:encoded><![CDATA[<h3>Securing Your API With Long-Lived Authentication Keys</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VCTMbAPumFQnIiEHfRwa0g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@moneyphotos?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Old Money</a> on <a href="https://unsplash.com/s/photos/key?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>There comes a time in the life of a multi-tenant SAAS company when its larger customers need the automation and power of an API. The multitude of reasons includes scaling user provisioning, integrating with other products, facilitating advanced reporting and more.</p><p>If you’re in this position, one of the most important areas you need to think about carefully is authentication. There are many different factors to consider:</p><ul><li>Is your API responding to server-to-server requests? Or will you need to support other types of clients like web applications, mobile, etc.?</li><li>Do you need long-lived or short-lived tokens?</li><li>What about OAuth? Does that make sense right now?</li><li>Should you jump on the JWT bandwagon?</li><li>How will your customers configure authentication? How does your choice on this affect their user and developer experience?</li></ul><p>At ProcedureFlow, we’ve spent a fair amount of time researching how the best APIs out there have implemented API authentication: <a href="https://stripe.com/en-ca">Stripe</a>, <a href="https://slack.com/">Slack</a>, <a href="https://github.com/">GitHub</a>, <a href="https://www.twilio.com/">Twilio</a> and others. We want to make sure our API is really easy to use, gives superpowers to our customers and is rock-solid secure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t4y2OZzt2osuhaALxkA3Ag.png" /></figure><p>Needless to say, this one area can get overwhelming quickly! To figure out what works best for your company’s needs, you have to start by thinking about the requirements of your API.</p><h3>Minimum Viable API</h3><p>If you’re a startup like us, then you won’t have the time and resources to build a complete API that will integrate with “all the things” immediately. You have to identify what API products make sense as a priority. Then, you can build your foundational API infrastructure, that first API product and iterate based on your customer’s feedback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uocaCTJP9KrsMVUcC9-coQ.png" /><figcaption>Use An Iterative Approach To API Product Development</figcaption></figure><p>For example, we decided to build a <a href="http://www.simplecloud.info/">SCIM API</a> first.</p><p>Authentication is one of the areas where SCIM is flexible — so we can use the mechanism that works best for our custom API and use it for SCIM too 👍.</p><p>Based on our requirements, there were a few smaller decisions we had to make first:</p><ul><li>We’d be focusing on server-to-server APIs for the first few API products so this influences what kind of authentication mechanism makes sense for us.</li><li>We wanted to retain the ability to implement other authentication mechanisms in the future.</li><li><a href="https://blog.postman.com/the-most-important-api-metric-is-time-to-first-call/">TTFC (Time-to-first-call)</a> is considered one of the most important API metrics. Configuring authentication should be as simple as possible for our customers to facilitate a low TTFC.</li><li>How do well-designed APIs like Stripe, Twilio, Slack, Twitter and GitHub do things? What can we learn or implement ourselves?</li></ul><h3>The Big Decision</h3><p>Your overall decision will be based on a balance between valuing ease of use for your customers and enforcing solid security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KfeIoXaJ1K2H_0wPeLS2Bg.png" /></figure><p>At ProcedureFlow, we decided to use a long-lived API key that our customers can generate from within our product. This is similar to how <a href="https://stripe.com/docs/keys">Stripe</a> and <a href="https://developer.twitter.com/en/docs/tutorials/step-by-step-guide-to-making-your-first-request-to-the-twitter-api-v2">Twitter V2</a> do API authentication. We generate both a client_id and a client_secret (more on these later 😉).</p><p>Some of the qualities and behaviors of using a long-lived API key includes:</p><ul><li>API keys can be tied to individual tenants or specific users <a href="https://api.slack.com/authentication/token-types">like Slack does</a>.</li><li>Can be scoped to specific products or features like <a href="https://stripe.com/docs/keys#limit-access">Stripe does</a>, with read-only or read/write access per feature.</li><li>Also inspired by <a href="https://stripe.com/docs/keys#rolling-keys">Stripe’s approach</a>, customers can have a user-friendly UI to generate new keys, revoke them immediately or revoke them with a grace period.</li><li>API secrets should be hidden on the UI, except when first generated. This is mainly inspired by <a href="https://stripe.com/docs/keys#safe-keys">Stripe’s</a> approach and is a best practice. You don’t want those secrets getting leaked!</li></ul><p>Another thing we chose to do is prefix our key values. This makes them easier to identify and makes the type of key/token more explicit. This technique is <a href="https://stripe.com/docs/keys">inspired by Stripe</a> and GitHub who have <a href="https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/">recently switched to this format too</a>.</p><h3>Deep-Dive: Long-lived API Token Authentication</h3><p>Let’s deep-dive into some of the more detailed decisions we had to make and why they might make sense for you too.</p><h4>The Anatomy Of An API Key</h4><p>Services like Stripe, Slack and Twilio use <em>two values</em> for their long-lived API keys. Slack, for example, <a href="https://api.slack.com/authentication/best-practices#slack_apps__client-id-and-secret">calls these the Client Id and Client Secret</a>. <a href="https://stripe.com/docs/keys#obtain-api-keys">Stripe calls them the Publishable and Secret Keys</a>. Other vendors have used other terms like “Access Key” and “Access Key Secret”.</p><p>We have chosen to call ours client_id and client_secret. This helps to set us up for future use-cases around delegated authorization (e.g. OAuth) and is consistent with the standard OAuth naming terminology. Also, each token can be used by a specific client — web, mobile, server, etc. so client_id seems more semantically accurate to us than other options like app_id , access_key or public_key.</p><h4>Public Identifier</h4><p>The client_id is used to identify the user or owner of the API key.</p><p>This is helpful when you may have multiple types of clients that use your API keys — web applications, mobile applications, back-end systems, etc. It also helps when tokens can be assigned to specific users in your system. You can use the client_id to peg rate limits per client, logging metrics that are tied to the identifier, etc.</p><h4>Secret Token</h4><p>The client_secret is a random cryptographically generated token.</p><p>When thinking about the technical aspects of implementing API key authentication, one of the most important issues to make sure you consider is that <em>API secrets are </em><a href="https://aws.amazon.com/blogs/security/wheres-my-secret-access-key/"><em>just like passwords</em></a>.</p><p>It is inappropriate to store these tokens as plain-text for the same reasons you wouldn’t store passwords as plain-text. Even worse, API secrets are present for every HTTP request, so you want to make sure to protect them well.</p><p>Like passwords, API secrets ought to be hashed when stored in a database or some other tool like a cache. If an attacker ever managed to get access to your database, then they could start impersonating your customers by using plain-text API secrets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nnIRFOn28iT0zBhubuMrFg.png" /></figure><h4>Other Security Considerations</h4><p>One of the reasons you may not want to only use a “secret” value, even if hashed, is that it becomes both the secret and the lookup value.</p><p>When an API request comes into your system, and if all you have is the secret value, then you would have to hash the secret and check if it exists in your database. If it does exist, then you know who owns the API key and therefore who’s allowed to perform the API request.</p><p>Your SQL query would look similar to the following:</p><pre>select * from api_auth_keys where secret_hash = $secret_hash</pre><p>One potential problem with this approach is that it <a href="https://blog.ircmaxell.com/2014/11/its-all-about-time.html">could be susceptible to timing attacks</a>. While in practice there are multiple ways to mitigate these kinds of security vulnerabilities, the issue simply disappears if you use a different value as the identifier for the lookup — assuming you compare the hashes in memory by using a safe constant time comparison function.</p><h4>Bearer Token</h4><p>At the moment, we are only using API keys for server-to-server communication. This means our customer’s servers will need to communicate directly with our API as opposed to via some delegated third-party system (which would require something like OAuth).</p><p>Because of this, we can combine both the client_id and client_secret and display that to our users as one value. This helps with ease of use and user experience, yet allows us to still gain the benefits of using a <a href="https://paragonie.com/blog/2017/02/split-tokens-token-based-authentication-protocols-without-side-channels">split token approach.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7dvOr-qU3lwC9z3Z69lDZA.png" /><figcaption>Bearer Token Using A Split Token</figcaption></figure><h4>Best Hashing Algorithm?</h4><p>PBKDF2 is one of the most popular and reliable hashing algorithms today. It’s a great algorithm for password hashing because it’s slow and cryptographically sound. You don’t want attackers to brute-force guess passwords quickly, so PBKFD2 makes that process much slower and therefore harder to attack.</p><p>That’s great — but one of the hallmarks of any high-quality API is having a short response time. This affects developer experience, can cause more load on servers (which means paying money for more servers), can affect contractual issues due to not meeting certain SLAs and can affect the overall perception of your products and company.</p><p><em>Is PBKFD2 the best option then?</em></p><p>SHA256 is another common hashing algorithm that is solid — but it’s quick to compute hashes. But, is there a way to use SHA256 so that hashes are still computed quickly but have high entropy so that attackers can’t brute force API tokens within a reasonable amount of time?</p><p>Two core problems with user-supplied passwords are that they are generally<em> short and predictable</em>. So, what you need are API tokens that are long and random!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y-W36VNxieE2JXr8ICQ8vw.png" /></figure><p>This is what we did — we opted to generate very long random values for our client_secret — and we hash this using SHA256.</p><p>The code for this might look like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b51254f1ba141d3685ed4134df65a27d/href">https://medium.com/media/b51254f1ba141d3685ed4134df65a27d/href</a></iframe><h4>Storing API Tokens</h4><p>You already know that you should store the hash of an API secret. However, you might also want to store the last few digits of your API secret.</p><p><a href="https://stripe.com/docs/keys#safe-keys">Like Stripe</a>, you should only show the raw API secret immediately after it is created. From that point forward, show the last few digits of the token on the UI. This helps customers identify which key they want to revoke, change scopes for, etc.</p><p>We opted to follow suit with Stripe and keep 4 digits from our non-hashed API secrets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OLZAyagl1EPQ9jV3jrb19w.png" /><figcaption>Mock API Key Schema</figcaption></figure><p>The client_id column would also benefit from using an index so that your database lookups performed during incoming API request authentication are fast 🚀.</p><h4>API Token Pipeline</h4><p>Whatever technology stack you are using, you’ll want to verify any incoming API tokens early in the lifetime of an HTTP request.</p><p>While .NET can sometimes get a bad rap, we use it for reasons like being one of the <a href="https://octoverse.github.com/static/github-octoverse-2020-security-report.pdf">most secure web development platforms out there</a>, having most of the basic tools you’ll need for web development out of the box and having a robust type system. We might write more on that topic another time 😅.</p><p>.NET’s MVC framework has a flexible middleware system that’s easy to hook into. We use the built-in middleware (a.k.a. “filters”) to process API tokens early in the HTTP pipeline.</p><p>Here’s the flow of how we process bearer tokens when authenticating against our API:</p><ol><li>A client issues an HTTP request with an API token as a bearer token.</li><li>We intercept the bearer token early in the HTTP pipeline.</li><li>We split the token into client_id and client_secret.</li><li>Using client_id we check if a row exists in the database.</li><li>We hash the user input client_secret and use a constant-time comparison function to verify that it matches the stored hash.</li><li>We create a “session” object that only exists in memory for the lifetime of the HTTP request.</li><li>Other events occur downstream that use the API key—like rate limiting.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EvR8uOWjRjRKhLzCqMKikg.png" /><figcaption>API authentication process</figcaption></figure><p>The core of our API authentication middleware looks roughly like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9bb30e81d038fdfcb120384f8040201/href">https://medium.com/media/c9bb30e81d038fdfcb120384f8040201/href</a></iframe><h3>Conclusion</h3><p>There’s much more you’ll have to consider when implementing API authentication and API tokens in particular:</p><ul><li>Resource/feature scopes</li><li>UI elements</li><li>Logging</li><li>Tracking token usage for troubleshooting</li><li>Database indexing</li><li>Rate limiting</li><li>Etc.</li></ul><p>For example, we had to extend our existing Redis-based rate-limiting to support limiting based on API keys. Originally, limit data was not being made available to the caller. We had to modify our LUA scripts to return rate limit data and then assign values to the appropriate HTTP headers.</p><p>We do our best at working fast and smart so that we can deliver value to our customers quickly. But we also care about the details, especially when decisions we make now can have an impact on the future of our products. For example, choosing to prefix our API tokens may seem insignificant at face value, but it affects user experience, the overall security of our API, and is not trivial to change in the future.</p><p>If you like solving problems like the ones we’ve discussed and you’re interested in the possibility of joining our team then check out our <a href="https://procedureflow.com/jobs">open positions!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d1fe78bb293" width="1" height="1" alt=""><hr><p><a href="https://medium.com/procedureflow-engineering/building-api-authentication-at-procedureflow-4d1fe78bb293">Building API Authentication At ProcedureFlow</a> was originally published in <a href="https://medium.com/procedureflow-engineering">ProcedureFlow Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>