<?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: Jan</title>
    <description>The latest articles on Forem by Jan (@spacekidlat).</description>
    <link>https://forem.com/spacekidlat</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%2F48305%2Fddaba9e5-4edc-424f-95f8-00178d5bceba.jpg</url>
      <title>Forem: Jan</title>
      <link>https://forem.com/spacekidlat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/spacekidlat"/>
    <language>en</language>
    <item>
      <title>Mold an amateur's API authentication approach</title>
      <dc:creator>Jan</dc:creator>
      <pubDate>Thu, 30 Aug 2018 03:55:38 +0000</pubDate>
      <link>https://forem.com/spacekidlat/mold-an-amateurs-api-authentication-approach-27k8</link>
      <guid>https://forem.com/spacekidlat/mold-an-amateurs-api-authentication-approach-27k8</guid>
      <description>&lt;p&gt;The process&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fqxfhwii6yos8in3zwklf.jpg" 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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fqxfhwii6yos8in3zwklf.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I know and I am familiar that we have oauth/oauth2 advancements in the API authentication area but I can't help but explore my own ideas on it.&lt;/p&gt;

&lt;p&gt;I have this idea for API authentication. Simple and straight to the point. But I can't help but feel that I lack a few more scenarios to consider on designing this flow.&lt;/p&gt;

&lt;p&gt;Glossary/Legend :&lt;br&gt;
Token = unique combination of string&lt;br&gt;
User = Registered entity in the project/app&lt;br&gt;
Red boxes = Process that would induce a "SELECT" clause&lt;br&gt;
Blue boxes = "UPDATE" clause&lt;br&gt;
Green boxes = "INSERT" clause&lt;/p&gt;

&lt;p&gt;So to start, the User makes a request to the API to create a token, the API then checks the token table if there are existing ones tagged to the user that are not yet expired, if a token exists, the expiration will be increased and returned to the user, if none a new token is created and returned.&lt;/p&gt;

&lt;p&gt;After successfully securing a token, the user is now able to request for resources from the API.&lt;/p&gt;

&lt;p&gt;Now for EVERY resource request the user makes to the API, the request would only need to include the token (aside from the parameters of the resource requested) and the can already determine which user sent the request, the API will then check the validity and expiration of said token in the database, if token is valid, return the resource, if not return a 401 http code.&lt;/p&gt;

&lt;p&gt;Additional notes : Thinking about 3rd party logins, Some sort of access type can be attached to the token to determine the purpose of it, i.e. access via facebook, twitter etc&lt;/p&gt;

&lt;p&gt;I believe in this logic but I wanna find out things that would make this a more better and industry-standardized approach so to speak.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>api</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
