<?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: Maria Pelagia</title>
    <description>The latest articles on DEV Community by Maria Pelagia (@maria_pelagia_389e257c127).</description>
    <link>https://dev.to/maria_pelagia_389e257c127</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%2F1005215%2Fb505a712-e211-41f1-8e65-7ce41803eeb0.jpeg</url>
      <title>DEV Community: Maria Pelagia</title>
      <link>https://dev.to/maria_pelagia_389e257c127</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/maria_pelagia_389e257c127"/>
    <language>en</language>
    <item>
      <title>Scopes and Claims Explained</title>
      <dc:creator>Maria Pelagia</dc:creator>
      <pubDate>Thu, 02 May 2024 08:45:43 +0000</pubDate>
      <link>https://dev.to/curity/scopes-and-claims-explained-3fhm</link>
      <guid>https://dev.to/curity/scopes-and-claims-explained-3fhm</guid>
      <description>&lt;p&gt;In OAuth and OpenID Connect, scopes and claims appear quite often. However, many times their explanation is overlooked. This brief article will explain what scopes and claims are and how you can use them. &lt;/p&gt;

&lt;h2&gt;
  
  
  Claims Explained
&lt;/h2&gt;

&lt;p&gt;Claims are statements of facts that are only believable if the asserting party is trusted. In OAuth and OpenID Connect, the asserting party is the authorization server. A claim can be asserted about a subject or an entity—often the user—that is claimed to be true by an asserting party. The subject is the resource owner; the API or the client is the relying party.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scopes Explained
&lt;/h2&gt;

&lt;p&gt;Scopes are a set of claims. They are a shorthand way of requesting a level of access from the authorization server. Clients request one or more scopes to be issued to access tokens so that they get the API permissions they need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Standard Claims and Scopes
&lt;/h2&gt;

&lt;p&gt;In OpenID Connect, a profile scope consists of a group of claim names that include claim values. The claim names usually contain these variables: &lt;em&gt;name, family_name, given_name, middle_name, profile, picture, website, gender,etc&lt;/em&gt;. When a user logs in, the values for those claims - if the authorization server can assert them - will be asserted as claim values. Instead of having to ask for a dozen different claims, you can simply request one scope that will contain this information.&lt;/p&gt;

&lt;p&gt;Examples of standard OpenID groupings include: &lt;em&gt;profile, openid, offline_access, email, address, phone&lt;/em&gt;. When a user logs in and is being authenticated, and their data is released in claims format, this information can be passed into an ID token user info or to an access token. Consequently, these claim values would end up manifesting themselves.&lt;/p&gt;

&lt;h2&gt;
  
  
  How are Claims and Scopes Useful?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Business Value&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scopes and claims provide the heart of a scalable security architecture for your APIs and clients. Scopes enable you to set security boundaries to define which clients can access which API endpoints. You can create custom scopes that are defined in terms of areas of your business.&lt;/p&gt;

&lt;p&gt;Your APIs use claims to implement their business authorization. You can define custom claims to implement any finer-grained identity values your APIs need. Both scopes and claims are issued to access tokens returned to clients so that each client calls APIs with the correct level of business access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Consent&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The consent user experience should be based on scopes not claims. The user sees a plain English message of a scope's meaning rather than technical information about many fine-grained permissions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary &amp;amp; Conclusion
&lt;/h2&gt;

&lt;p&gt;Claims are assertions made by one party about another. The authorization server is the asserting party, the user is the subject, the API and the client are the relying parties. Scopes are a group of claims and with claims less data is released. Lastly, claims provide a finer-grained authorization model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Further Reading:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://curity.io/resources/learn/scopes-vs-claims/"&gt;Scopes vs Claims&lt;/a&gt;&lt;br&gt;
&lt;a href="https://curity.io/resources/learn/what-are-claims-and-how-they-are-used/"&gt;Introduction to Claims&lt;/a&gt;&lt;br&gt;
&lt;a href="https://curity.io/resources/learn/scopes-and-how-they-relate-to-claims/"&gt;Introduction to Scopes&lt;/a&gt;&lt;br&gt;
&lt;a href="https://curity.io/resources/learn/using-claims-in-apis/"&gt;Using Claims in APIs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://curity.io/resources/learn/scopes-claims-and-the-client/"&gt;Scopes, Claims and the Client&lt;/a&gt;&lt;br&gt;
&lt;a href="https://curity.io/resources/learn/the-relationship-between-consent-and-claims/"&gt;Consent and Claims&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>api</category>
      <category>cybersecurity</category>
      <category>community</category>
    </item>
    <item>
      <title>Best Practices for Handling JWTs</title>
      <dc:creator>Maria Pelagia</dc:creator>
      <pubDate>Wed, 11 Jan 2023 12:34:43 +0000</pubDate>
      <link>https://dev.to/curity/best-practices-for-handling-jwts-3all</link>
      <guid>https://dev.to/curity/best-practices-for-handling-jwts-3all</guid>
      <description>&lt;p&gt;Even though JSON Web Tokens (JWT) are widely used in the OAuth and OpenID protocols, maintaining a high level of security while using them is not always easy. This article will focus on some best practices for handling JWTs so that you can maintain a high level of security in your applications. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is a JWT?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;JWTs are not protocols, they are message formats.&lt;/li&gt;
&lt;li&gt;They are used to pass messages between two parties, e.g., a client and a server, or between services.&lt;/li&gt;
&lt;li&gt;A JSON Web Token has a form of a string divided into parts which are base64 encoded and separated by dots. &lt;/li&gt;
&lt;li&gt;A JWT can either be a JWS (a signed token) or a JWE (an encrypted token). These types of tokens define the parts that the JSON Web Token will consist of. &lt;/li&gt;
&lt;li&gt;Most often JWTs are used as Access Tokens or ID Tokens (but they can also be used in other scenarios as well).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  JWT Best Practices
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Protect Valuable API Data in Access Tokens&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;When JWTs are issued to your clients to be used as Access Tokens, client developers are able to access the data in the token.  In such cases developers can start using the data from JWTs in their applications which can cause issues if you decide to change the structure of the data in the JWT. As the token can easily be accessed or read, personal information about users can also be easily leaked and valuable API data can become prone to cyber attacks. Either avoid adding sensitive data to access tokens or utilise a pattern like the &lt;a href="https://curity.io/resources/learn/phantom-token-pattern/" rel="noopener noreferrer"&gt;Phantom Token&lt;/a&gt;, where the data is concealed by an opaque token.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JWTs and Algorithms&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Encrypted and signed tokens always contain an &lt;code&gt;alg&lt;/code&gt; claim in the header to show which algorithm has been used. When verifying and decrypting tokens it is considered a best practice to check the value of this claim against a list of algorithms that your system accepts and which are verified to be secure. If the &lt;code&gt;alg&lt;/code&gt; claim contains a &lt;code&gt;none&lt;/code&gt; value, make sure that you know both the identity of the issuer of the token and of the client that uses the token before proceeding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Always Validate an Incoming JWT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another best practice is to always validate an incoming token. This should be done even when a service is only accessible on an internal network, to prevent situations where someone manages to make requests from inside the network. Many times when services are moved to a public domain the security measures are overlooked, thus it’s important to have them properly protected from the beginning. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verify the Issuer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Always check the issuer of the JWT to make sure that you can trust them by checking the &lt;code&gt;iss&lt;/code&gt; claim. This is especially important when downloading the keys needed to validate / decrypt the tokens. Make sure to confirm that any cryptographic keys used to sign or encrypt the token belong to the issuer. The verification of the issuer depends on the implementation of the JWT. For example, when using OpenID Connect the issuer should be an HTTPS URL. This makes it easier to confirm the ownership. &lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this article we have explored a few best practices when using JWTs. It's important to remember that JWT safety depends greatly on how the tokens are implemented and used. At Curity, we have written a complete guide on &lt;a href="https://curity.io/resources/learn/jwt-best-practices/" rel="noopener noreferrer"&gt;how to keep your JWTs secure&lt;/a&gt;, following best practices. Make sure to also check any changes in the RFCs which talk about the good practices for &lt;a href="https://www.rfc-editor.org/rfc/rfc8725" rel="noopener noreferrer"&gt;JWTs: in RFC 8725 JSON Web Token Best Current Practices&lt;/a&gt; and in &lt;a href="https://www.rfc-editor.org/rfc/rfc7518" rel="noopener noreferrer"&gt;RFC 7518 JSON Web Algorithms (JWA)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Related content:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://curity.io/resources/learn/self-contained-jwts/" rel="noopener noreferrer"&gt;Self-contained JWTs - Curity&lt;/a&gt;&lt;br&gt;
&lt;a href="https://curity.io/resources/learn/jwt-signatures/" rel="noopener noreferrer"&gt;JWT Signatures and EdDSA - Curity&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>help</category>
      <category>saas</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
