<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Zack Allen</title>
    <description>The latest articles on Forem by Zack Allen (@teachmetechy).</description>
    <link>https://forem.com/teachmetechy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F771044%2Fd80a17cd-d4cb-45fd-b146-8b0ff27cdc67.jpg</url>
      <title>Forem: Zack Allen</title>
      <link>https://forem.com/teachmetechy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/teachmetechy"/>
    <language>en</language>
    <item>
      <title>Absolute measurement corrupts alert severity, absolutely</title>
      <dc:creator>Zack Allen</dc:creator>
      <pubDate>Fri, 18 Nov 2022 12:50:58 +0000</pubDate>
      <link>https://forem.com/teachmetechy/absolute-measurement-corrupts-alert-severity-absolutely-go1</link>
      <guid>https://forem.com/teachmetechy/absolute-measurement-corrupts-alert-severity-absolutely-go1</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hgNRV_KP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/romfiot4dnf1s89r1qal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hgNRV_KP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/romfiot4dnf1s89r1qal.png" alt="Image description" width="880" height="780"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I sometimes get so excited about an alert or a finding, then immediately feel a sense of dread because of this comic. Is this a bun? Who else cares besides me?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Tell me if you’ve been in this situation before: you are working as a (SOC Analyst, Detection Engineer, Security Researcher), and just created a new rule for your SIEM. It took blood, sweat, and tears to get it exactly how you wanted it. It has lots of unit tests, links to articles, and blogs that document the TTP you are trying to capture, and it is a high visibility rule because management asked for it. Now comes the dreaded question: what should the severity of the rule be, and how can you logically explain &lt;em&gt;why&lt;/em&gt; it is set to a certain level?&lt;/p&gt;

&lt;p&gt;You sit back and think. You’re a professional. A logical, creative and driven individual. “Well, management asked for it”, you say to yourself, “..especially after they read about that breach that this rule helps prevent, so I can’t just mark it an insignificant info or low. They’d question my judgment”! Alright, so it’s gotta be higher than low. That leaves medium, high, and critical. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AIUwuPpb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.kym-cdn.com/photos/images/newsfeed/001/179/536/c7f.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AIUwuPpb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.kym-cdn.com/photos/images/newsfeed/001/179/536/c7f.gif" alt="Image description" width="200" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You pull up your organization’s Risk Severity Matrix document. In it, you sift through all kinds of mathematical equations to give you direction. The goal here is to apply rigor to your decision because without math, you’d just be making this up anyways. &lt;/p&gt;

&lt;p&gt;The document is several matrices lined up with different colors and selection parameters: likelihood of occurrence, impact if successful, countermeasures in place to mitigate damage, should someone be woken up for this. It starts to feel like you are reading a different language. How the hell are YOU responsible for computing this?&lt;/p&gt;

&lt;p&gt;After 30 mins, your brain starts to melt, and you let out a big sigh. “Screw it,” you say, “critical. Management wants it, my team wants it, it just seems important”. You deploy to production, pat yourself on the back and move on. &lt;/p&gt;

&lt;h2&gt;
  
  
  What’s the problem here?
&lt;/h2&gt;

&lt;p&gt;I’ve been in this exact scenario a myriad of times in my career. You need to label an alert within a rule with a severity that you hope is accurate enough. You want an adequate severity because it would really suck to mess somebody’s night up because they get paged, and the alert is a nothing burger. Or worse - the alert triggered, but the severity wasn’t set high enough, so you did not wake that person up, and now the company is burned. So what gives? How did we get here? Why do we have so much power?&lt;/p&gt;

&lt;p&gt;There are a lot of ways to measure the severity of a potential security alert. And I think we’ve taken it a bit far with the best ways to do it. The security industry latched onto this concept of being on-call because the bad guys never sleep, so why should we? So after we made THAT decision, we now need some logic behind what constitutes an alert that’s interesting from an alert that makes you go, “Oh, Shit.”&lt;/p&gt;

&lt;p&gt;Here’s the problem. Brilliant people are in security. And because we have so many brilliant people, we came up with clever ways to find bad things. And once we found those bad things, we let our lizard brains take us the next step further and say, “well, the only way to explain how bad this evil thing is, is to make something equally brilliant to quantify its severity.” &lt;/p&gt;

&lt;p&gt;Look - I am not going to name and shame severity models. The only question I am asking - does this explain enough to my boss or my organization why someone should be interrupted, paged, or woken up? How does this help my alert explainability?&lt;/p&gt;

&lt;h2&gt;
  
  
  Alert severity explainability
&lt;/h2&gt;

&lt;p&gt;I joined Mastodon after the crazy Twitter exodus and started thinking about ways I could write about this subject. I also had COVID. And so what do you do when you are bored, isolated, and have COVID? You start &lt;del&gt;tweeting&lt;/del&gt; tooting your boss, the CISO!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nVWPtY5I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e8u2ys8m3294sm5wvfhm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nVWPtY5I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e8u2ys8m3294sm5wvfhm.png" alt="Image description" width="583" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---6M58cBl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ry9mtsix936hzniz864b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---6M58cBl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ry9mtsix936hzniz864b.png" alt="Image description" width="583" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vm-put1S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vvcl8hsjaqepd85j48n0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vm-put1S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vvcl8hsjaqepd85j48n0.png" alt="Image description" width="580" height="152"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;I had a performance management review scheduled with Emilio the week after this toot, so I thought tagging him in this investigation would get me into his good graces 😇😇&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After more and more Googling, I realized I should be careful, there has been a lot of smart people working on this problem.  Instead, I realized the issue: everything I investigated focused on &lt;em&gt;Absolute Measurement&lt;/em&gt;. A series of inputs are sent into an alert, and the output should be some severity on a scale from informational -&amp;gt; critical. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Severity = Probability of occurrence * Threat Actor Jerk Coefficient * (Compensating Control - Cups of Coffee) - abs(Last time I took a vacation - Burnout)&lt;/code&gt;&lt;br&gt;
&lt;em&gt;Not all threat actors are jerks, but many jerks are threat actors&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Aha! Mathematics saves the day yet again! But here is the problem: humans are generally bad at absolute measurement. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.simula.no/sites/default/files/publications/Simula.SE.299.pdf"&gt;Exhibit A&lt;/a&gt; is a study about how different outsourcing companies could give an absolute estimate of hours of work provided a set of specifications. It turns out they were all over the place. Culture, bias, expertise, and specification details (or lack thereof) all played a role in how firms decided the cost of doing a project. So what can we do instead?&lt;/p&gt;

&lt;h2&gt;
  
  
  Security has to learn yet again from Dev and Ops: relative measurements to the rescue!
&lt;/h2&gt;

&lt;p&gt;Estimating work for software is difficult. But developers and operations folks figured this out long ago with a little thing called Agile Development. Rather than being all waterfall-y, you can get a couple of sprints under your belt and compare feature requests and bug reports with work you’ve already done!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"So I believe that a button on our website is a 2-point story because I worked on a slider for our website 2 sprints ago, and that was a 2-pointer, and the code is relatively the same.” - An unknown enlightened developer, Initech, 1998&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Bingo! Relative measurement. Humans rock.&lt;/p&gt;

&lt;p&gt;So how does this apply to alert severity? Well, we should embrace what we’ve done before. What does this specific rule look like compared to our library of rules? Similar TTPs, similar environment? Does it alert on a very specific case, or a broad case? These may seem like absolute measurements, but you'd be surprised how good humans are at taking very vague details like above and clustering them to other similar rules.&lt;/p&gt;

&lt;p&gt;Once you can cluster that, it is easy to assign the severity because it’s just the same severity as the rules it was clustered in. And yeah, finger to the wind is totally fine here! No more math, make a justification of why your PHP Webshell rule is a Medium that seems awfully similar to an ASP.NET Webshell rule, and bam! Deploy away. &lt;/p&gt;

&lt;h2&gt;
  
  
  Alert severity can be alert urgency. Different name, similar outcomes
&lt;/h2&gt;

&lt;p&gt;What does it mean for day-to-day operations to have an informational, low, medium, high, and critical alert now that you can cluster? Well, this is where documentation and an SLA come into play. I’m pretty bullish on treating security as a ship in the ocean rather than an immovable fortress. You have to keep the ship afloat. So how would you classify problems within the ship, with increasing levels of severity, that go from something to note, to something interesting, to something catastrophic?&lt;/p&gt;

&lt;p&gt;Sailing analogies aside, I am impressed with how the DevOps profession solved this issue years ago. My employer has a &lt;a href="https://www.datadoghq.com/blog/monitoring-101-alerting/"&gt;great blog&lt;/a&gt; on Alert Urgency (not severity!) and classifies alerts as Records, Notifications and Pages. &lt;a href="https://www.atlassian.com/incident-management/kpis/severity-levels"&gt;Atlassian&lt;/a&gt; has a 5 tier model that talks about service degradation and customer annoyance. Notice these all can fit into one page and can be quickly adapted. &lt;/p&gt;

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

&lt;p&gt;TL;DR focus on relative measurement. There will be some upfront costs and pain, but it gets easier as time goes on. That pain is the same thing Agile teams go through with assigning points, but it quickly fades. Next, identify your severity model from a notification perspective rather than a threat perspective. You might realize they achieve the same thing, but without as much absolute measurement in trying to quantify threat scores. &lt;/p&gt;

</description>
      <category>security</category>
      <category>detectionengineering</category>
      <category>threatdetection</category>
    </item>
    <item>
      <title>Table stakes for Detection Engineering</title>
      <dc:creator>Zack Allen</dc:creator>
      <pubDate>Fri, 18 Nov 2022 01:38:32 +0000</pubDate>
      <link>https://forem.com/teachmetechy/table-stakes-for-detection-engineering-2ekh</link>
      <guid>https://forem.com/teachmetechy/table-stakes-for-detection-engineering-2ekh</guid>
      <description>&lt;h2&gt;
  
  
  What is a rule, really?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwd6y0egrd7b3x9af5ycc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwd6y0egrd7b3x9af5ycc.png" alt="Alucard from SoTN makes fun of rules" width="512" height="416"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Alucard will not be sold any snake oil&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For as long as I have been in the security industry, there has been a concerted effort to sort through massive troves of data with powerful and mysterious tools called “rules”. It allows us mere mortals to take a million line logfile and separate each line into two buckets: interesting or not interesting, malicious or not malicious, vulnerable or not vulnerable. If you know what “bad” or “vulnerable” is, then you can codify it and let the computer do the sorting for you. &lt;/p&gt;

&lt;p&gt;I cut my teeth in security research writing WAF rules for modsecurity and looking for interesting HTTP-based attacks on behalf of a customer base. I also launched the security detection and research team at startups that are now public. At my current gig, I help my organization write detection content against 100s of data sources with terabytes of cloud-based control-plane and data-plane events flowing through our systems. Seeing how detection and research have evolved in my 10+ year career has been rewarding and tiring. &lt;/p&gt;

&lt;p&gt;The security elders at my previous companies would scoff at my WAF rules and talk to me about a time when vulnerability scanner rules were the only thing that mattered. A team of researchers would feverishly comb through binaries and RE tools like the Matrix, and when they would find a vulnerability, they would rush out a rule so &lt;em&gt;their&lt;/em&gt; company would be the first to disclose it and have a detection before their competitors. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7rz0qtfpiyv9gpqeajv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7rz0qtfpiyv9gpqeajv.png" alt="A security researcher from McAfee deploys a new rule to their vulnerability scanner (2003, colorized)" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A security researcher from McAfee deploys a new rule to their vulnerability scanner (2003, colorized)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;At the end of the day, this fell in the realm of "security research". Companies would scoop up new grads and oldheads alike, put them on a security research team, and put them to work. They would then measure how many rules and detections they could push into production in a month, and hopefully it was enough to claim that their products protected customers from &lt;em&gt;more&lt;/em&gt; attacks and vulnerabilities than their competitors. &lt;/p&gt;

&lt;p&gt;This go-to-market strategy can be effective but suffers diminishing returns. It begs the question: why is "more" better, and why is "lots more", lots better? In the age of vulnerability scanners, more rules meant more vulnerabilities being detected. This translates into having better coverage, which is a great sales statistic. The same pervasiveness of coverage crept into threat detection products, but threats are not equal to vulnerabilities. Sure, you want to have coverage against an overwhelming number of threats, but is that going to help protect you and your firm? Can you do “all” threats, forever? More than a competitor, more than a threat actor? Probably not.&lt;/p&gt;

&lt;p&gt;This culture of more is better has caused burnout and pain for researchers at these companies. It doesn't matter if you wrote an exceptional rule that was relevant, contextual, and precise: it carried the same weight as another bad rule with bad results within the game of quotas. When detection counts go up, the sales engine gets revved up, and they rush to their pipelines to close more deals. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4yl63thktgcrk3gyw4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4yl63thktgcrk3gyw4a.png" alt="Detorction rules are like stonks, they can only go up" width="666" height="499"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Detorction rules are like stonks, they can only go up&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Threat detection is dead. Long live threat detection!
&lt;/h2&gt;

&lt;p&gt;The security research team in these times (maybe not as much now, but I have recency bias) was treated like wizards. They were the identity of the company. They had cringe-inducing named research teams, such as the IBM Hacker Ninjas or the McAfee Alpha Bro Exploiter Extraordinaires. The wizards would come down from their spire and preach to the world their latest findings, present at Blackhat and DEFCON, then afterward head back up the spire and close the door behind them. Their rules, research, and detections would then be left for other people to deal with. They had bigger things to worry about, like writing more rules to hit that damn quota.&lt;/p&gt;

&lt;p&gt;In my opinion, this concept of "more is better" for detection rules is a sign that a company's go-to market is either a) stuck in the past of vulnerability research coverage or b) don't know what they are doing so they just do as much as possible to hide that fact. Believe me, I was part of this a few times in my career. &lt;/p&gt;

&lt;p&gt;Now, I am not saying that you shouldn’t crank rules out for the sake of coverage. There are legitimate reasons to write, deploy and maintain a vast ruleset. What I am saying is that I think we got into this mess because we still continue to focus too much on deploying as much as possible, rather than thinking about the problems we are trying to solve. And the more I get into my career, the more I realize that I can’t blame sales or marketing people for this problem, this is the security research team’s fault.&lt;/p&gt;

&lt;p&gt;When a company relies heavily on a research team to pump out content, they need to make sure that the team has the right people supporting them so they can focus on the nuances of security detection. Company’s should provide access to project management resources, software engineering capabilities to scale rule writing efforts and infrastructure, and consider the impact of rules using tried and tested methods in everyone’s favorite high school class: statistics. And no, I am not saying machine learning. &lt;/p&gt;

&lt;p&gt;I think the industry is starting to see that security detection and research, for the sole purpose of writing threat detection rules, is evolving into a new and exciting type of security engineer: the Detection Engineer!&lt;/p&gt;

&lt;h2&gt;
  
  
  Detection Engineering is the new hotness but requires solid foundations in more than just security subject matter expertise
&lt;/h2&gt;

&lt;p&gt;Detection Engineering, in my opinion, is the next level of security research. It's an evolution because companies have realized that it's more scalable to require security researchers to have skills in software engineering, project management, and statistics before they are released to go work through a detection backlog. If you want to scale your detection program, you need to hire a Detection Engineering team that can complement each other in the following areas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Subject matter expertise in security&lt;/li&gt;
&lt;li&gt;Software engineering&lt;/li&gt;
&lt;li&gt;Statistics&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's it. That's all you need. Of course, this list can be picked apart, stretched, and folded under other areas like DevOps or Infrastructure,  but at the end of the day, these 3 pillars can get you far without having to hire a ton of bodies. &lt;/p&gt;

&lt;p&gt;You can't write detections for your network security product if you don't have network security experts. This is the same for endpoint, cloud, application and host-based detections. It’s like having a bunch of data scientists build a machine learning model to detect asthma in patients but they forgot to bring in a doctor to show them how pneumonia patients would give the model false positives. You need the subject matter experts. This has not changed in the industry, nor should it. &lt;/p&gt;

&lt;p&gt;What has changed is that these experts need a solid basis in software engineering principles. You can't scale all of those detections and deploy them in a modern environment, manage sprints (yes this is software engineering :)), or write unit, integration, and regression tests without lots of bodies or lots of automation. I can reliably say my boss would rather hear that I can scale the problem away with software than with hiring more people. &lt;/p&gt;

&lt;p&gt;Lastly, and I think this is the next step in the evolution of security research to detection engineering: we all must improve the explainability, and thus impact, of our rules, and statistics is how you do it. You can't reliably create, improve, deprecate or justify your detections to your sales teams, internal leadership, or customers without a background in statistics. This does not mean you need a graduate degree, but I think if security engineers and researchers spent some time looking at concepts like sampling bias and error, confusion matrices, precision and recall, they could better understand how rules perform under certain conditions and spot errors much earlier on before a rule hits production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frs55o1tzx6m3v806bqs1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frs55o1tzx6m3v806bqs1.png" alt="XKCD" width="459" height="185"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The more you learn, the more you realize you don't know anything&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;I am excited to see these 3 pillars being talked about more in the detection engineering and security realm. It shows how much we've matured as an industry. I wrote this post as a rant but also as a warning: do not do what I did. Do not fall victim to the "more is better" farce. I have a few more post ideas going into detail on what separates a good detection from a great detection (my team asks this question all the time), or what a go-to-market strategy for security detection rules should be (it's covering the right things, not more things). But for now, my parting advice for aspiring researchers and engineers is this Einstein quote:&lt;/p&gt;

&lt;p&gt;"If I had only one hour to save the world, I would spend fifty-five minutes defining the problem, and only five minutes finding the solution." &lt;/p&gt;

&lt;p&gt;Also, turns out, Einstein may not have said this, but the premise is still great. We write solutions (detections) trying to find problems (threats) without focusing on the problem (threat) beforehand. Don't do what I did. Don't commit to a quota!&lt;/p&gt;

</description>
      <category>docker</category>
    </item>
    <item>
      <title>Table stakes for Detection Engineering</title>
      <dc:creator>Zack Allen</dc:creator>
      <pubDate>Tue, 18 Oct 2022 00:56:41 +0000</pubDate>
      <link>https://forem.com/teachmetechy/table-stakes-for-detection-engineering-1h68</link>
      <guid>https://forem.com/teachmetechy/table-stakes-for-detection-engineering-1h68</guid>
      <description>&lt;h2&gt;
  
  
  What is a rule, really?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwd6y0egrd7b3x9af5ycc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwd6y0egrd7b3x9af5ycc.png" alt="Dracula from SoTN makes fun of rules"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Dracula refuses a call with a security vendor&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For as long as I have been in the security industry, there has been a concerted effort to sort through massive troves of data with powerful and mysterious tools called “rules”. It allows us mere mortals to take a million line logfile and separate each line into two buckets: interesting or not interesting, malicious or not malicious, vulnerable or not vulnerable. If you know what “bad” or “vulnerable” is, then you can codify it and let the computer do the sorting for you. &lt;/p&gt;

&lt;p&gt;I cut my teeth in security research writing WAF rules for modsecurity and looking for interesting HTTP-based attacks on behalf of a customer base. I also launched the security detection and research team at startups that are now public. At my current gig, I help my organization write detection content against 100s of data sources with terabytes of cloud-based control-plane and data-plane events flowing through our systems. Seeing how detection and research have evolved in my 10+ year career has been rewarding and tiring. &lt;/p&gt;

&lt;p&gt;The security elders at my previous companies would scoff at my WAF rules. They would talk to me about a time when vulnerability scanner rules were the only thing that mattered. A team of researchers would feverishly comb through binaries and RE tools like the Matrix. When they would find a vulnerability, they would rush out a rule so their company would be the first to disclose it and have a detection before their competitors. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7rz0qtfpiyv9gpqeajv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7rz0qtfpiyv9gpqeajv.png" alt="A security researcher from McAfee deploys a new rule to their vulnerability scanner (2003, colorized)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A security researcher from McAfee deploys a new rule to their vulnerability scanner (2003, colorized)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;At the end of the day, this fell into the realm of "security research". Companies would scoop up new grads and old heads alike, put them on a security research team, and put them to work. They would then measure how many rules and detections they could push into production in a month. Hopefully, it was enough to claim that their products protected customers from more attacks and vulnerabilities than their competitors. &lt;/p&gt;

&lt;p&gt;This go-to-market strategy can be effective but suffers diminishing returns. It begs the question: why is "more" better, and why is "lots more", lots better? In the age of vulnerability scanners, more rules meant more vulnerabilities being detected. This translates to better coverage, which is a great sales statistic. The same pervasiveness of coverage crept into threat detection products, but threats are not equal to vulnerabilities. Sure, you want to have coverage against an overwhelming number of threats, but is that going to help protect you and your firm? Can you do “all” threats, forever? More than a competitor, more than a threat actor? Probably not.&lt;/p&gt;

&lt;p&gt;This culture of more is better has caused burnout and pain for researchers at these companies. It doesn't matter if you wrote an exceptional rule that was relevant, contextual, and precise: it carried the same weight as another bad rule with bad results within the game of quotas. When detection counts are up, the sales engine gets revved up, and they rush to their pipelines to close more deals. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4yl63thktgcrk3gyw4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4yl63thktgcrk3gyw4a.png" alt="Detorction rules are like stonks, they can only go up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Detorction rules are like stonks, they can only go up&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Threat detection is dead. Long live threat detection!
&lt;/h2&gt;

&lt;p&gt;The security research team in these times (maybe not as much now, but I have recency bias) was treated like wizards. They were the identity of the company. They had cringe-inducing named research teams, such as the IBM Hacker Ninjas or the McAfee Alpha Bro Exploiter Extraordinaires. The wizards would come down from their spire and preach to the world their latest findings, present at Blackhat and DEFCON. Afterwards, they would head back up the spire and close the door behind them. Their rules, research, and detections would then be left for other people to deal with. They had bigger things to worry about, like writing more rules to hit that damn quota.&lt;/p&gt;

&lt;p&gt;In my opinion, this concept of "more is better" for detection rules is a sign that a company's go-to market is either a) stuck in the past of vulnerability research coverage or b) doesn't know what they are doing so they just do as much as possible to hide that fact. Believe me, I was part of this a few times in my career. &lt;/p&gt;

&lt;p&gt;Now, I am not saying that you shouldn’t crank them out for the sake of coverage. There are legitimate reasons to write, deploy and maintain a vast ruleset. What I am saying is that I think we got into this mess because we think more coverage is more secure. This fallacy can lead internal teams, or in my case a product detection team, down rabbit holes that aren't fruitful in the longrun. And the more I get into my career, the more I realize that I can’t solely blame sales or marketing people for this strategy. It's up to us, the researchers, to let them know which path is the more fruitful and why.&lt;/p&gt;

&lt;p&gt;When a company relies heavily on a research team to pump out content, they need to make sure that the team has the right people supporting them. This will enable the team to focus on the nuances of security detection. Companies should provide access to project management resources, software engineering capabilities to scale rule writing efforts and infrastructure, and consider the impact of rules using tried and tested methods in everyone’s favorite high school class: statistics. &lt;/p&gt;

&lt;p&gt;I think the industry is starting to see that security detection and research, for the sole purpose of writing threat detection rules, is evolving into a more advanced and exciting type of security engineer: the Detection Engineer!&lt;/p&gt;

&lt;h2&gt;
  
  
  Detection Engineering is the new hotness but requires solid foundations in more than just security subject matter expertise
&lt;/h2&gt;

&lt;p&gt;Detection Engineering, in my opinion, is the next level of security research. It's an evolution because companies have realized that it's more scalable to require security researchers to have skills in software engineering, project management, and statistics. If you want to scale your detection program, you need to hire a Detection Engineering team that can complement each other in the following areas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Subject matter expertise in security&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Software engineering&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Statistics&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's it. That's all you need. Of course, this list can be picked apart, stretched, and folded under other areas like DevOps or Infrastructure. However, at the end of the day, these 3 pillars can get you far without having to hire a ton of bodies. &lt;/p&gt;

&lt;p&gt;You can't write detections for your network security product if you don't have network security experts. This is the same for endpoint, cloud, application and host-based detections. It’s like having a bunch of data scientists build a machine learning model to detect asthma in patients. However, they forgot to bring in a doctor to show them how pneumonia patients would give the model false positives. You need the subject matter experts. This has not changed in the industry, nor should it. &lt;/p&gt;

&lt;p&gt;What has changed is that these experts need a solid basis in software engineering principles. You can't scale all of those detections and deploy them in a modern environment, manage sprints (yes this is software engineering :)), or write unit, integration, and regression tests without lots of bodies or lots of automation. I can reliably say my boss would rather hear that I can scale the problem away with software than with hiring more people. &lt;/p&gt;

&lt;p&gt;Lastly, and I think this is the next step in the evolution of security research to detection engineering: we all must improve the explainability, and thus impact, of our rules, and statistics is how you do it. You can't reliably create, improve, deprecate or justify your detections to your sales teams, internal leadership, or customers without a background in statistics. This does not mean you need a graduate degree, but I think if security engineers and researchers spent some time looking at concepts like sampling bias and error, confusion matrices, precision and recall, they could better understand how rules perform under certain conditions and spot errors much earlier on before a rule hits production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frs55o1tzx6m3v806bqs1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frs55o1tzx6m3v806bqs1.png" alt="XKCD"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The more you learn, the more you realize you don't know anything&lt;/p&gt;

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

&lt;p&gt;I am excited to see these 3 pillars being talked about more in the detection engineering and security realm. It shows how much we've matured as an industry. I wrote this post as a rant but also as a warning: do not do what I did. Do not fall victim to the "more is better" farce. I have a few more post ideas going into detail on what separates a good detection from a great detection (my team asks this question all the time), or what a go-to-market strategy for security detection rules should be (it's covering the right things, not more things). But for now, my parting advice for aspiring researchers and engineers is this Einstein quote:&lt;/p&gt;

&lt;p&gt;"If I had only one hour to save the world, I would spend fifty-five minutes defining the problem, and only five minutes finding the solution." &lt;/p&gt;

&lt;p&gt;Also, turns out, Einstein may not have said this, but the premise is still great. We write solutions (detections) trying to find problems (threats) without focusing on the problem (threat) beforehand. Don't do what I did. Don't commit to a quota!&lt;/p&gt;

</description>
      <category>security</category>
      <category>detectionengineering</category>
      <category>threatdetection</category>
    </item>
    <item>
      <title>Deploying Django Rest Framework with Postgres on fly.io</title>
      <dc:creator>Zack Allen</dc:creator>
      <pubDate>Thu, 30 Dec 2021 22:45:18 +0000</pubDate>
      <link>https://forem.com/teachmetechy/django-rest-framework-on-flyio-582p</link>
      <guid>https://forem.com/teachmetechy/django-rest-framework-on-flyio-582p</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;In this post, I will be demonstrating how to deploy a &lt;a href="https://www.django-rest-framework.org/" rel="noopener noreferrer"&gt;Django Rest Framework&lt;/a&gt; (DRF) application on &lt;a href="https://fly.io" rel="noopener noreferrer"&gt;fly.io&lt;/a&gt;. DRF is built on top of Django and is my choice when it comes to building small to massive APIs. I have used it extensively professionally and personally, and as a cybersecurity researcher, it's been my favorite to build as a backend for some complex applications that track malicious actors and their infrastructure. I noticed the fly website did not have a Django example, so I wanted to provide the community with a template to get started to avoid the headaches that I endured building this :) &lt;/p&gt;

&lt;p&gt;You should have an understanding of Docker, docker compose, DRF and postgres for this post. Although it's possible to use this template without too much knowledge of these concepts, you'd get a ton of knowledge going through the following tutorials:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.django-rest-framework.org/tutorial/quickstart/" rel="noopener noreferrer"&gt;https://www.django-rest-framework.org/tutorial/quickstart/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/samples/django/" rel="noopener noreferrer"&gt;https://docs.docker.com/samples/django/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://fly.io/docs/getting-started/python/" rel="noopener noreferrer"&gt;https://fly.io/docs/getting-started/python/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why DRF?
&lt;/h3&gt;

&lt;p&gt;From the DRF website:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Some reasons you might want to use REST framework:

-  The Web browsable API is a huge usability win for your developers.
-  Authentication policies including packages for OAuth1a and OAuth2.
-  Serialization that supports both ORM and non-ORM data sources.
-  Customizable all the way down - just use regular function-based views if you don't need the more powerful features.
-  Extensive documentation, and great community support.
-  Used and trusted by internationally recognised companies including Mozilla, Red Hat, Heroku, and Eventbrite.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The biggest issue with DRF is that it can be somewhat challenging to get up and running (can be lots of up front work). My experience has been that once you get a good template for an API up, it's the fastest to build, most scalable and most intuitive ORM. &lt;/p&gt;

&lt;h3&gt;
  
  
  Why fly.io?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz8cg503lfumrmni4rfdp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz8cg503lfumrmni4rfdp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've used Heroku for one-off apps for a few years. Fly came across my Twitter feed and I've been following it closely. The company has a great section on why you &lt;a href="https://fly.io/docs/introduction/" rel="noopener noreferrer"&gt;should use fly&lt;/a&gt;, and this section caught my eye and has kept me interested ever since I read it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Despite the benefits of location-smart, time-agile and cloud-clever applications, there’s been no good platform for building applications that work like this. This is what Fly has set out to fix. In the process we want to make application distribution platforms as ubiquitous as CDNs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can think of fly as a Heroku competitor, although some folks might disagree with me. I like it because it does what it says it does well, is focused, and isn't as bloated as the Heroku stack.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Bookkeeping
&lt;/h3&gt;

&lt;p&gt;We'll be making a DRF app, the Silly Simple API, or &lt;code&gt;ss-api&lt;/code&gt; for short, on fly. This will have the following features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Postgres backend, &lt;a href="https://fly.io/docs/reference/postgres/" rel="noopener noreferrer"&gt;courtesy of fly&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;No session authentication, only using Tokens (you can use some tricks from &lt;code&gt;fly&lt;/code&gt; to manage this). This is especially nice for APIs and simplifies authentication to a token, which I prefer for microservices&lt;/li&gt;
&lt;li&gt;Swagger and OpenAPI capabilities using &lt;a href="https://drf-yasg.readthedocs.io/en/stable/" rel="noopener noreferrer"&gt;drf-yasg&lt;/a&gt;, where you can only see endpoints and Swagger docs if you have a valid Token&lt;/li&gt;
&lt;li&gt;TCP &amp;amp; HTTP health checks using fly. The HTTP health check will be somewhat &lt;em&gt;useful&lt;/em&gt; by issuing a query to our DRF app under &lt;code&gt;/ping/&lt;/code&gt;, which connects to the DB and issues an innocuous &lt;code&gt;select 1&lt;/code&gt; statement to make sure things are working&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;docker&lt;/code&gt; with a &lt;code&gt;Dockerfile&lt;/code&gt; and &lt;code&gt;gunicorn&lt;/code&gt; to launch the app. The cool thing about fly is that you can give it a &lt;code&gt;Dockerfile&lt;/code&gt; and a &lt;code&gt;fly.toml&lt;/code&gt; and you have a full-fledged app running on their infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This app will only have 1 endpoint, &lt;code&gt;users&lt;/code&gt;, that you can use to manage your users. You must be authenticated to see it. &lt;/p&gt;

&lt;p&gt;I will leave the following for later blog posts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Metrics exposure and app tracing via Datadog (p.s., we're hiring &lt;a href="https://www.datadoghq.com/careers/" rel="noopener noreferrer"&gt;https://www.datadoghq.com/careers/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Tables for an app (this isn't a tutorial on building DRF apps, rather, to get you a template to get started)&lt;/li&gt;
&lt;li&gt;Scaling primitives in DRF (avoiding n+1, indexing, replicas for postgres)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If this all sounds interesting for you still, let's get started :D &lt;/p&gt;

&lt;h3&gt;
  
  
  Clone and run locally
&lt;/h3&gt;

&lt;p&gt;Make sure to have the following installed locally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Latest Docker (with &lt;code&gt;docker compose&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;fly via &lt;a href="https://fly.io/docs/hands-on/installing/" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;then clone from the &lt;a href="https://github.com/zmallen/ss-api" rel="noopener noreferrer"&gt;repo&lt;/a&gt; here:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone git@github.com:zmallen/ss-api.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;docker compose up&lt;/code&gt; and connect locally by navigating to:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://localhost:8000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F63dih5ixmamlncj88osj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F63dih5ixmamlncj88osj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;docker-compose.yml&lt;/code&gt; file overrides the &lt;code&gt;RUN&lt;/code&gt; command in the &lt;code&gt;Dockerfile&lt;/code&gt; by issuing the following command on every &lt;code&gt;docker compose up&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bash -c "python manage.py migrate &amp;amp;&amp;amp; python manage.py runserver 0.0.0.0:8000"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will differ from when we deploy on fly.io, where we use &lt;code&gt;gunicorn&lt;/code&gt; to serve the app and we run migrations manually.&lt;/p&gt;

&lt;h3&gt;
  
  
  Token Auth &amp;amp; Authentication in DRF
&lt;/h3&gt;

&lt;p&gt;Unauthenticated users can only see the &lt;code&gt;/ping/&lt;/code&gt; endpoint on Swagger. This is by design - the app will render endpoints based on permission, and under &lt;code&gt;/ping/views.py&lt;/code&gt; on Line 16, the permission for this endpoint is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;permission_classes = (AllowAny,)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Compare this to &lt;code&gt;ssapi/views.py&lt;/code&gt;, under the &lt;code&gt;UserViewSet&lt;/code&gt; on Line 17:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;authentication_classes = (authentication.TokenAuthentication,)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is achieved via some magic in &lt;code&gt;settings.py&lt;/code&gt; Lines 88-111:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;DRF&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;settings&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;REST_FRAMEWORK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"DEFAULT_PERMISSION_CLASSES"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"rest_framework.permissions.IsAuthenticated"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"DEFAULT_AUTHENTICATION_CLASSES"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"rest_framework.authentication.TokenAuthentication"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"DEFAULT_RENDERER_CLASSES"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"rest_framework.renderers.JSONRenderer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;SWAGGER_SETTINGS&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;SWAGGER_SETTINGS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"USE_SESSION_AUTH"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"LOGIN_URL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rest_framework:login"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"LOGOUT_URL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rest_framework:logout"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"VALIDATOR_URL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"SECURITY_DEFINITIONS"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"api_key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"apiKey"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"in"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"header"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"REFETCH_SCHEMA_WITH_AUTH"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under &lt;code&gt;DRF_SETTINGS&lt;/code&gt;, I forced &lt;code&gt;TokenAuthentication&lt;/code&gt; and &lt;code&gt;isAuthenticated&lt;/code&gt; for viewing endpoints, so no more sessions! 🎉🎉&lt;/p&gt;

&lt;p&gt;So how do you get an API token if you can't authenticate? This is where some magic with &lt;code&gt;manage.py&lt;/code&gt; comes into play.&lt;/p&gt;

&lt;h3&gt;
  
  
  Authenticating - &lt;code&gt;getdevtoken&lt;/code&gt; and &lt;code&gt;/users/&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;To get a local API key, run the following command in a separate tab, in the same directory as &lt;code&gt;docker-compose.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;└&amp;gt; docker compose run api python manage.py getdevtoken
&lt;span class="o"&gt;[&lt;/span&gt;+] Running 1/0
 ⠿ Container ss-api-db-1  Running                                          0.0s
Looking &lt;span class="k"&gt;for &lt;/span&gt;superuser..
superuser doesn&lt;span class="s1"&gt;'t exist, creating!
superuser created!
Use the following key for dev:
(｡◕‿‿◕｡)☞☞  Token 9884a551be31b80a61b49becf7c3640224a9ec42  ☜☜(｡◕‿‿◕｡)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Note, this Token is for my local deployment :) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Copy the &lt;code&gt;Token abc&lt;/code&gt; and navigate over to your browser, then click 'Authorize', paste and press submit. You should get the &lt;code&gt;/users/&lt;/code&gt; endpoint to return in the Swagger frontend, and issuing a GET request will list the &lt;code&gt;superuser&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rb2p7ojeg0qsl9kd2u5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rb2p7ojeg0qsl9kd2u5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzkrywmdaiklmkbjs0ixm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzkrywmdaiklmkbjs0ixm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can do a lot more with Swagger documentation than just the defaults, I suggest checking out these resources to learn about Swagger docs in Django:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://django-rest-swagger.readthedocs.io/en/stable-0.3.x/examples.html" rel="noopener noreferrer"&gt;https://django-rest-swagger.readthedocs.io/en/stable-0.3.x/examples.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://swagger.io/tools/open-source/" rel="noopener noreferrer"&gt;https://swagger.io/tools/open-source/&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deploying to fly
&lt;/h3&gt;

&lt;p&gt;Everything is running smoothly in your local environment, now let's get it to a prod environment!&lt;/p&gt;

&lt;p&gt;First, we need to create a &lt;code&gt;toml&lt;/code&gt; file for fly. This is a configuration file used by fly to deploy your app. I generated one within the Github repo, but you can explore how to generate and configure other &lt;code&gt;toml&lt;/code&gt; files on fly &lt;a href="https://fly.io/docs/reference/configuration/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A few things need to happen to finish our "deploy to prod" for ss-api:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a fly app&lt;/li&gt;
&lt;li&gt;Create a postgres db with fly, and retrieve the &lt;code&gt;DATABASE_URL&lt;/code&gt; string &lt;/li&gt;
&lt;li&gt;Set a &lt;code&gt;fly secret&lt;/code&gt; with the &lt;code&gt;DATABASE_URL&lt;/code&gt; from Step 1 so our app can dynamically render the secret in a fly environment and use the db created in step 1&lt;/li&gt;
&lt;li&gt;Deploy the app on fly, make sure TCP &amp;amp; HTTP health checks pass (they wont on first pass :D)&lt;/li&gt;
&lt;li&gt;Create a database and run a migration using &lt;code&gt;fly ssh&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Get a &lt;code&gt;devtoken&lt;/code&gt; for prod&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Step 1: Create your fly app
&lt;/h4&gt;

&lt;p&gt;Simply run &lt;code&gt;fly create&lt;/code&gt; and name your app!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;└&amp;gt; fly create
? App Name: ssapiblog
automatically selected personal organization: Zack Allen
New app created: ssapiblog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 2: postgres
&lt;/h4&gt;

&lt;p&gt;Launch a new postgres instance via &lt;code&gt;fly&lt;/code&gt; with &lt;code&gt;fly postgres create&lt;/code&gt;. Accept all the defaults (minimal DB settings, aka the cheapest!) and wait for fly to give you the &lt;code&gt;DATABASE_URL&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;└&amp;gt; fly postgres create
? App Name: ssapidb
Automatically selected personal organization: Zack Allen
? Select region: iad &lt;span class="o"&gt;(&lt;/span&gt;Ashburn, Virginia &lt;span class="o"&gt;(&lt;/span&gt;US&lt;span class="o"&gt;))&lt;/span&gt;
? Select VM size: shared-cpu-1x - 256
? Volume size &lt;span class="o"&gt;(&lt;/span&gt;GB&lt;span class="o"&gt;)&lt;/span&gt;: 10
Creating postgres cluster ssapidb &lt;span class="k"&gt;in &lt;/span&gt;organization personal
Postgres cluster ssapidb created
  Username:    postgres
  Password:   SECRETPASSWORD
  Hostname:    ssapidb.internal
  Proxy Port:  5432
  PG Port: 5433
Save your credentials &lt;span class="k"&gt;in &lt;/span&gt;a secure place, you won&lt;span class="s1"&gt;'t be able to see them again!

Monitoring Deployment
...
...
2 desired, 2 placed, 2 healthy, 0 unhealthy [health checks: 6 total, 6 passing]
--&amp;gt; v0 deployed successfully

Connect to postgres
Any app within the personal organization can connect to postgres using the above credentials and the hostname "ssapidb.internal."
For example: postgres://postgres:SECRETPASSWORD@ssapidb.internal:5432

See the postgres docs for more information on next steps, managing postgres, connecting from outside fly:  https://fly.io/docs/reference/postgres/
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You want the &lt;a href="https://www.12factor.net/backing-services" rel="noopener noreferrer"&gt;12factor&lt;/a&gt; string after &lt;code&gt;For example:&lt;/code&gt;, which in this example is:&lt;br&gt;
&lt;code&gt;postgres://postgres:SECRETPASSWORD@ssapidb.internal:5432&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 3: Set DATABASE_URL as a &lt;code&gt;fly secret&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;You want to set the DATABASE_URL with a 12factor string from before, as well as a database name (which we will create). &lt;/p&gt;

&lt;p&gt;Note the &lt;code&gt;/ssapidb&lt;/code&gt; at the end of the &lt;code&gt;DATABASE_URL&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;fly secrets set DATABASE_URL="postgres://postgres:SECRETPASSWORD@ssapidb.internal:5432/ssapidb"&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 4: Deploy your app
&lt;/h4&gt;

&lt;p&gt;Change the following line in &lt;code&gt;fly.toml&lt;/code&gt; to whatever you want:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="py"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"ssapiblog"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;fly deploy&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;└&amp;gt; fly deploy 
Deploying ssapiblog
&lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; Validating app configuration
&lt;span class="nt"&gt;--&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Validating app configuration &lt;span class="k"&gt;done
&lt;/span&gt;Services
TCP 80/443 ⇢ 8000
&lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; Creating build context
&lt;span class="nt"&gt;--&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Creating build context &lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; Building image with Docker
&lt;span class="nt"&gt;--&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; docker host: 20.10.8 linux x86_64
Sending build context to Docker daemon  153.1kB
...
&lt;span class="o"&gt;==&amp;gt;&lt;/span&gt; A bunch of Docker output

You can detach the terminal anytime without stopping the deployment
Monitoring Deployment

v0 is being deployed
2021-12-30T22:26:21.000 &lt;span class="o"&gt;[&lt;/span&gt;info] 145.40.89.203 - - &lt;span class="o"&gt;[&lt;/span&gt;30/Dec/2021:22:26:21 +0000] &lt;span class="s2"&gt;"GET /ping/ HTTP/1.1"&lt;/span&gt; 500 114326 &lt;span class="s2"&gt;"http://172.19.10.66:8000/ping"&lt;/span&gt; &lt;span class="s2"&gt;"Consul Health Check"&lt;/span&gt;

1 desired, 1 placed, 0 healthy, 0 unhealthy &lt;span class="o"&gt;[&lt;/span&gt;health checks: 2 total, 1 passing, 1 critical]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 5: Build a DB then migrate
&lt;/h4&gt;

&lt;p&gt;Notice how 1 health check is passing (tcp), and 1 is critical. This is because we did not do a database migration and our &lt;code&gt;/ping&lt;/code&gt; healthcheck is failing. This will most likely fail after a certain amount of time, so in a separate tab navigate to the project directory to run a few &lt;code&gt;fly ssh&lt;/code&gt; commands.&lt;/p&gt;

&lt;p&gt;First, make the &lt;code&gt;ssapidb&lt;/code&gt; database by running a handy dandy bash script I added into the repo. We can use this via &lt;code&gt;fly ssh console -C&lt;/code&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;└&amp;gt; fly ssh console &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s1"&gt;'bash /app/provision_db.sh'&lt;/span&gt;
Connecting to ssapiblog.internal... &lt;span class="nb"&gt;complete
&lt;/span&gt;Database does not exist. Creating now..
CREATE DATABASE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run &lt;code&gt;fly logs&lt;/code&gt; in a separate tab, you should see Consul health checks returning 200, which is healthy \o/:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;2021-12-30T22:31:27.116 app[3d7bc4b5] iad &lt;span class="o"&gt;[&lt;/span&gt;info] 145.40.89.203 - - &lt;span class="o"&gt;[&lt;/span&gt;30/Dec/2021:22:31:27 +0000] &lt;span class="s2"&gt;"GET /ping HTTP/1.1"&lt;/span&gt; 301 0 &lt;span class="s2"&gt;"-"&lt;/span&gt; &lt;span class="s2"&gt;"Consul Health Check"&lt;/span&gt;
2021-12-30T22:31:27.119 app[3d7bc4b5] iad &lt;span class="o"&gt;[&lt;/span&gt;info] 145.40.89.203 - - &lt;span class="o"&gt;[&lt;/span&gt;30/Dec/2021:22:31:27 +0000] &lt;span class="s2"&gt;"GET /ping/ HTTP/1.1"&lt;/span&gt; 200 2 &lt;span class="s2"&gt;"http://172.19.10.66:8000/ping"&lt;/span&gt; &lt;span class="s2"&gt;"Consul Health Check"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's migrate and get a devtoken:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;└&amp;gt; fly ssh console &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s1"&gt;'python /app/manage.py migrate'&lt;/span&gt;
Connecting to ssapiblog.internal... &lt;span class="nb"&gt;complete
&lt;/span&gt;Operations to perform:
  Apply all migrations: admin, auth, authtoken, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying authtoken.0001_initial... OK
  Applying authtoken.0002_auto_20160226_1747... OK
  Applying authtoken.0003_tokenproxy... OK
  Applying sessions.0001_initial... OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 6: Get your devtoken and open the app
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;└&amp;gt; fly ssh console &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s1"&gt;'python /app/manage.py getdevtoken'&lt;/span&gt;
Connecting to ssapiblog.internal... &lt;span class="nb"&gt;complete
&lt;/span&gt;Looking &lt;span class="k"&gt;for &lt;/span&gt;superuser..
superuser doesn&lt;span class="s1"&gt;'t exist, creating!
superuser created!
Use the following key for dev:
(｡◕‿‿◕｡)☞☞  Token TOKEN  ☜☜(｡◕‿‿◕｡)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Woot! Run &lt;code&gt;fly open&lt;/code&gt; and go through the same workflow as your local deployment: put &lt;code&gt;Token TOKEN&lt;/code&gt; into the Authorize panel, and you can now see the authenticated users endpoint, and issue a GET request to get your token!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flcivi3mditvg02d6vne1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flcivi3mditvg02d6vne1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to add more users, just use the &lt;code&gt;POST&lt;/code&gt; request endpoint here to create a new user. &lt;/p&gt;

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

&lt;p&gt;I enjoyed writing this app and this blog post! Fly is a cool concept and I will definitely play with it more. There are some sharp edges with DRF, so I tried to simplify it, but please study the DRF tutorials and the &lt;code&gt;api/settings.py&lt;/code&gt; file for other configuration options I used. &lt;/p&gt;

&lt;p&gt;For my next posts, Im looking to develop an app to do some basic cybersecurity threat intelligence tracking and correlation. If you have ideas for other apps, or have a question on this app, please leave a comment or open an issue on the &lt;code&gt;ss-api&lt;/code&gt; repo here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/zmallen/ss-api" rel="noopener noreferrer"&gt;https://github.com/zmallen/ss-api&lt;/a&gt;&lt;/p&gt;

</description>
      <category>django</category>
      <category>flyio</category>
      <category>programming</category>
      <category>python</category>
    </item>
    <item>
      <title>Cross-post: Threat Detection Opportunities Learned from the Ubiquiti indictment</title>
      <dc:creator>Zack Allen</dc:creator>
      <pubDate>Wed, 22 Dec 2021 15:09:44 +0000</pubDate>
      <link>https://forem.com/teachmetechy/cross-post-threat-detection-opportunities-learned-from-the-ubiquiti-indictment-11g2</link>
      <guid>https://forem.com/teachmetechy/cross-post-threat-detection-opportunities-learned-from-the-ubiquiti-indictment-11g2</guid>
      <description>&lt;p&gt;My coworker and I just published a blog post for Datadog on the techniques used by the Ubiquiti hacker. We go into detail on different threat detection opportunities you can leverage in Amazon to catch a highly technical and malicious insider.&lt;/p&gt;

&lt;p&gt;Check it out! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/anskedatadog/threat-detection-opportunities-learned-from-the-ubiquiti-indictment-56i8"&gt;https://dev.to/anskedatadog/threat-detection-opportunities-learned-from-the-ubiquiti-indictment-56i8&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>datadog</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
