<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Space Blocks</title>
    <description>The latest articles on DEV Community by Space Blocks (@spaceblocks).</description>
    <link>https://dev.to/spaceblocks</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%2Forganization%2Fprofile_image%2F8777%2Fc328a466-1445-4364-8931-e25c619f7d79.png</url>
      <title>DEV Community: Space Blocks</title>
      <link>https://dev.to/spaceblocks</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/spaceblocks"/>
    <language>en</language>
    <item>
      <title>Understanding the Difference Between Authentication and Authorization</title>
      <dc:creator>Robin-Manuel Thiel</dc:creator>
      <pubDate>Thu, 09 May 2024 07:29:00 +0000</pubDate>
      <link>https://dev.to/spaceblocks/understanding-the-difference-between-authentication-and-authorization-1kg9</link>
      <guid>https://dev.to/spaceblocks/understanding-the-difference-between-authentication-and-authorization-1kg9</guid>
      <description>&lt;p&gt;In the realm of software development, particularly in the context of security, two terms that often come up are "authentication" and "authorization." While they sound similar and are often used interchangeably, they serve distinct purposes in ensuring the security and integrity of software systems. Let's delve into the specifics of each and explore how they differ, along with some technologies commonly used to implement them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authentication: Who Are You?
&lt;/h2&gt;

&lt;p&gt;Authentication is the process of verifying the identity of a user or entity attempting to access a system or resource. In simpler terms, authentication answers the question, "Who are you?" This process typically involves the user providing some form of credentials, such as a username and password, biometric data, security tokens, or digital certificates. The system then validates these credentials against stored records to determine whether the user is who they claim to be.&lt;/p&gt;

&lt;h3&gt;
  
  
  Technologies for Authentication:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Username and Password&lt;/strong&gt;: This is the most common form of authentication, where users provide a unique username and a corresponding password.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Biometric Authentication&lt;/strong&gt;: With advancements in technology, biometric authentication methods such as fingerprint scanning, facial recognition, iris scanning, and voice recognition are becoming increasingly popular for user authentication.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Tokens&lt;/strong&gt;: Security tokens, such as smart cards or hardware tokens, generate one-time passwords or cryptographic keys that users must provide along with their other credentials.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OAuth 2.0&lt;/strong&gt;: OAuth is an open-standard authorization protocol that allows users to access resources from one website using their credentials from another website or service without exposing their password. It is commonly used for granting third-party applications limited access to a user's resources without exposing their credentials.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Passwordless Authentication&lt;/strong&gt;: Passwordless authentication eliminates the need for traditional passwords and relies on alternative methods such as magic links sent via email, SMS-based one-time passcodes (OTPs), or authentication apps. This approach enhances security and user experience by reducing the risk of password-related attacks such as phishing and credential stuffing, while also simplifying the login process for users.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Authorization: What Are You Allowed to Do?
&lt;/h2&gt;

&lt;p&gt;Authorization, on the other hand, comes into play after authentication and determines what actions an authenticated user or entity is permitted to perform within the system. Authorization answers the question, "What are you allowed to do?" It involves defining and enforcing access controls based on the user's identity, role, or other attributes.&lt;/p&gt;

&lt;p&gt;Authorization mechanisms specify the level of access granted to users for various resources or functionalities within the system. This could include read-only access, write access, administrative privileges, or custom permissions tailored to specific roles or individuals.&lt;/p&gt;

&lt;h3&gt;
  
  
  Technologies for Authorization:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OAuth 2.0&lt;/strong&gt;: While OAuth is primarily an authentication protocol, it also has provisions for authorization through the use of access tokens. OAuth 2.0 enables third-party applications to access resources on behalf of a user with their consent, following a predefined authorization flow. Read, why Access Tokens are not sufficient for fine-grained access control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Role-Based Access Control (RBAC)&lt;/strong&gt;: RBAC is a widely used authorization model that assigns permissions to roles rather than individual users. Users are then assigned one or more roles that determine their access rights within the system. RBAC simplifies access management by grouping users based on their job functions or responsibilities. This is, what Space Blocks Permissions is doing for fine-grained access control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attribute-Based Access Control (ABAC)&lt;/strong&gt;: ABAC defines access controls based on attributes associated with the user, the resource being accessed, and the environment. Policies are defined using attributes such as user roles, location, time of access, and other contextual information to make access decisions dynamically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access Control Lists (ACLs)&lt;/strong&gt;: ACLs are a mechanism for defining and enforcing access controls on individual resources. They specify which users or groups are granted access to a particular resource and what operations they are allowed to perform.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Don't build Authentication or Authorization yourself!
&lt;/h2&gt;

&lt;p&gt;Implementing both, Authentication and Authorization on your own can be challenging and complex. You want to make sure, to follow all security requirements for storing user-passwords, for example.&lt;/p&gt;

&lt;p&gt;This is, why most developers rely on external tools for Authentication and others for Authorization, which can then be included into their apps. &lt;a href="https://www.spaceblocks.cloud"&gt;Space Blocks Permissions&lt;/a&gt; is a system to integrate fine-grained access control quickly into your apps with a few lines of code, so developers can focus on their core business. If you need to add permissions to your app, give it a try with the free Developer Tier.&lt;/p&gt;

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

&lt;p&gt;In summary, while authentication verifies the identity of users or entities accessing a system, authorization determines what actions they are allowed to perform once authenticated. Understanding the distinction between these two concepts is crucial for designing secure and robust software systems. By implementing appropriate authentication and authorization mechanisms using technologies such as those mentioned above, developers can ensure that their applications remain secure, and only authorized users have access to sensitive resources.&lt;/p&gt;

</description>
      <category>authorization</category>
      <category>authentication</category>
      <category>permissions</category>
    </item>
    <item>
      <title>Google Zanzibar implementations</title>
      <dc:creator>Robin-Manuel Thiel</dc:creator>
      <pubDate>Wed, 08 May 2024 05:22:00 +0000</pubDate>
      <link>https://dev.to/spaceblocks/google-zanzibar-implementations-56f8</link>
      <guid>https://dev.to/spaceblocks/google-zanzibar-implementations-56f8</guid>
      <description>&lt;p&gt;Authentication is hard. Implementing fine-grained access control is even harder. Whoever tried to build a sophisticated authentication system themselves knows that. And those who didn't are well advised by not trying to. Proper Authentication is so hard, that 2020 &lt;a href="https://research.google/pubs/pub48190/"&gt;Google published a research paper&lt;/a&gt; about the numerous challenges and complexity they faced when implementing a global permission system for YouTube, Google Drive and Google Photos. This research paper is called "Zanzibar".&lt;/p&gt;

&lt;p&gt;What the paper is lacking are implementation details. And since its release, some brave developers tried to implement an Authentication system along Google's findings. Here is a list of Google Zanzibar implementations:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1. Space Blocks Permissions&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://spaceblocks.cloud/"&gt;Space Blocks&lt;/a&gt; has built &lt;strong&gt;&lt;em&gt;the most complete&lt;/em&gt;&lt;/strong&gt; implementation of the Google Zanzibar research paper. It supports hierarchical permission trees, inheritance of access rights and custom roles. It can be hosted on your own servers or in the Space Blocks Cloud, where it provides high-availability and short response times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Completeness&lt;/strong&gt;: Most complete and feature-rich Zanzibar implementation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy to integrate&lt;/strong&gt;: Permissions checks are integrated with a few lines of code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GUI&lt;/strong&gt;: Graphical Editor for designing and visualizing permission trees.&lt;strong&gt;‍&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Low Learning Curve&lt;/strong&gt;: No proprietary modeling language.
****&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SDK Availability&lt;/strong&gt;: Only for .NET, JavaScript and React. Other platforms need to use the REST-API&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Additional API endpoint required&lt;/strong&gt;: Your backend might need to implement additional API endpoints for your frontend&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;2. OpenFGA&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Auth0’s OpenFGA project focuses on delivering a universal authorization system. The name stands for “Fine Grained Authorization,” emphasizing a granular approach to modeling authorization that can handle diverse use cases. It is owned by the Cloud Native Foundation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Granularity&lt;/strong&gt;: Allows fine-grained control over permissions, catering to complex authorization scenarios.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open-Source Community&lt;/strong&gt;: Community contributions and improvements are encouraged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance&lt;/strong&gt;: OpenFGA aims for reliability and performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Missing Features:&lt;/strong&gt; Operation for Listing all items a user has access to is incomplete&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Steep Learning Curve&lt;/strong&gt;: Understanding the modeling language schema may require some effort.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3. ORY Keto&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;An open-source implementation of the Google Zanzibar paper exists in the form of the ****ORY Keto project. The first working version was released, aiming to bring the concepts from the paper to practical use. It can be employed to manage permissions and roles in various applications and websites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Open-Source Community&lt;/strong&gt;: Being open source, it benefits from community contributions and improvements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fast and Efficient&lt;/strong&gt;: ORY Keto aims for high performance, ensuring rapid decision-making.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Steep Learning Curve&lt;/strong&gt;: The granular permission language might require some learning and understanding.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;4. Permify&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Permify is another open-source authorization service for creating and managing scalable authorization systems using fine-grained permissions. It draws inspiration from Google’s Zanzibar paper and offers various binding and crafting options, allowing engineers to work with performant, observable, and secure permission systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Integration&lt;/strong&gt;: Integrates into many Identity Providers like Okta and Azure Active Directory&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Granularity&lt;/strong&gt;: Allows fine-grained control over permissions, catering to complex authorization scenarios.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open-Source Community&lt;/strong&gt;: Benefits from community contributions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Steep Learning Curve&lt;/strong&gt;: Understanding the modeling schema may require effort.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>permissions</category>
      <category>authorization</category>
      <category>google</category>
      <category>zanzibar</category>
    </item>
    <item>
      <title>What is a JWT and why is it not sufficient for fine-grained access control</title>
      <dc:creator>Robin-Manuel Thiel</dc:creator>
      <pubDate>Tue, 07 May 2024 08:46:00 +0000</pubDate>
      <link>https://dev.to/spaceblocks/what-is-a-jwt-and-why-is-it-not-sufficient-for-fine-grained-access-control-5aa3</link>
      <guid>https://dev.to/spaceblocks/what-is-a-jwt-and-why-is-it-not-sufficient-for-fine-grained-access-control-5aa3</guid>
      <description>&lt;p&gt;While JWT (JSON Web Tokens) and session-based authentication mechanisms are robust tools for authenticating users and managing sessions, they fall short when it comes to fine-grained access control (FGA), which is where Space Blocks Permissions come into play.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authentication vs. Authorization
&lt;/h2&gt;

&lt;p&gt;In the realm of securing digital systems, two fundamental concepts often come into play: &lt;em&gt;authentication&lt;/em&gt; and &lt;em&gt;authorization&lt;/em&gt;. While authentication verifies the identity of a user, authorization dictates what actions they are allowed to perform within a system. So authentication is answering the question of &lt;em&gt;whom&lt;/em&gt; the user is. Authorization answers the question of &lt;em&gt;what&lt;/em&gt; the user is allowed to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does JWT work?
&lt;/h2&gt;

&lt;p&gt;JWT (JSON Web Token) is a digitally signed JSON document, which includes information about the current user. It usually gets issued to the user by the identity provider, after a user signed in successfully. With every request, the user then sends the JWT to the backend, which can then verify its authenticity at the identity provider and, in case of a positive outcome, decide to let the user do, what they want to do.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8p7m91v0vb7o6fdu6qj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8p7m91v0vb7o6fdu6qj.png" alt="Example of a JWT from jwt.io" width="800" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The information about the user in the JWT’s payload are called claims. The &lt;a href="https://www.iana.org/assignments/jwt/jwt.xhtml#claims"&gt;JWT Standard defines official claims&lt;/a&gt;, that a token can have, but any identity provider can also add custom claims. A JWT can hold any kind of information, but usually, you can find the following claims:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;iss&lt;/code&gt; (issuer): Issuer of the JWT&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sub&lt;/code&gt; (subject): Subject of the JWT (the user)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aud&lt;/code&gt; (audience): Recipient for which the JWT is intended&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;scope&lt;/code&gt; (scope): Actions for which the JWT is intended&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;exp&lt;/code&gt; (expiration time): Time after which the JWT expires&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nbf&lt;/code&gt; (not before time): Time before which the JWT must not be accepted for processing&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;iat&lt;/code&gt; (issued at time): Time at which the JWT was issued; can be used to determine the age of the JWT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When it comes to authorization (checking, what a user is allowed to do), the &lt;code&gt;aud&lt;/code&gt; (audience) and &lt;code&gt;scope&lt;/code&gt; (scope) claims of a JWT are interesting. &lt;/p&gt;

&lt;p&gt;By checking the audience, a backend service can check, if a caller, that presents a certain token should be allowed to communicate with a specific backend or service (the audiences).&lt;/p&gt;

&lt;p&gt;When defining APIs, developers often add scopes like &lt;code&gt;read:secrets&lt;/code&gt; or &lt;code&gt;write:secrets&lt;/code&gt; to their routes. Depending on how the user acquired the Access Token and which permissions that user has, different scopes are listed in a JWTs claims. Backend services can check these scopes against the ones they defined as required for their APIs, to decide if a user is allowed to call a certain API method or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why JWTs are insufficient for fine-grained access control
&lt;/h2&gt;

&lt;p&gt;As you might have noticed in the example above, JWT claims like audience and scope can only be used to check, if a user can call a certain API method or interact with a certain service at all. It’s all or nothing. The &lt;code&gt;read:secrets&lt;/code&gt; scope either allows a user to read secrets in your application or not.&lt;/p&gt;

&lt;p&gt;The reality often looks different. In most applications, where users collaborate with and share resources among each other, they have different permissions on different resources. A user might have read and write permissions to all of their own folders, but only read permissions to those that got shared by a teammate. Some permissions can also imply access to other resources without explicitly mentioning them. Read access to a folder usually also implies access to the files and sub-folder within the shared folder. &lt;/p&gt;

&lt;p&gt;JWTs are great and have their place in the authorization space, but should only be used to determine if a user should be let into a system and how far. When it comes to fine-grained access control on resource level, a more sophisticated approach like Space Blocks Permissions is needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Permissions as a Service with Space Blocks
&lt;/h2&gt;

&lt;p&gt;With the &lt;a href="https://www.spaceblocks.cloud"&gt;Space Blocks Permissions&lt;/a&gt; service, you can offload the burden of managing permissions, roles, groups and inheritance to our &lt;em&gt;Permissions as a Service&lt;/em&gt; system and focus on your core project. You can define the structure of your resources and their relationships, define permissions for them, create roles and then just let us know, whenever permissions got assigned or changed.&lt;/p&gt;

&lt;p&gt;Your backend can still use JWT for basic authentication, but can check the Space Blocks API for fine-grained access control, once a user got let into your system. &lt;/p&gt;

&lt;p&gt;You can integrate Space Blocks into your backend code with a few lines of code and completely for free in the Developer Tier.&lt;/p&gt;

</description>
      <category>permissions</category>
      <category>rbac</category>
      <category>jwt</category>
    </item>
  </channel>
</rss>
