<?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: Renato D. Prado</title>
    <description>The latest articles on DEV Community by Renato D. Prado (@renato_dprado_bbf0901ec).</description>
    <link>https://dev.to/renato_dprado_bbf0901ec</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3203878%2Fa42acaad-6826-4c55-b46f-9741d0c7f306.png</url>
      <title>DEV Community: Renato D. Prado</title>
      <link>https://dev.to/renato_dprado_bbf0901ec</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/renato_dprado_bbf0901ec"/>
    <language>en</language>
    <item>
      <title>Access tokens, refresh tokens, and the offline_access mess</title>
      <dc:creator>Renato D. Prado</dc:creator>
      <pubDate>Sun, 29 Nov 2026 21:07:52 +0000</pubDate>
      <link>https://dev.to/renato_dprado_bbf0901ec/access-tokens-refresh-tokens-and-the-offlineaccess-mess-2i6p</link>
      <guid>https://dev.to/renato_dprado_bbf0901ec/access-tokens-refresh-tokens-and-the-offlineaccess-mess-2i6p</guid>
      <description>&lt;p&gt;Authentication looks simple from the outside: a sign-in page, a sign-out button. Underneath, it is a stack of specifications written over more than a decade, identity providers that each made their own choices, and best practices that changed along the way. I have been building apps that deal with authentication, both at work and in personal projects. Whenever I asked an AI assistant about authentication and authorization, the answers were often confusing and sometimes misleading. They changed from one question to the next, and explanations that sounded confident fell apart as soon as I looked closer. So in this post I lean on the specifications themselves, and quote them wherever I can.&lt;/p&gt;

&lt;p&gt;The earlier posts in this series covered how a sign-in is protected: &lt;code&gt;state&lt;/code&gt;, PKCE, the &lt;code&gt;nonce&lt;/code&gt;, exact redirect URIs. This post is about what the app receives &lt;strong&gt;after&lt;/strong&gt; the sign-in: an access token and a refresh token. I want to answer three questions that confused me for a long time. How long should each token live? Who decides when a user is signed out? And what is &lt;code&gt;offline_access&lt;/code&gt;, a value I had been putting in my apps' configuration without really understanding it?&lt;/p&gt;

&lt;p&gt;The base for this post is the IETF's current guide for web apps: &lt;strong&gt;RFC 10017, *OAuth 2.0 for Browser-Based Applications&lt;/strong&gt;*, published in August 2026 as Best Current Practice 212. Every quote marked "RFC 10017" comes from it: &lt;a href="https://www.rfc-editor.org/rfc/rfc10017" rel="noopener noreferrer"&gt;https://www.rfc-editor.org/rfc/rfc10017&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A few terms first
&lt;/h2&gt;

&lt;p&gt;Four parties take part in a sign-in, and it helps to name them before going further:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;strong&gt;user&lt;/strong&gt;, the person signing in;&lt;/li&gt;
&lt;li&gt;the &lt;strong&gt;app&lt;/strong&gt; the user is using. The OAuth specifications call it the &lt;em&gt;client&lt;/em&gt;;&lt;/li&gt;
&lt;li&gt;the &lt;strong&gt;identity provider&lt;/strong&gt;, the server where the user signs in: Google, Microsoft, Keycloak, or one your company runs. The OAuth specifications call it the &lt;em&gt;authorization server&lt;/em&gt;, a name you will see in the quotes below;&lt;/li&gt;
&lt;li&gt;one or more &lt;strong&gt;APIs&lt;/strong&gt; that the app calls to do its work. Each API only answers requests that carry a valid access token. The OAuth specifications call each one a &lt;em&gt;resource server&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They fit together like this.  When you click "Sign in", the app redirects your browser to the identity provider's sign-in page. The identity provider then redirects your browser back to the app with a one-time co&lt;br&gt;
de, and the app exchanges that code with the identity provider for tokens. From then on, the app calls the APIs and sends an access token with each call, and each API checks that token before it answers. One app often talks to several APIs, and one identity provider often serves several apps: that is how a company can have a single sign-in for all its products.&lt;/p&gt;

&lt;p&gt;Two specifications define how this works, and they are easy to mix up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OAuth 2.0&lt;/strong&gt; (RFC 6749) is about &lt;em&gt;authorization&lt;/em&gt;: how an app gets an &lt;strong&gt;access token&lt;/strong&gt; that lets it call the APIs on the user's behalf. With OAuth alone, the app gets permission to call the APIs, but it doesn't learn who the user is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenID Connect&lt;/strong&gt; is about &lt;em&gt;authentication&lt;/em&gt;. It describes itself as "a simple identity layer on top of the OAuth 2.0 protocol", and its main addition is the &lt;strong&gt;id_token&lt;/strong&gt;, which tells the app who signed in. OpenID Connect also defines the &lt;code&gt;offline_access&lt;/code&gt; scope discussed below, and, in companion specifications, how users sign out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice, signing in to a modern app uses both: OpenID Connect to know who you are, OAuth to get the tokens for the API. In this post, "identity provider" means the server that does both.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IdentityServer&lt;/strong&gt; is a .NET framework for building your own identity provider. Version 4 is open source; its successor is the commercial Duende IdentityServer. IdentityServer 4 is no longer supported: its support ended in December 2022, and its repository is now archived. I still use it as a reference in this post because it keeps running in existing systems, including the one I work with, either directly or through community forks such as IdentityServer8.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;scope&lt;/strong&gt; is a word the app puts in the sign-in request to say what it wants, for example &lt;code&gt;openid profile email&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the confusion came from
&lt;/h2&gt;

&lt;p&gt;At work we run an identity provider built on IdentityServer 4. Its documentation explains how an app gets a refresh token:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Since this is a privileged operation, the clients needs to be explicitly authorized to be able to use refresh tokens by setting the &lt;code&gt;AllowOfflineAccess&lt;/code&gt; property to &lt;code&gt;true&lt;/code&gt;."&lt;/p&gt;

&lt;p&gt;"You can request a refresh token by adding a scope called &lt;code&gt;offline_access&lt;/code&gt; to the scope parameter list of the authorize request."&lt;/p&gt;

&lt;p&gt;(Duende IdentityServer documentation, &lt;em&gt;Refreshing a Token&lt;/em&gt;: &lt;a href="https://docs.duendesoftware.com/identityserver/tokens/refresh/" rel="noopener noreferrer"&gt;https://docs.duendesoftware.com/identityserver/tokens/refresh/&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So every web app that needed a refresh token asked for the &lt;code&gt;offline_access&lt;/code&gt; scope. These apps are used in a browser, with a person in front of the screen. Nothing about them is offline. That raised two questions I couldn't answer: why is it called "offline", and when the user signs out, should the app keep working with its refresh token?&lt;/p&gt;

&lt;p&gt;To answer them, we first need to separate two things that are easy to mix up: the identity provider's session and the app's tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two sessions, not one
&lt;/h2&gt;

&lt;p&gt;When you sign in to an app through an identity provider, two separate things are created.&lt;/p&gt;

&lt;p&gt;The first is &lt;strong&gt;the identity provider's session&lt;/strong&gt;. The provider stores a cookie in your browser, on its own domain. While that cookie lives, its sign-in page lets you through without asking for your password again. That is what single sign-on means: you sign in once, and the other apps that use the same provider let you in. OpenID Connect's sign-out specifications give this session an id, called &lt;code&gt;sid&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The second is &lt;strong&gt;the app's tokens&lt;/strong&gt;. After the sign-in, the app receives an access token and, usually, a refresh token. It also receives an id_token, which says who signed in and can carry the &lt;code&gt;sid&lt;/code&gt; of the provider session it came from.&lt;/p&gt;

&lt;p&gt;The important point is that neither token depends on the provider's cookie. The API validates the access token on its own, without asking the provider about its session. The refresh token is exchanged in a call between the app's server and the provider, with no browser involved. So the tokens &lt;em&gt;can&lt;/em&gt; keep working after the provider's session has ended. Whether they &lt;em&gt;should&lt;/em&gt; is a decision, and that decision is what this post is about.&lt;/p&gt;

&lt;h2&gt;
  
  
  The access token: short and narrow
&lt;/h2&gt;

&lt;p&gt;The access token is what the app sends to the APIs with each request. It is a &lt;em&gt;bearer&lt;/em&gt; token: whoever holds it can use it, just like cash. If someone steals it, they can call those APIs as you until it expires. RFC 10017 gives this advice:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The recommended defensive strategy to decrease the risk associated with compromised access tokens is to reduce the scope and lifetime of the token." (RFC 10017, §5.1.1)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In practice, that means access tokens should last minutes, not days, and allow only what the app needs. A short lifetime creates a new problem, though. A few minutes later the user is still using the app, and the app needs a new access token without sending the user back to the sign-in page. That is the job of the refresh token.&lt;/p&gt;

&lt;h2&gt;
  
  
  The refresh token: renewing without the user
&lt;/h2&gt;

&lt;p&gt;A refresh token is exchanged at the identity provider for a new access token. The user doesn't see this happen, and doesn't have to type anything. Because a refresh token is powerful, RFC 10017 sets rules for the identity provider that issues it. They appear in its section on apps that run entirely in the browser (§6.3.2.3), where the risk is highest.&lt;/p&gt;

&lt;p&gt;First, it must not live forever. The provider "MUST either set a maximum lifetime on refresh tokens OR expire if the refresh token has not been used within some amount of time."&lt;/p&gt;

&lt;p&gt;Second, it must be protected against copying. The provider "MUST either rotate refresh tokens on each use OR use sender-constrained refresh tokens". Rotation means every refresh returns a new refresh token and retires the old one. If the old one is ever used again, someone must have copied it, and the provider can cancel the whole chain. The RFC calls rotation "a detection and correction mechanism" (§5.1.1). Sender-constrained tokens are the alternative: they only work together with a private key that the app holds.&lt;/p&gt;

&lt;p&gt;Third, rotation must not stretch the lifetime. A new refresh token must not last "beyond the lifetime of the initial refresh token."&lt;/p&gt;

&lt;p&gt;To give a sense of scale, the RFC's own example pairs an access token of 10 minutes with "a refresh token that lasts 8 hours."&lt;/p&gt;

&lt;h2&gt;
  
  
  Which session should the refresh token follow?
&lt;/h2&gt;

&lt;p&gt;This is the sentence that settled the question for me:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Authorization servers SHOULD link the lifetime of the refresh token to the user's authenticated session with the authorization server." (RFC 10017, §6.3.2.3)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The RFC also explains why:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Doing so ensures that when a user logs out, previously issued refresh tokens to browser-based applications become invalid, mimicking a single-logout scenario." (RFC 10017, §6.3.2.3)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In other words, the identity provider's session decides. When it ends, the refresh tokens issued under it should stop working.&lt;/p&gt;

&lt;p&gt;That alone doesn't sign the other apps out at once. An app only finds out when it tries to refresh, so it keeps working until its current access token expires. To sign the other apps out right away, the identity provider can notify each of them directly, server to server, using OpenID Connect Back-Channel Logout. Even then, an access token that was already issued stays valid until it expires: one more reason to keep access tokens short. This sentence is in the same section on apps that run entirely in the browser, but I think the reasoning applies to any web app that a person uses in a browser.&lt;/p&gt;

&lt;p&gt;This matches what I see with Google in my own browser. When I sign out of Google in one browser, the other Google sites in that browser are signed out too, but my phone and my other browsers stay signed in. Each browser has its own provider session, with its own &lt;code&gt;sid&lt;/code&gt;. A private window counts as another browser, which is why it asks for the password again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Online and offline refresh tokens
&lt;/h2&gt;

&lt;p&gt;This is the heart of the confusion, so let's go slowly.&lt;/p&gt;

&lt;p&gt;The difference between "online" and "offline" is &lt;strong&gt;not&lt;/strong&gt; whether the app has a refresh token. Both kinds of app use one, in exactly the same way: every few minutes, the app's server trades it for a new access token. The difference is &lt;strong&gt;what happens to the refresh token when the user's session at the identity provider ends.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An &lt;strong&gt;online&lt;/strong&gt; refresh token is tied to that session. When the user signs out at the identity provider, or the session expires, the next refresh fails, and the app is signed out too.&lt;/li&gt;
&lt;li&gt;An &lt;strong&gt;offline&lt;/strong&gt; refresh token is not tied to that session. It keeps working until its own lifetime runs out or someone revokes it, whether the user is still signed in at the identity provider or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An example makes it concrete. In the morning you sign in to three apps through the same identity provider. App A and App C are dashboards you use in your browser. App B is a service that copies your new files to a backup every night.&lt;/p&gt;

&lt;p&gt;In the evening, you click "Sign out" in App A. App A ends its own session right away and sends your browser to the identity provider, which ends its session too.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;App C is still open in another tab. A few minutes later, it tries to refresh. Its refresh token was online, so the refresh fails and App C is signed out as well. That is what you wanted: you signed out.&lt;/li&gt;
&lt;li&gt;At three in the morning, App B tries to refresh. Its refresh token was offline, so the refresh works and the backup runs. That is also what you wanted: the backup's whole job is to work while you are not there.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now swap them. If App C had an offline token, it would stay signed in on that browser after you signed out, and anyone who sat down at your computer could keep using it. If App B had an online token, the backup would stop the first night you signed out.&lt;/p&gt;

&lt;p&gt;So the rule of thumb is simple. An app that a person uses should get an online refresh token, which is what RFC 10017 asks for when it says the refresh token's lifetime should be linked to the user's session at the identity provider. An app that has to work while nobody is signed in needs an offline one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the name comes from
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;offline_access&lt;/code&gt; comes from OpenID Connect, not from OAuth. OpenID Connect Core, §11 &lt;em&gt;Offline Access&lt;/em&gt;, defines it as a scope that "requests that an OAuth 2.0 Refresh Token be issued that can be used to obtain an Access Token" to reach the user's data while the user is not logged in at the identity provider. So "offline" has nothing to do with the network. It means "the user is not signed in at the identity provider anymore".&lt;/p&gt;

&lt;p&gt;Google uses the same word in its own OAuth API. Its authorization request has an &lt;code&gt;access_type&lt;/code&gt; parameter with two values, &lt;code&gt;online&lt;/code&gt; (the default) and &lt;code&gt;offline&lt;/code&gt;, and Google's documentation says to choose &lt;code&gt;offline&lt;/code&gt; "if your application needs to refresh access tokens when the user is not present at the browser." (Google Identity, &lt;em&gt;Using OAuth 2.0 for Web Server Applications&lt;/em&gt;: &lt;a href="https://developers.google.com/identity/protocols/oauth2/web-server" rel="noopener noreferrer"&gt;https://developers.google.com/identity/protocols/oauth2/web-server&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Because an offline token lets an app act for you while you are away, OpenID Connect normally requires the identity provider to ask the user for consent, and it adds: "A previously saved user consent is not always sufficient to grant offline access." (OIDC Core, §11)&lt;/p&gt;

&lt;p&gt;RFC 10017 does not mention &lt;code&gt;offline_access&lt;/code&gt; at all. For web apps, the only refresh token it describes is the online kind.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where IdentityServer 4 fits
&lt;/h2&gt;

&lt;p&gt;OpenID Connect does not require &lt;code&gt;offline_access&lt;/code&gt; for every refresh token: §11 ends by saying that refresh tokens are not limited to the offline case. So an identity provider can offer both kinds, and some do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keycloak&lt;/strong&gt;, an open-source identity provider, offers both. ("Online" is my word for it; Keycloak simply says "refresh token".) A normal sign-in gets an online refresh token, tied to the user's session. Asking for &lt;code&gt;offline_access&lt;/code&gt; gets what Keycloak calls an &lt;em&gt;offline token&lt;/em&gt;, which, in its documentation, "is not subject to the SSO Session Idle timeout and SSO Session Max lifespan" and "is valid after a user logout or server restart".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Auth0&lt;/strong&gt;, a hosted identity provider, explains the same split in its community forum: an app can refresh tokens without &lt;code&gt;offline_access&lt;/code&gt; as long as the user still has an active session at the provider.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IdentityServer 4&lt;/strong&gt; offers only one kind. As quoted at the start, an app gets a refresh token only by asking for &lt;code&gt;offline_access&lt;/code&gt;. By default, that token is not tied to the user's session: signing out doesn't touch it. IdentityServer 4 does record which session each refresh token came from, though, and offers a method that the sign-out page can call, &lt;code&gt;RevokeTokensForCurrentSessionAsync&lt;/code&gt;, which deletes every refresh token of the current session. Nothing equivalent happens when the session simply expires.&lt;/p&gt;

&lt;p&gt;That is the whole mess. With IdentityServer 4, App A, the dashboard, can only get the kind of refresh token that App B, the backup, needs. Every web app ends up with an offline token: a token that outlives the user's session at the identity provider. That is exactly what RFC 10017 advises against, unless the sign-out page calls &lt;code&gt;RevokeTokensForCurrentSessionAsync&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not skip refresh tokens?
&lt;/h2&gt;

&lt;p&gt;My first idea was to drop refresh tokens altogether and simply issue a new access token every few minutes. The trouble is how the app would get that new token. Without a refresh token, the only way is to send the &lt;strong&gt;browser&lt;/strong&gt; back to the provider's sign-in page with &lt;code&gt;prompt=none&lt;/code&gt;, a parameter that asks the provider to answer silently. It works only while the provider's cookie lives.&lt;/p&gt;

&lt;p&gt;Apps that run entirely in the browser used to do this inside a hidden iframe. Browsers now block the third-party cookies that this trick needs, and RFC 10017 draws the conclusion:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"in light of the impact of third-party cookie-blocking mechanisms, the use of refresh tokens has become significantly more attractive." (RFC 10017, §6.3.2.3)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So the refresh token is not the problem. It is simply the way to renew an access token without the browser. The real question is how long the refresh token lives, and that is what &lt;code&gt;offline_access&lt;/code&gt; changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we are changing
&lt;/h2&gt;

&lt;p&gt;Putting all of this together, this is the model I chose for my own apps.&lt;/p&gt;

&lt;p&gt;The identity provider's session decides, and refresh tokens are tied to its &lt;code&gt;sid&lt;/code&gt;. When the user signs out of an app, the app sends the browser to the provider's sign-out page, together with the id_token. That flow is defined by OpenID Connect RP-Initiated Logout. The provider then ends its session and revokes every refresh token issued under that &lt;code&gt;sid&lt;/code&gt;. Each app's next refresh fails, and the app ends its own session.&lt;/p&gt;

&lt;p&gt;When the provider's session expires without a sign-out, the same revocation should happen. My own identity provider revokes at sign-out but not yet at expiry. IdentityServer 4 can revoke at sign-out if the sign-out page calls &lt;code&gt;RevokeTokensForCurrentSessionAsync&lt;/code&gt;, and has nothing for expiry. In both cases, the expiry part still has to be written.&lt;/p&gt;

&lt;p&gt;How long the provider session lasts then becomes a product decision: it is how long people stay signed in to every app that uses it.&lt;/p&gt;

&lt;p&gt;Finally, &lt;code&gt;offline_access&lt;/code&gt; stays available for apps that really work while the user is away, with a consent screen that says so.&lt;/p&gt;

&lt;p&gt;The other side of this, how the app's backend holds these tokens for the browser (the BFF pattern), is the subject of the next post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Access tokens should be short and narrow (RFC 10017, §5.1.1).&lt;/li&gt;
&lt;li&gt;Refresh tokens need a maximum lifetime, and either rotation or a private key that binds them to the app. Rotation must never stretch their lifetime (RFC 10017, §6.3.2.3).&lt;/li&gt;
&lt;li&gt;For web apps, the refresh token should stop working when the user's session at the identity provider ends (RFC 10017, §6.3.2.3).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;offline_access&lt;/code&gt; means "the user is not logged in at the provider", not "no network". It is meant for apps that work while the user is away.&lt;/li&gt;
&lt;li&gt;If your identity provider only issues offline refresh tokens, as IdentityServer 4 does, revoke them by &lt;code&gt;sid&lt;/code&gt; at sign-out and at expiry. Otherwise, signing out doesn't fully sign the user out.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;RFC 10017, &lt;em&gt;OAuth 2.0 for Browser-Based Applications&lt;/em&gt; (BCP 212), §5.1.1 and §6.3.2.3: &lt;a href="https://www.rfc-editor.org/rfc/rfc10017" rel="noopener noreferrer"&gt;https://www.rfc-editor.org/rfc/rfc10017&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;RFC 9700, &lt;em&gt;Best Current Practice for OAuth 2.0 Security&lt;/em&gt;, §4.14.2.&lt;/li&gt;
&lt;li&gt;OpenID Connect Core 1.0, §11 &lt;em&gt;Offline Access&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;OpenID Connect RP-Initiated Logout 1.0.&lt;/li&gt;
&lt;li&gt;Duende IdentityServer documentation, &lt;em&gt;Refreshing a Token&lt;/em&gt; (the old IdentityServer4 documentation now redirects here): &lt;a href="https://docs.duendesoftware.com/identityserver/tokens/refresh/" rel="noopener noreferrer"&gt;https://docs.duendesoftware.com/identityserver/tokens/refresh/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Duende, &lt;em&gt;IdentityServer4 is public again&lt;/em&gt; (the archived repository): &lt;a href="https://blog.duendesoftware.com/posts/20250306-identityserver4-public-again" rel="noopener noreferrer"&gt;https://blog.duendesoftware.com/posts/20250306-identityserver4-public-again&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Keycloak Server Administration Guide, &lt;em&gt;Managing user sessions&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Auth0 Community, &lt;em&gt;Ask Me Anything: Auth0 Sessions and Refresh Tokens&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>authentication</category>
      <category>backend</category>
      <category>security</category>
    </item>
    <item>
      <title>OAuth sign-in with a BFF: why the client secret still matters</title>
      <dc:creator>Renato D. Prado</dc:creator>
      <pubDate>Tue, 24 Nov 2026 19:56:27 +0000</pubDate>
      <link>https://dev.to/renato_dprado_bbf0901ec/oauth-sign-in-with-a-bff-why-the-client-secret-still-matters-3kp7</link>
      <guid>https://dev.to/renato_dprado_bbf0901ec/oauth-sign-in-with-a-bff-why-the-client-secret-still-matters-3kp7</guid>
      <description>&lt;p&gt;In the previous articles we added protection after protection to the sign-in: &lt;code&gt;state&lt;/code&gt; against login CSRF, PKCE against a stolen or injected authorization code, and exact redirect URIs so the authorization code only goes back to the app. With all that in place, a fair question is: &lt;strong&gt;why does the BFF still need a client secret?&lt;/strong&gt; If the redirect URI is exact and PKCE is on, what is left for it to do?&lt;/p&gt;

&lt;h2&gt;
  
  
  What the client secret is
&lt;/h2&gt;

&lt;p&gt;When an app is registered at the identity provider, it gets a &lt;strong&gt;client id&lt;/strong&gt; (public, it appears in every &lt;code&gt;/authorize&lt;/code&gt; URL) and, if it runs on a server, a &lt;strong&gt;client secret&lt;/strong&gt;: a password for the app itself. Whenever the app calls the provider's token endpoint, it sends both, and the provider checks them (RFC 6749, §2.3).&lt;/p&gt;

&lt;p&gt;Only apps that can keep a secret get one. OAuth calls them &lt;strong&gt;confidential clients&lt;/strong&gt;: a server, like our BFF. A single-page app or a mobile app is a &lt;strong&gt;public client&lt;/strong&gt;: anything shipped to a browser or a phone can be read by whoever has it, so it can't hold a secret (RFC 6749, §2.1). That's one of the main reasons to have a BFF at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Each protection answers a different question
&lt;/h2&gt;

&lt;p&gt;The protections we've seen don't overlap; each one checks something else:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Protection&lt;/th&gt;
&lt;th&gt;The question it answers&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;state&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Did &lt;strong&gt;this browser&lt;/strong&gt; start this sign-in?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PKCE&lt;/td&gt;
&lt;td&gt;Is whoever exchanges this authorization code the one who &lt;strong&gt;started this sign-in&lt;/strong&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exact redirect URI&lt;/td&gt;
&lt;td&gt;Does the authorization code go back &lt;strong&gt;to the app's own address&lt;/strong&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Client secret&lt;/td&gt;
&lt;td&gt;Is whoever calls the token endpoint &lt;strong&gt;the registered app&lt;/strong&gt;?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Only the client secret is about the app's identity. The other three are about one sign-in. That difference is what the rest of this article is about.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the client secret does
&lt;/h2&gt;

&lt;p&gt;The client secret &lt;strong&gt;identifies the app&lt;/strong&gt; to the identity provider. Every time the BFF calls the provider's token endpoint (to exchange an authorization code, refresh a token, or revoke one), it sends its client id and its secret, and the provider checks them. So only the real BFF can make those calls in the app's name.&lt;/p&gt;

&lt;p&gt;That gives the provider two things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It knows which app is behind each request.&lt;/strong&gt; It can log it, apply per-app rules (which scopes the app may ask for, how long its tokens last, rate limits), and switch an app off.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What it issued to an app can only be used by that app.&lt;/strong&gt; OAuth says this is the purpose of client authentication: to bind authorization codes and refresh tokens to the app they were issued to (RFC 6749, §3.2.1).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Can someone build a fake app?
&lt;/h3&gt;

&lt;p&gt;The client id is no secret: it appears in every &lt;code&gt;/authorize&lt;/code&gt; URL, so anyone can copy it and build a fake app that claims to be yours. What can that fake app do?&lt;/p&gt;

&lt;p&gt;The other attacks in this series (login CSRF, code injection, the code sent to the wrong place) go through your real app. Here we only look at what a &lt;strong&gt;fake app holding your client id&lt;/strong&gt; can try, and it comes down to two things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Getting new authorization codes.&lt;/strong&gt; The fake app starts a sign-in with your client id and hopes the provider sends the code to it. Here the client secret isn't even needed: with an exact redirect URI (previous article), the provider sends the code to &lt;strong&gt;your&lt;/strong&gt; app's address, never to the fake one. The redirect URI alone stops this.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using codes or tokens stolen from your app&lt;/strong&gt;, such as a refresh token taken from a log or a leaked database. The fake app takes it straight to the token endpoint. The redirect URI can't help here, because nothing is being redirected. What stops it is the client secret: the token endpoint wants proof that the caller &lt;strong&gt;is&lt;/strong&gt; your app. Without a secret, your client id is all it asks for, and anyone has that. With a secret, the fake app is stuck.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So exact redirect URIs keep the fake app from &lt;strong&gt;receiving&lt;/strong&gt; your app's authorization codes, and the client secret keeps it from &lt;strong&gt;using&lt;/strong&gt; anything issued to your app.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Refresh tokens
&lt;/h3&gt;

&lt;p&gt;The biggest thing a stolen value can give is a refresh token. Access tokens are short-lived, so the app usually also gets a refresh token: a long-lived token it exchanges for new access tokens without asking you to log in again. Days or weeks of access, in one string.&lt;/p&gt;

&lt;p&gt;PKCE plays no part here: it only protects the exchange of an authorization code. So with a client secret, a stolen refresh token alone gets nothing (RFC 6749, §6). Without one (a public client), the refresh token alone is enough, which is why RFC 9700 requires extra measures for public clients' refresh tokens, such as rotating them on every use (§2.2.2).&lt;/p&gt;

&lt;p&gt;The same goes for a stolen authorization code when the provider ignores PKCE (a provider that doesn't know PKCE silently ignores the &lt;code&gt;code_challenge&lt;/code&gt;): the attacker still can't exchange it directly without the secret. It doesn't stop the code injection from the second article, which goes &lt;strong&gt;through&lt;/strong&gt; the BFF and its own secret.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Recovering when something leaks
&lt;/h3&gt;

&lt;p&gt;If the app is compromised, the provider can change its secret or disable it, and every stolen authorization code and refresh token issued to it stops working at once, without touching any user. A public client has no such switch: anyone who copied its client id can keep presenting it.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Revoking tokens
&lt;/h3&gt;

&lt;p&gt;When you sign out, the app should tell the provider to throw its refresh token away (the revocation endpoint, RFC 7009). A confidential client must authenticate there too (§2.1), so nobody else can revoke the app's tokens in its name.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the client secret does not do
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It doesn't replace PKCE: it says nothing about &lt;strong&gt;which sign-in&lt;/strong&gt; an authorization code belongs to, which is why RFC 9700 recommends PKCE for confidential clients too (§2.1.1).&lt;/li&gt;
&lt;li&gt;It doesn't replace &lt;code&gt;state&lt;/code&gt; or exact redirect URIs: those protect the trip through the browser, where the secret never goes.&lt;/li&gt;
&lt;li&gt;It only works while it stays secret. It must live in the server's environment, never in a repository, a front-end bundle or a mobile app. If it leaks, rotate it at the provider.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Providers also offer stronger ways for a server to prove who it is, such as signing a short assertion with a private key instead of sending a shared secret (&lt;code&gt;private_key_jwt&lt;/code&gt;, RFC 7523 and OpenID Connect Core §9) or mutual TLS (RFC 8705). The idea is the same: the token endpoint only talks to the real app.&lt;/p&gt;

&lt;h2&gt;
  
  
  So does a mobile app need a BFF?
&lt;/h2&gt;

&lt;p&gt;Not necessarily. The standard way for mobile apps (RFC 8252, &lt;em&gt;OAuth 2.0 for Native Apps&lt;/em&gt;) is a public client: no secret, PKCE, and the login done in the phone's system browser. A phone has what a browser doesn't: &lt;strong&gt;secure storage&lt;/strong&gt; (the Keychain on iOS, the Keystore on Android), where other apps and web pages can't read the tokens. And without a secret, the refresh token is protected by &lt;strong&gt;rotation&lt;/strong&gt;: each refresh returns a new refresh token and invalidates the old one, so a stolen copy stops working as soon as either side uses it (RFC 9700, §2.2.2).&lt;/p&gt;

&lt;p&gt;A backend for a mobile app is still a valid choice when you want a confidential client: the tokens never on the phone, or a provider that only gives long-lived refresh tokens to clients with a secret. It's a choice, not a requirement. In the browser the case for a BFF is much stronger, because a browser has no storage that the page's own JavaScript can't read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;With the right redirect URI and PKCE, the authorization code is safe. The client secret protects what comes &lt;strong&gt;after&lt;/strong&gt; it: the refresh token that keeps you signed in for weeks, the revocation that ends it, and the provider's certainty that it is talking to the real app. That's also why it only makes sense on a server, which is exactly what a BFF is.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;RFC 6749, &lt;em&gt;The OAuth 2.0 Authorization Framework&lt;/em&gt;, §2.1, §2.3, §3.2.1, §6.&lt;/li&gt;
&lt;li&gt;RFC 7009, &lt;em&gt;OAuth 2.0 Token Revocation&lt;/em&gt;, §2.1.&lt;/li&gt;
&lt;li&gt;RFC 8252, &lt;em&gt;OAuth 2.0 for Native Apps&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;RFC 7523, &lt;em&gt;JWT Profile for OAuth 2.0 Client Authentication and Authorization Grants&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;RFC 8705, &lt;em&gt;OAuth 2.0 Mutual-TLS Client Authentication&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;RFC 9700, &lt;em&gt;Best Current Practice for OAuth 2.0 Security&lt;/em&gt;, §2.1.1, §2.2.2.&lt;/li&gt;
&lt;li&gt;OpenID Connect Core 1.0, §9 (client authentication).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>architecture</category>
      <category>authentication</category>
      <category>backend</category>
      <category>security</category>
    </item>
    <item>
      <title>OAuth sign-in with a BFF: exact redirect URIs (and the nonce)</title>
      <dc:creator>Renato D. Prado</dc:creator>
      <pubDate>Tue, 24 Nov 2026 19:25:59 +0000</pubDate>
      <link>https://dev.to/renato_dprado_bbf0901ec/oauth-sign-in-with-a-bff-exact-redirect-uris-and-the-nonce-5f4n</link>
      <guid>https://dev.to/renato_dprado_bbf0901ec/oauth-sign-in-with-a-bff-exact-redirect-uris-and-the-nonce-5f4n</guid>
      <description>&lt;p&gt;In the previous articles we saw how &lt;code&gt;state&lt;/code&gt; stops login CSRF and how PKCE stops a stolen authorization code from being used. This one covers the last piece of the sign-in: &lt;strong&gt;exact redirect URIs&lt;/strong&gt;, which stop an authorization code from being sent to the wrong place. At the end, a word on the &lt;code&gt;nonce&lt;/code&gt;, which you'll see in every OpenID Connect sign-in. The app is the same as before: a BFF (backend for frontend) runs the sign-in and keeps the tokens on the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  The attacks so far
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Attack&lt;/th&gt;
&lt;th&gt;What the attacker does&lt;/th&gt;
&lt;th&gt;What catches it&lt;/th&gt;
&lt;th&gt;Article&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Login CSRF&lt;/td&gt;
&lt;td&gt;Gets &lt;strong&gt;your&lt;/strong&gt; browser to make the callback request with &lt;strong&gt;their&lt;/strong&gt; authorization code and &lt;strong&gt;their&lt;/strong&gt; &lt;code&gt;state&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;state&lt;/code&gt;: your browser never saved their &lt;code&gt;state&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;first&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Authorization code injection&lt;/td&gt;
&lt;td&gt;Makes the callback request in &lt;strong&gt;their&lt;/strong&gt; browser, with &lt;strong&gt;their&lt;/strong&gt; &lt;code&gt;state&lt;/code&gt; and &lt;strong&gt;your&lt;/strong&gt; stolen authorization code&lt;/td&gt;
&lt;td&gt;PKCE: your authorization code is tied to your challenge, not theirs&lt;/td&gt;
&lt;td&gt;second&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Words used here
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authorization code&lt;/strong&gt;: the one-time ticket the identity provider gives after you log in, which the BFF exchanges for tokens.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redirect URI&lt;/strong&gt;: the app's address the provider sends the browser back to after the login, e.g. &lt;code&gt;https://app.com/callback&lt;/code&gt;. The provider adds the authorization code and the &lt;code&gt;state&lt;/code&gt; to it, so the browser lands on &lt;code&gt;https://app.com/callback?code=ABC&amp;amp;state=X&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The authorization code sent to the wrong place → exact redirect URIs
&lt;/h2&gt;

&lt;p&gt;The app tells the provider where to send the authorization code back: the &lt;code&gt;redirect_uri&lt;/code&gt; parameter in the &lt;code&gt;/authorize&lt;/code&gt; URL (RFC 6749, §4.1.1):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://provider.com/authorize?client_id=app&amp;amp;redirect_uri=https://app.com/callback&amp;amp;state=…&amp;amp;code_challenge=…
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the redirect URI is &lt;code&gt;https://app.com/callback&lt;/code&gt;. The provider sends the authorization code to whatever redirect URI that URL names, as long as it matches what the app registered. If the provider accepts loose matches, an attacker can change it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The app registered &lt;code&gt;https://*.app.com/callback&lt;/code&gt; ("any subdomain of app.com"), and the provider accepts any URL that fits.&lt;/li&gt;
&lt;li&gt;The attacker controls one subdomain: say &lt;code&gt;blog.app.com&lt;/code&gt; still points to an old hosting account that someone else has since taken over (a "subdomain takeover").&lt;/li&gt;
&lt;li&gt;The attacker builds a sign-in link that looks normal, but with &lt;code&gt;redirect_uri=https://blog.app.com/callback&lt;/code&gt;, and gets you to click it.&lt;/li&gt;
&lt;li&gt;You see the provider's &lt;strong&gt;real&lt;/strong&gt; login page and log in as usual (or you're already logged in there, and nothing even shows).&lt;/li&gt;
&lt;li&gt;The provider sends &lt;strong&gt;your&lt;/strong&gt; authorization code to &lt;code&gt;blog.app.com&lt;/code&gt;, which is the attacker's server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Notice what the attacker never needed: your password. You typed it yourself, on the real page. The attacker only bent the address the result goes to. Without a BFF, a client with no secret, they can often exchange that code for your tokens right away; with a BFF it's harder, but an authorization code should never reach a stranger in the first place.&lt;/p&gt;

&lt;p&gt;This is "insufficient redirect URI validation" (RFC 9700, §4.1). The fix is simple: the app registers its &lt;strong&gt;exact&lt;/strong&gt; callback URLs, and the provider compares them &lt;strong&gt;character by character&lt;/strong&gt; (RFC 9700, §2.1). If only &lt;code&gt;https://app.com/auth/callback&lt;/code&gt; is registered, then &lt;code&gt;https://blog.app.com/callback&lt;/code&gt;, &lt;code&gt;https://app.com/other/page&lt;/code&gt;, and even &lt;code&gt;https://app.com/auth/callback/&lt;/code&gt; with a trailing slash are all refused.&lt;/p&gt;

&lt;h2&gt;
  
  
  And the nonce?
&lt;/h2&gt;

&lt;p&gt;If you've read about OpenID Connect, you've seen a &lt;code&gt;nonce&lt;/code&gt; ("number used once") in the &lt;code&gt;/authorize&lt;/code&gt; URL. It's a random value the app creates for each sign-in; the provider copies it into the ID token (the token that tells the app who logged in), and the app checks that the ID token carries the nonce of &lt;strong&gt;this&lt;/strong&gt; sign-in (OpenID Connect Core, §3.1.2.1 and §3.1.3.7).&lt;/p&gt;

&lt;p&gt;Its main job today is stopping the authorization code injection from the previous article: your stolen authorization code brings back an ID token with &lt;strong&gt;your&lt;/strong&gt; sign-in's nonce, which doesn't match the attacker's sign-in, so the app throws away all the tokens. &lt;strong&gt;PKCE already stops that attack&lt;/strong&gt;, so with PKCE the nonce adds little. RFC 9700 treats the two as alternatives, not layers (§2.1.1).&lt;/p&gt;

&lt;p&gt;So why does it exist? History. OpenID Connect (2014) came before PKCE (2015), and PKCE was first meant for mobile apps; web apps with a server used the nonce. The nonce also came from older flows that put the ID token straight in the redirect URL, where it could be swapped. And there is one real difference: the app checks the nonce &lt;strong&gt;by itself&lt;/strong&gt;, while PKCE only works if the provider supports and enforces it. A provider that doesn't know PKCE silently ignores the &lt;code&gt;code_challenge&lt;/code&gt;. Today the advice is PKCE for every client; most libraries send the nonce too, since it costs nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary: all three attacks
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Attack&lt;/th&gt;
&lt;th&gt;What the attacker does&lt;/th&gt;
&lt;th&gt;What catches it&lt;/th&gt;
&lt;th&gt;Article&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Login CSRF&lt;/td&gt;
&lt;td&gt;Gets &lt;strong&gt;your&lt;/strong&gt; browser to make the callback request with &lt;strong&gt;their&lt;/strong&gt; authorization code and &lt;strong&gt;their&lt;/strong&gt; &lt;code&gt;state&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;state&lt;/code&gt;: your browser never saved their &lt;code&gt;state&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;first&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Authorization code injection&lt;/td&gt;
&lt;td&gt;Makes the callback request in &lt;strong&gt;their&lt;/strong&gt; browser, with &lt;strong&gt;their&lt;/strong&gt; &lt;code&gt;state&lt;/code&gt; and &lt;strong&gt;your&lt;/strong&gt; stolen authorization code&lt;/td&gt;
&lt;td&gt;PKCE: your authorization code is tied to your challenge, not theirs&lt;/td&gt;
&lt;td&gt;second&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Authorization code sent to the wrong place&lt;/td&gt;
&lt;td&gt;Gets the provider to send &lt;strong&gt;your&lt;/strong&gt; authorization code to an address they control, through a loosely matched redirect URI&lt;/td&gt;
&lt;td&gt;Exact redirect URIs: the provider only sends authorization codes to addresses registered character by character&lt;/td&gt;
&lt;td&gt;this one&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;OpenID Connect Core 1.0, §3.1.2.1 and §3.1.3.7 (&lt;code&gt;nonce&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;RFC 9700, &lt;em&gt;Best Current Practice for OAuth 2.0 Security&lt;/em&gt;, §2.1, §2.1.1, §4.1.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>architecture</category>
      <category>authentication</category>
      <category>backend</category>
      <category>security</category>
    </item>
    <item>
      <title>OAuth sign-in with a BFF: redirects and PKCE explained</title>
      <dc:creator>Renato D. Prado</dc:creator>
      <pubDate>Tue, 24 Nov 2026 18:50:29 +0000</pubDate>
      <link>https://dev.to/renato_dprado_bbf0901ec/oauth-sign-in-with-a-bff-redirects-and-pkce-explained-3354</link>
      <guid>https://dev.to/renato_dprado_bbf0901ec/oauth-sign-in-with-a-bff-redirects-and-pkce-explained-3354</guid>
      <description>&lt;p&gt;In the previous article we saw how CSRF works and how OAuth's &lt;code&gt;state&lt;/code&gt; parameter stops an attacker from signing you into their account. But &lt;code&gt;state&lt;/code&gt; is not the only thing that can go wrong in an OAuth sign-in. This article covers the next one: a &lt;strong&gt;stolen authorization code&lt;/strong&gt;, and the tool that stops it, PKCE, with its &lt;strong&gt;verifier&lt;/strong&gt; and &lt;strong&gt;challenge&lt;/strong&gt;. Along the way we'll answer two questions that confuse almost everyone the first time: what a 302 really does, and why the server can't simply call the identity provider itself.&lt;/p&gt;

&lt;p&gt;This time the app has a &lt;strong&gt;BFF&lt;/strong&gt; (backend for frontend): a small server that sits between the browser and everything else. A BFF is not required for the sign-in to &lt;strong&gt;work&lt;/strong&gt;: a single-page app can run the whole sign-in by itself, with the same &lt;code&gt;state&lt;/code&gt; and PKCE. But it makes it &lt;strong&gt;safer&lt;/strong&gt;: the secrets stay on the server, the browser only gets an &lt;code&gt;HttpOnly&lt;/code&gt; session cookie holding a random id, and as a server the BFF can hold a client secret, which a browser can't. Why keeping tokens away from JavaScript matters is the subject of a later article. In OAuth terms the BFF is the &lt;strong&gt;client&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Words used here
&lt;/h2&gt;

&lt;p&gt;"Code" and "token" mean many things in this area, so here is exactly what each word means in this article:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authorization code&lt;/strong&gt;: a one-time ticket the identity provider gives after you log in. It is not a token and grants nothing by itself; it can only be exchanged for tokens, once, within a few minutes (RFC 6749 recommends at most 10, §4.1.2). Whenever this article says "code" alone, it means this.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access token&lt;/strong&gt;: a short-lived key (usually minutes to an hour) that lets whoever holds it call the API in your name, limited to what you allowed. The API checks it on every request and doesn't care who presents it, which is why it must not leak.&lt;/li&gt;
&lt;li&gt;Not covered here: the code the provider may email or text you to log in. That is part of &lt;em&gt;how you log in&lt;/em&gt; at the provider and has nothing to do with OAuth.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What a 302 is
&lt;/h2&gt;

&lt;p&gt;A server can't move your browser anywhere. It can only answer the request the browser sent. When it wants the browser to go somewhere else, it answers with status &lt;strong&gt;302 Found&lt;/strong&gt; and a &lt;code&gt;Location&lt;/code&gt; header holding the new URL (RFC 9110, §15.4.3). The browser reads that answer and immediately sends a new request to that URL, on its own, without the user doing anything. That is all a "redirect" is: an answer that says "ask over there instead".&lt;/p&gt;

&lt;p&gt;So in an OAuth sign-in, when we say "the BFF sends you to the identity provider", what really happens is: the browser asks the BFF, the BFF answers 302 with the provider's URL, and the browser goes there by itself. The BFF never talks to the provider in that step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the BFF can't just call the identity provider
&lt;/h2&gt;

&lt;p&gt;If the BFF is a server and the identity provider is a server, why not have them talk directly and skip the browser?&lt;/p&gt;

&lt;p&gt;Because the whole point of OAuth is that &lt;strong&gt;your credentials go only to the identity provider&lt;/strong&gt;. You type your password (or a one-time login code, or use a passkey) on the provider's own page, in your own browser. The app never sees them (RFC 6749, §1). The provider also needs your browser for things only it can do: show its login page, ask for a second factor, ask for your consent, and set its own session cookie so you don't have to log in again on the next app (single sign-on).&lt;/p&gt;

&lt;p&gt;There is an old way that skips the browser: the app collects your username and password and sends them to the provider's token endpoint (the "resource owner password credentials" grant). It hands your password to the app, so the OAuth Security Best Current Practice says it &lt;strong&gt;must not&lt;/strong&gt; be used (RFC 9700, §2.4).&lt;/p&gt;

&lt;p&gt;So the sign-in always has two kinds of trips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Front channel&lt;/strong&gt;: through the browser, with redirects. Anything here travels in URLs, so it can end up in browser history, server logs, or a malicious extension.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Back channel&lt;/strong&gt;: a direct server-to-server call from the BFF to the provider. The browser doesn't see it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep that split in mind: PKCE is built on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The flow, step by step
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The browser asks the BFF to sign in: &lt;code&gt;GET /auth/signin&lt;/code&gt;. The request carries nothing special.&lt;/li&gt;
&lt;li&gt;The BFF creates two random values: &lt;code&gt;state&lt;/code&gt; (from the previous article) and a PKCE &lt;code&gt;code_verifier&lt;/code&gt;. It computes &lt;code&gt;code_challenge = SHA-256(code_verifier)&lt;/code&gt;, keeps &lt;code&gt;state&lt;/code&gt; and the verifier in server memory, and sets a short-lived cookie in the browser so it can find them again later.&lt;/li&gt;
&lt;li&gt;The BFF answers &lt;strong&gt;302&lt;/strong&gt; to the provider's &lt;code&gt;/authorize&lt;/code&gt; URL, with &lt;code&gt;state&lt;/code&gt; and &lt;code&gt;code_challenge&lt;/code&gt; in it. &lt;strong&gt;The verifier is not in the URL.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The browser follows the redirect. You log in on the provider's page. The provider remembers the &lt;code&gt;code_challenge&lt;/code&gt;, and redirects the browser back to the BFF's callback with a one-time &lt;strong&gt;authorization code&lt;/strong&gt;: &lt;code&gt;/callback?code=ABC&amp;amp;state=…&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The BFF checks &lt;code&gt;state&lt;/code&gt;, then calls the provider's token endpoint &lt;strong&gt;directly&lt;/strong&gt; (back channel) with the authorization code, the &lt;strong&gt;verifier&lt;/strong&gt; and its client secret.&lt;/li&gt;
&lt;li&gt;The provider checks everything and answers with the tokens. The BFF stores them on the server and gives the browser its session cookie.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Steps 3 and 4 are the front channel; step 5 is the back channel. Now let's see what PKCE is for.&lt;/p&gt;

&lt;h2&gt;
  
  
  A stolen authorization code → PKCE
&lt;/h2&gt;

&lt;p&gt;The authorization code travels in a URL (step 4), so it can leak: browser history, a proxy log, a malicious browser extension, a &lt;code&gt;Referer&lt;/code&gt; header. PKCE (pronounced "pixy", RFC 7636) was created for this "authorization code interception attack" (§1). The name says what it does: &lt;strong&gt;Proof Key for Code Exchange&lt;/strong&gt;. When the authorization code is exchanged for tokens, the client must show a proof key, a secret that only the one who started that sign-in has.&lt;/p&gt;

&lt;p&gt;How it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;verifier&lt;/strong&gt; is a long random string the client creates for each sign-in (43 to 128 characters, §4.1). It's a secret, and it stays with the client: with a BFF, in the server's memory, so it never reaches the browser; without a BFF, the app in the browser keeps it (in &lt;code&gt;sessionStorage&lt;/code&gt;) and sends it to the token endpoint itself.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;challenge&lt;/strong&gt; is the verifier's SHA-256 hash, base64url-encoded (§4.2). It goes to the provider in the front channel, in the &lt;code&gt;/authorize&lt;/code&gt; URL (§4.3).&lt;/li&gt;
&lt;li&gt;When the client exchanges the authorization code, it sends the &lt;strong&gt;verifier&lt;/strong&gt; in the back channel (§4.5). The provider hashes it and compares the result with the challenge it received earlier (§4.6). No match, no tokens.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why this is safe: &lt;/p&gt;

&lt;p&gt;The challenge travels in the front channel, in the &lt;code&gt;/authorize&lt;/code&gt; URL the &lt;strong&gt;browser&lt;/strong&gt; opens, so others may see it. But a hash can't be reversed, so seeing it doesn't reveal the verifier, and the verifier never travels in the front channel at all. Someone who steals the authorization code from a URL has the authorization code, maybe the challenge, but not the verifier. Without a BFF, an attacker with access to the browser itself (such as a malicious extension) could read the verifier from &lt;code&gt;sessionStorage&lt;/code&gt;; with a BFF, the verifier never reaches the browser, so not even that works.&lt;/p&gt;

&lt;p&gt;What about the BFF's client secret? It stops a stranger from calling the token endpoint, but it doesn't stop &lt;strong&gt;authorization code injection&lt;/strong&gt; (RFC 9700, §4.5), an attack that goes &lt;strong&gt;through&lt;/strong&gt; the BFF. The key detail: when the provider issues an authorization code, it &lt;strong&gt;stores the challenge it received in that same sign-in together with the code&lt;/strong&gt; (RFC 7636, §4.4). Each authorization code is tied to one challenge. Now follow both sign-ins in time:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Your sign-in.&lt;/strong&gt; The BFF creates verifier &lt;code&gt;V1&lt;/code&gt;, and the browser takes challenge &lt;code&gt;C1 = hash(V1)&lt;/code&gt; to the provider. You log in. The provider issues your authorization code and records "this code belongs to &lt;code&gt;C1&lt;/code&gt;".&lt;/li&gt;
&lt;li&gt;The attacker steals your authorization code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The attacker's sign-in&lt;/strong&gt;, on the same app, in their own browser. The BFF creates verifier &lt;code&gt;V2&lt;/code&gt;, and challenge &lt;code&gt;C2 = hash(V2)&lt;/code&gt; goes to the provider.&lt;/li&gt;
&lt;li&gt;When the provider redirects the attacker back to the BFF, they replace the authorization code in the callback URL with &lt;strong&gt;yours&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The BFF now exchanges &lt;strong&gt;your&lt;/strong&gt; authorization code together with &lt;strong&gt;&lt;code&gt;V2&lt;/code&gt;&lt;/strong&gt;, the verifier of the attacker's sign-in.&lt;/li&gt;
&lt;li&gt;The provider hashes &lt;code&gt;V2&lt;/code&gt; and gets &lt;code&gt;C2&lt;/code&gt;, but your authorization code belongs to &lt;code&gt;C1&lt;/code&gt;. No match, no tokens.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without PKCE there is no challenge to compare: in step 5 the BFF would exchange your authorization code with its own secret, and the attacker would be signed in &lt;strong&gt;as you&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why &lt;code&gt;state&lt;/code&gt; doesn't catch this.&lt;/strong&gt; It looks a lot like the login CSRF (Cross-Site Request Forgery) from the previous article, which &lt;code&gt;state&lt;/code&gt; did stop. The difference, in two lines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Login CSRF:&lt;/strong&gt; the attacker starts a sign-in in their own browser, logs in with &lt;strong&gt;their&lt;/strong&gt; account, keeps the callback URL with &lt;strong&gt;their&lt;/strong&gt; authorization code, and gets &lt;strong&gt;your&lt;/strong&gt; browser to open it (through a link, an image or a hidden iframe on another site). You end up inside &lt;strong&gt;their&lt;/strong&gt; account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code injection:&lt;/strong&gt; the attacker steals &lt;strong&gt;your&lt;/strong&gt; authorization code, starts a sign-in in their own browser, and at the callback swaps in &lt;strong&gt;your&lt;/strong&gt; stolen authorization code. &lt;strong&gt;They&lt;/strong&gt; end up inside &lt;strong&gt;your&lt;/strong&gt; account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;state&lt;/code&gt; asks one question: &lt;strong&gt;did this browser start this sign-in?&lt;/strong&gt; In login CSRF the answer is no (your browser, their sign-in), so it fails. In code injection the answer is yes (their browser, their sign-in, their valid &lt;code&gt;state&lt;/code&gt;), so it passes. PKCE asks a different question, &lt;strong&gt;does this authorization code belong to this sign-in?&lt;/strong&gt;, and in code injection the answer is no.&lt;/p&gt;

&lt;p&gt;In neither attack does the attacker handle a token: the app exchanges the authorization code itself. (RFC 6749 §10.12 also mentions injecting an "access token": that comes from the old &lt;em&gt;implicit&lt;/em&gt; flow, which put the access token straight in the redirect URL. RFC 9700 advises against it (§2.1.2) and OAuth 2.1 drops it.)&lt;/p&gt;

&lt;p&gt;That's why RFC 9700 recommends PKCE for every client, servers included (§2.1.1).&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;PKCE and &lt;code&gt;state&lt;/code&gt; are not the whole story. Two more things can go wrong in this flow: a &lt;strong&gt;replayed ID token&lt;/strong&gt;, stopped by the &lt;code&gt;nonce&lt;/code&gt;, and an &lt;strong&gt;authorization code sent to the wrong place&lt;/strong&gt;, stopped by exact redirect URIs. That's the next article.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;RFC 6749, &lt;em&gt;The OAuth 2.0 Authorization Framework&lt;/em&gt;, §1, §4.1.2.&lt;/li&gt;
&lt;li&gt;RFC 7636, &lt;em&gt;Proof Key for Code Exchange by OAuth Public Clients&lt;/em&gt;, §1, §4.1–4.6.&lt;/li&gt;
&lt;li&gt;RFC 9110, &lt;em&gt;HTTP Semantics&lt;/em&gt;, §15.4.3 (302 Found).&lt;/li&gt;
&lt;li&gt;RFC 9700, &lt;em&gt;Best Current Practice for OAuth 2.0 Security&lt;/em&gt;, §2.1.1, §2.4, §4.5.&lt;/li&gt;
&lt;li&gt;IETF draft &lt;em&gt;OAuth 2.0 for Browser-Based Applications&lt;/em&gt; (the BFF pattern).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>architecture</category>
      <category>authentication</category>
      <category>backend</category>
      <category>security</category>
    </item>
    <item>
      <title>CSRF Explained</title>
      <dc:creator>Renato D. Prado</dc:creator>
      <pubDate>Tue, 24 Nov 2026 18:07:39 +0000</pubDate>
      <link>https://dev.to/renato_dprado_bbf0901ec/csrf-explained-2akp</link>
      <guid>https://dev.to/renato_dprado_bbf0901ec/csrf-explained-2akp</guid>
      <description>&lt;h1&gt;
  
  
  When your browser works for the attacker
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What CSRF is
&lt;/h2&gt;

&lt;p&gt;Cross-Site Request Forgery (CSRF) is an attack that makes &lt;strong&gt;your own browser&lt;/strong&gt; send a request you never meant to send, to a site where you are already signed in. It works because of one simple browser rule: when the browser sends a request to &lt;code&gt;bank.com&lt;/code&gt;, it attaches the cookies it holds for &lt;code&gt;bank.com&lt;/code&gt;, no matter &lt;strong&gt;which page started the request&lt;/strong&gt;. It could be a tab on &lt;code&gt;bank.com&lt;/code&gt;, or a page on &lt;code&gt;evil.com&lt;/code&gt;. If the bank recognizes you by a session cookie, every request your browser sends there carries your identity, and the server can't tell "the user clicked a button on our site" from "another site made the browser send this".&lt;/p&gt;

&lt;p&gt;Here is the classic example. You are signed in to your bank, and in another tab you open a page on &lt;code&gt;evil.com&lt;/code&gt;. That page contains a hidden form pointing to &lt;code&gt;https://bank.com/transfer&lt;/code&gt;, with the fields &lt;code&gt;to=attacker&lt;/code&gt; and &lt;code&gt;amount=1000&lt;/code&gt;, plus one line of JavaScript that submits it as soon as the page loads. Your browser sends the POST &lt;strong&gt;with your bank cookie&lt;/strong&gt;, the bank sees a valid session, and the money moves. The attacker never saw your password or your cookie, and never read the bank's answer. They didn't need to: the goal was the action itself, not the data. That is also why CORS doesn't help. CORS only decides whether a page may &lt;em&gt;read&lt;/em&gt; a response from another site; the forged request has already been sent and processed.&lt;/p&gt;

&lt;p&gt;There is also an inverted version, called &lt;strong&gt;login CSRF&lt;/strong&gt;: instead of acting inside your account, the attacker signs you into &lt;strong&gt;theirs&lt;/strong&gt;, without you noticing. It sounds harmless until you think about what people do after signing in: save a credit card, upload a document, write notes. All of it lands in an account the attacker controls and can read later. This variant matters a lot for "Sign in with…" buttons, which brings us to OAuth.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSRF in OAuth
&lt;/h2&gt;

&lt;p&gt;In OAuth 2.0 / OpenID Connect sign-in, the app sends you to the identity provider (Google, Microsoft, your company's login server). After you log in there, the provider redirects your browser back to the app with a one-time &lt;strong&gt;authorization code&lt;/strong&gt; in the URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://app.com/callback?code=ABC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The app exchanges that code for tokens and signs you in. The attack goes like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The attacker starts a normal sign-in &lt;strong&gt;on their own machine, with their own account&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;At the last step they stop the browser from following the redirect and copy the URL, with the code still unused: &lt;code&gt;https://app.com/callback?code=ABC&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;They get you to open that URL: a link, an image tag, a hidden iframe.&lt;/li&gt;
&lt;li&gt;The app exchanges &lt;code&gt;ABC&lt;/code&gt; and signs you in &lt;strong&gt;as the attacker&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This isn't hypothetical; the OAuth 2.0 spec itself describes it (RFC 6749, §10.12):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"A CSRF attack against the client's redirection URI allows an attacker to inject its own authorization code or access token, which can result in the client using an access token associated with the attacker's protected resources rather than the victim's (e.g., save the victim's bank account information to a protected resource controlled by the attacker)."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to protect OAuth sign-in
&lt;/h2&gt;

&lt;p&gt;The examples below use the simplest setup: a single-page app that does the whole sign-in itself, running in your browser. In OAuth terms that application is the &lt;strong&gt;client&lt;/strong&gt;; the browser is only the &lt;em&gt;user-agent&lt;/em&gt; that runs it (RFC 6749, §2.1).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The &lt;code&gt;state&lt;/code&gt; parameter.&lt;/strong&gt; Before sending the browser to the identity provider, the app generates a random value (&lt;code&gt;crypto.getRandomValues&lt;/code&gt;), saves it in &lt;code&gt;sessionStorage&lt;/code&gt;, and puts it in the authorization request. The provider sends it back unchanged on the callback. The callback page compares it with the saved one and stops if they differ.&lt;/p&gt;

&lt;p&gt;How this stops the attack, step by step:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The attacker starts the sign-in in &lt;strong&gt;their&lt;/strong&gt; browser. The app there saves a random &lt;code&gt;state&lt;/code&gt;, say &lt;code&gt;X7f…&lt;/code&gt;, in the attacker's &lt;code&gt;sessionStorage&lt;/code&gt;, and the provider later redirects to &lt;code&gt;https://app.com/callback?code=ABC&amp;amp;state=X7f…&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The attacker copies that URL and gets you to open it.&lt;/li&gt;
&lt;li&gt;The callback page now runs in &lt;strong&gt;your&lt;/strong&gt; browser and looks in &lt;strong&gt;your&lt;/strong&gt; &lt;code&gt;sessionStorage&lt;/code&gt; for the saved &lt;code&gt;state&lt;/code&gt;. There is none (you never started a sign-in), or there is a different one (your own sign-in). Either way it doesn't match &lt;code&gt;X7f…&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The app stops right there. It never sends &lt;code&gt;ABC&lt;/code&gt; to the provider, so you are never signed in to the attacker's account.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The attacker can't get around this by planting &lt;code&gt;X7f…&lt;/code&gt; in your browser: &lt;code&gt;sessionStorage&lt;/code&gt; lives in your browser, which keeps a separate box for each site. Only pages from &lt;code&gt;app.com&lt;/code&gt; can read or write &lt;code&gt;app.com&lt;/code&gt;'s box, so a page from &lt;code&gt;evil.com&lt;/code&gt; can't plant a value there (the browser's same-origin policy). And they can't guess the value you saved, because it is random and new on every sign-in.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;state&lt;/code&gt; closes the CSRF hole in OAuth sign-in, but it is not the only thing that can go wrong in this flow: a stolen authorization code, a replayed token, a redirect sent to the wrong place. Those are different attacks with different fixes, and they are the subject of the next article.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;RFC 6749, &lt;em&gt;The OAuth 2.0 Authorization Framework&lt;/em&gt;, §2.1 (client types) and §10.12 (CSRF).&lt;/li&gt;
&lt;li&gt;A. Barth, C. Jackson, J. C. Mitchell, &lt;em&gt;Robust Defenses for Cross-Site Request Forgery&lt;/em&gt;, ACM CCS 2008.&lt;/li&gt;
&lt;li&gt;OWASP, &lt;em&gt;Cross-Site Request Forgery Prevention Cheat Sheet&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cybersecurity</category>
      <category>infosec</category>
      <category>security</category>
    </item>
    <item>
      <title>Agentic AI - Part 1: foundations</title>
      <dc:creator>Renato D. Prado</dc:creator>
      <pubDate>Wed, 13 May 2026 20:01:23 +0000</pubDate>
      <link>https://dev.to/renato_dprado_bbf0901ec/agentic-ai-part-1-foundations-40ga</link>
      <guid>https://dev.to/renato_dprado_bbf0901ec/agentic-ai-part-1-foundations-40ga</guid>
      <description>&lt;h1&gt;
  
  
  Agentic AI: a tech lead's glossary
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Study notes from coursers like Pluralsight on agentic AI and other references, organized as a glossary I wish I'd had on day one.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every dev I know is using AI tools, and most of us are fuzzy on the words behind them. Where does a transformer fit in? What does MCP actually solve? Is "agentic AI" a real thing or just rebranded chatbots?&lt;/p&gt;

&lt;p&gt;This is my map of the territory: machine learning at the bottom, agents and MCP at the top, and the concepts in between — tokens, memory, tools, RAG, vector databases. Built for lookup, not for a single read-through. If a term is fuzzy in your head, jump to it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Foundations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Machine Learning
&lt;/h3&gt;

&lt;p&gt;Normal coding: you write the rules. &lt;em&gt;"If the email subject says 'free money,' mark it as spam."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Machine learning flips that. You don't write the rules — the program &lt;em&gt;finds&lt;/em&gt; them by trial and error. You give it thousands of emails labeled "spam" or "not spam." For each one, the program guesses the label, compares its guess to the correct answer, and nudges a bunch of internal numbers (its &lt;strong&gt;weights&lt;/strong&gt;) to be a little less wrong. Do that millions of times across thousands of examples, and those weights settle into something useful.&lt;/p&gt;

&lt;p&gt;What does a weight actually &lt;em&gt;look&lt;/em&gt; like? Picture the spam detector keeping a running score for each email. See the word "viagra"? Add 0.8 to the score. Unknown sender? Add 0.5. Lots of exclamation marks? Add 0.2. If the total clears a threshold, the email gets tagged as spam. Those numbers — 0.8, 0.5, 0.2 — are weights. Training is the process of finding what each one should be.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What comes out of training isn't code. It's the model — a file holding all those weights. A simple spam filter might have thousands. An LLM has billions. Hand the model a new email, and it produces a verdict: spam or not.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Want to feel it for yourself? Try Google's &lt;strong&gt;Teachable Machine&lt;/strong&gt; (&lt;a href="https://teachablemachine.withgoogle.com" rel="noopener noreferrer"&gt;teachablemachine.withgoogle.com&lt;/a&gt;). Train an image classifier in your browser with your webcam — show it a few photos of "happy face" vs "sad face" and watch it learn to tell them apart.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where LLMs fit
&lt;/h3&gt;

&lt;p&gt;A few useful distinctions before going further:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AI&lt;/strong&gt; is the broad field — anything where a machine does something we'd call intelligent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Machine learning&lt;/strong&gt; is a subset of AI: systems that learn patterns from data instead of being explicitly programmed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deep learning&lt;/strong&gt; is a subset of ML that uses multi-layer neural networks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLMs&lt;/strong&gt; are a specific application of deep learning, built on the transformer architecture (introduced in 2017).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So: &lt;strong&gt;LLM ⊂ deep learning ⊂ ML ⊂ AI.&lt;/strong&gt; Claude, ChatGPT, Gemini, Llama — all LLMs.&lt;/p&gt;

&lt;p&gt;These terms get used interchangeably, but they're not the same thing. A spam filter and ChatGPT are both AI, both ML, but only one is an LLM.&lt;/p&gt;

&lt;h3&gt;
  
  
  Neural networks and deep learning
&lt;/h3&gt;

&lt;p&gt;A neural network is one specific kind of ML algorithm. Loosely inspired by the brain: layers of nodes connected to each other, every connection carrying one of those weights from before. Input enters on one side, flows through the layers, a prediction comes out. The training loop is the same as before — guess, check, nudge the weights — there are just far more weights to nudge.&lt;/p&gt;

&lt;p&gt;"Deep learning" is just a neural network with many layers — the &lt;em&gt;deep&lt;/em&gt; refers to the layer count.&lt;/p&gt;

&lt;p&gt;Why depth matters: each layer learns a more abstract pattern than the one below it. For image recognition, the first layer might detect edges; the next, shapes; the next, eyes and noses; the next, full faces. For text: letters, then words, then phrases, then meaning. Stack enough layers and the model captures complex patterns.&lt;/p&gt;

&lt;p&gt;The deep learning boom of the 2010s happened because GPUs made training big networks practical, and there was enough digital data to feed them.&lt;/p&gt;

&lt;p&gt;LLMs are deep neural networks. Specifically, ones built on an architecture called the transformer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Transformers — and what makes an LLM different
&lt;/h3&gt;

&lt;p&gt;Earlier language models processed text word by word, in order — slow to train, and they tended to lose track of context across long sentences. The &lt;strong&gt;transformer&lt;/strong&gt;, introduced in a 2017 Google paper called &lt;em&gt;Attention Is All You Need&lt;/em&gt;, fixed both problems with two changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It looks at the whole input at once.&lt;/strong&gt; No more reading sequentially. The model sees the full sequence and processes it in parallel — which also made training scale across GPU clusters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attention pairs every word with the others that matter.&lt;/strong&gt; Think of it like reading with a highlighter, where the highlighting is automatic — learned from training data. For each word in the input, attention scores the others by relevance, weights them, and blends the most important ones into how that word is processed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Concrete example: in &lt;em&gt;"The cat sat on the mat. It was tired,"&lt;/em&gt; when the model reaches &lt;em&gt;"it,"&lt;/em&gt; attention scores &lt;em&gt;"cat"&lt;/em&gt; high and &lt;em&gt;"mat"&lt;/em&gt; low. That's how the model knows &lt;em&gt;"it"&lt;/em&gt; refers back to &lt;em&gt;"cat."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every well-known LLM since runs on this architecture: GPT, Claude, Gemini, Llama. Same core design, just bigger training data and more weights.&lt;/p&gt;

&lt;p&gt;So what's actually different about an LLM compared to the spam filter from earlier?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Generality.&lt;/strong&gt; Old ML: one model per task. An LLM is a single model that handles summarization, code, translation, and reasoning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generation vs. classification.&lt;/strong&gt; Old ML predicts a label or a number ("spam" / "not spam"). LLMs produce text, which lets them do almost anything we can describe in words.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scale.&lt;/strong&gt; Old ML: thousands to millions of weights, single GPU. LLMs: billions of weights, GPU clusters, weeks of training, millions of dollars per training run.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tokens
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;token&lt;/strong&gt; is a chunk of text the model reads — sometimes a full word, sometimes a fragment. &lt;em&gt;"Hello, world"&lt;/em&gt; might become three tokens: &lt;code&gt;Hello&lt;/code&gt;, &lt;code&gt;,&lt;/code&gt;, &lt;code&gt;world&lt;/code&gt;. The word &lt;em&gt;"strawberry"&lt;/em&gt; might split into two: &lt;code&gt;straw&lt;/code&gt;, &lt;code&gt;berry&lt;/code&gt;. Each token is then mapped to a number, and those numbers are what the model actually processes.&lt;/p&gt;

&lt;p&gt;Every model has its own tokenizer (the piece that does the chopping), so the same sentence in GPT, Claude, and Gemini can produce different token counts.&lt;/p&gt;

&lt;p&gt;The practical consequence: &lt;strong&gt;context limits and pricing are measured in tokens, not words.&lt;/strong&gt; A model's &lt;strong&gt;context&lt;/strong&gt; is how much text it can work with at once — its working memory. Rule of thumb: 1 English word ≈ 1.3 tokens.&lt;/p&gt;

&lt;p&gt;Every API charges two things separately: &lt;strong&gt;input tokens&lt;/strong&gt; (everything the model reads — system prompt + conversation history + retrieved memory + tool definitions + the new user message) and &lt;strong&gt;output tokens&lt;/strong&gt; (what the model generates, typically priced higher per token than input).&lt;/p&gt;

&lt;p&gt;Every turn, the entire conversation history gets sent as input. By turn 10, the input includes 9 prior turns plus the new message. Token usage grows with chat length.&lt;/p&gt;




&lt;h2&gt;
  
  
  Agents
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Agentic AI
&lt;/h3&gt;

&lt;p&gt;A regular LLM chat is one prompt in, one response out. &lt;strong&gt;Agentic AI&lt;/strong&gt; turns that into a loop: the LLM picks an action, the system runs it, the result feeds back, the LLM picks again. Actions come from &lt;strong&gt;tools&lt;/strong&gt; — APIs, code execution, file edits, database queries.&lt;/p&gt;

&lt;p&gt;There's a middle ground between chat and a full agent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Workflow&lt;/strong&gt; — a fixed pipeline of LLM calls. The path is hard-coded; the LLM just fills in the steps. &lt;em&gt;Example: classify ticket → summarize → draft reply.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent&lt;/strong&gt; — no fixed path. The LLM is given a goal and a set of tools, picks the next action, observes the result, and picks again. The loop continues until the goal is reached or a stop condition fires (step limit, token limit, failure).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key difference: &lt;em&gt;who decided the next step — a human writing the pipeline, or the LLM at runtime?&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The agent loop
&lt;/h3&gt;

&lt;p&gt;An agent is an &lt;strong&gt;LLM in a loop with tools and memory&lt;/strong&gt;. One cycle:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The agent receives a task.&lt;/li&gt;
&lt;li&gt;The LLM picks what to do next.&lt;/li&gt;
&lt;li&gt;The agent runs a tool, calls an API, writes a file, etc.&lt;/li&gt;
&lt;li&gt;The agent observes the result.&lt;/li&gt;
&lt;li&gt;Back to step 2 with the new information.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You'll see this written different ways — &lt;em&gt;perceive → reason → act → learn&lt;/em&gt;, or &lt;em&gt;plan → act → adapt&lt;/em&gt;. Same loop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Three components
&lt;/h3&gt;

&lt;p&gt;An agent has three:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LLM&lt;/strong&gt; — the reasoning engine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory&lt;/strong&gt; — what the agent remembers across steps and sessions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools&lt;/strong&gt; — what the agent can actually do (call APIs, run code, search files, edit data).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Strip any one and you're back to plain chat.&lt;/p&gt;

&lt;h3&gt;
  
  
  Four characteristics
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Autonomous execution.&lt;/strong&gt; Runs without step-by-step human input.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Goal-oriented.&lt;/strong&gt; Works toward an objective, not a fixed script.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proactivity.&lt;/strong&gt; Initiates actions on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration.&lt;/strong&gt; Can work with other agents (multi-agent systems).&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Memory
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;An LLM has no memory of its own.&lt;/strong&gt; Each call to the model is independent — it doesn't remember anything from the previous call. Any continuity you experience in ChatGPT or Claude comes from the conversation history being passed back in every turn.&lt;/p&gt;

&lt;p&gt;Memory is storage that gets auto-injected into the prompt. When the agent needs context, the system pulls relevant entries from storage and adds them to the prompt before the next LLM call.&lt;/p&gt;

&lt;p&gt;How it works in practice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The agent stores facts somewhere — JSON file, relational database, vector database, a dedicated memory service.&lt;/li&gt;
&lt;li&gt;Each turn, the system retrieves whatever matches the current question (recent messages, facts about the user, prior decisions).&lt;/li&gt;
&lt;li&gt;The retrieved content gets prepended or inserted into the prompt.&lt;/li&gt;
&lt;li&gt;The LLM sees it as context, no different from anything else in the prompt.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two kinds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Short-term&lt;/strong&gt; — the conversation so far. The running list of messages passed each turn.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long-term&lt;/strong&gt; — facts kept across sessions. ChatGPT's memory feature is the consumer example: tell it your favorite dish, come back next week, and it remembers — because &lt;em&gt;"user's favorite dish is feijoada"&lt;/em&gt; got stored and gets injected the next time you ask.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Compressing history
&lt;/h3&gt;

&lt;p&gt;Memory has a hard limit: the model's context window. Once a chat grows past that, something has to give — either older messages get dropped (the agent forgets) or they get compressed.&lt;/p&gt;

&lt;p&gt;Agent systems handle this automatically. As the conversation approaches the context limit, the system makes a separate LLM call to summarize older messages, then carries the summary forward in place of the raw history. The LLM keeps working without hitting the wall.&lt;/p&gt;

&lt;p&gt;Side effect: every future turn sends fewer tokens, which lowers cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;tool&lt;/strong&gt; is something the agent can do beyond producing text. The LLM outputs &lt;em&gt;"call tool X with these arguments,"&lt;/em&gt; the system runs it, and the result feeds back into the next LLM call.&lt;/p&gt;

&lt;p&gt;Common tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File operations (create, edit, delete, search)&lt;/li&gt;
&lt;li&gt;Web search&lt;/li&gt;
&lt;li&gt;API calls&lt;/li&gt;
&lt;li&gt;PDF parsing&lt;/li&gt;
&lt;li&gt;Code execution&lt;/li&gt;
&lt;li&gt;Database queries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In API terms, this is called &lt;strong&gt;tool use&lt;/strong&gt; (Anthropic) or &lt;strong&gt;function calling&lt;/strong&gt; (OpenAI). You declare the available tools to the LLM up front; the model decides when to call them.&lt;/p&gt;

&lt;p&gt;Without tools, the agent only produces text.&lt;/p&gt;

&lt;h3&gt;
  
  
  MCP (Model Context Protocol)
&lt;/h3&gt;

&lt;p&gt;LLMs use tools to take action — file operations, database queries, web searches. Historically, each LLM provider defined its own format for declaring tools (OpenAI function calling, Anthropic tool use, Google function declarations), so the same integration had to be rewritten for each.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MCP&lt;/strong&gt; is an open protocol that standardizes how applications expose tools to LLMs. Anthropic released it in November 2024; OpenAI added support in early 2025.&lt;/p&gt;

&lt;p&gt;Three pieces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MCP Server&lt;/strong&gt; — exposes a set of tools. Examples: a file system server, a Postgres server, a GitHub server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP Client&lt;/strong&gt; — sits inside the LLM application, forwards tool calls to servers, and returns the results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP Host&lt;/strong&gt; — the application the user interacts with (Claude Desktop, Cursor, etc.). It runs the client.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Flow: the user talks to the host → the LLM decides to call a tool → the client routes the call to the right server → the server runs it → the result feeds back into the LLM.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://modelcontextprotocol.io" rel="noopener noreferrer"&gt;modelcontextprotocol.io&lt;/a&gt;. Community-built servers are listed on GitHub.&lt;/p&gt;

&lt;h3&gt;
  
  
  RAG (Retrieval-Augmented Generation)
&lt;/h3&gt;

&lt;p&gt;An LLM only knows what it was trained on, up to a cutoff date. Events from last week, your company's internal docs, today's stock prices — none of it is in the model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RAG&lt;/strong&gt; is the pattern of fetching relevant information from outside the model and injecting it into the prompt before the LLM generates its answer.&lt;/p&gt;

&lt;p&gt;How it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The system detects that the question needs information the model doesn't have.&lt;/li&gt;
&lt;li&gt;It queries an external source — web search, a vector database, a file system, an API.&lt;/li&gt;
&lt;li&gt;The relevant chunks of content come back.&lt;/li&gt;
&lt;li&gt;Those chunks get inserted into the prompt as context.&lt;/li&gt;
&lt;li&gt;The LLM answers using the fresh content.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example: asking Claude &lt;em&gt;"who won last weekend's F1 race?"&lt;/em&gt; — the model doesn't know. Enable web search, the system retrieves a result page, passes the content to the model, and the model answers from the retrieved text.&lt;/p&gt;

&lt;h3&gt;
  
  
  RAG challenges
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Irrelevant retrieval&lt;/strong&gt; — the system pulls back content that doesn't help, and the LLM answers off-topic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chunking&lt;/strong&gt; — long documents have to be split into pieces small enough to fit the prompt while preserving meaning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access control&lt;/strong&gt; — when the source contains private data, the system has to respect permissions. The model shouldn't see what the user shouldn't.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Vector databases
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;vector database&lt;/strong&gt; stores text (or images, or other data) as arrays of numbers, then lets you search by similarity instead of exact match.&lt;/p&gt;

&lt;p&gt;The numbers come from an &lt;strong&gt;embedding model&lt;/strong&gt;. Feed it text (or an image, or audio) and it returns a list of numbers — typically hundreds to thousands of them — that captures the meaning of the input. Think of each embedding as a coordinate in a high-dimensional space where similar things sit close together.&lt;/p&gt;

&lt;p&gt;Two examples to make this concrete:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The embeddings for &lt;em&gt;"cat"&lt;/em&gt; and &lt;em&gt;"dog"&lt;/em&gt; sit close together. &lt;em&gt;"Helicopter"&lt;/em&gt; is far from both.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;"How do I reset my password?"&lt;/em&gt; and &lt;em&gt;"I forgot my login"&lt;/em&gt; sit close together, even though they share no words.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A vector database stores those coordinates and answers queries by returning the entries closest to your input.&lt;/p&gt;

&lt;p&gt;Concrete use case: a company chatbot that answers questions from internal docs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setup (one time):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Break the company wiki into chunks (paragraphs, sections, whatever fits).&lt;/li&gt;
&lt;li&gt;Run each chunk through an embedding model. Get back one vector per chunk.&lt;/li&gt;
&lt;li&gt;Store the chunks alongside their vectors in a vector database (Pinecone, Chroma, pgvector).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Query time (every user message):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The user asks: &lt;em&gt;"How do I file expense reports?"&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;You embed the question with the same embedding model.&lt;/li&gt;
&lt;li&gt;The database returns the chunks whose vectors are closest to the question vector — say, the top 5.&lt;/li&gt;
&lt;li&gt;Those chunks get injected into the LLM prompt: &lt;em&gt;"Use this context to answer: [chunks]. Question: How do I file expense reports?"&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;The LLM answers using the retrieved content.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Common vector databases: Pinecone, Weaviate, Chroma, Milvus, pgvector (a Postgres extension).&lt;/p&gt;




&lt;h2&gt;
  
  
  To be continued
&lt;/h2&gt;

&lt;p&gt;Part 1 covers the foundations: ML, transformers, tokens, agents, memory, tools, MCP, RAG, vector databases.&lt;/p&gt;

&lt;p&gt;Part 2 will cover the applied side — agentic coding, global rules and CLAUDE.md, vibe coding vs context engineering, multi-agent systems, guardrails, observability, and CI/CD with agents.&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>llm</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>TechMag 1 - May 1</title>
      <dc:creator>Renato D. Prado</dc:creator>
      <pubDate>Tue, 12 May 2026 15:43:08 +0000</pubDate>
      <link>https://dev.to/renato_dprado_bbf0901ec/techmag-1-may-26-5anl</link>
      <guid>https://dev.to/renato_dprado_bbf0901ec/techmag-1-may-26-5anl</guid>
      <description>&lt;p&gt;&lt;em&gt;The work moved. The craft didn't.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A weekly read for devs, tech leads, and anyone keeping up with where AI is taking software engineering..&lt;/p&gt;

&lt;h2&gt;
  
  
  Try This Week
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;How to keep up&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The New Senior Engineer
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Chris Parsons — chrismdp.com&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Less reviewing, more training.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you're still tied to your IDE, you're working a year behind. The 2026 toolchain recommendation: install Claude Code or Codex CLI, not Copilot. The senior engineer's job has shifted from writing code or reviewing diffs to training the AI to write better code.&lt;/p&gt;

&lt;p&gt;The central point: the harness around the model matters as much as the model itself. Leverage lives in standing instructions in AGENTS.md or CLAUDE.md and in skill files that teach the agent your conventions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How fast you can tell whether the output is right separates teams that ship from teams stuck&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;As Chris puts it: "Coding with AI is now the default. The question is whether you are doing it as a reviewer, a prompter, or a trainer. The trainer role compounds."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.chrismdp.com/coding-with-ai/" rel="noopener noreferrer"&gt;Read more...&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Harness
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Henrique Bastos — blog post&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Some teams keep getting better. Others run in place forever.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The difference is whether they've built a harness — something that turns repetitive work into a loop.&lt;/p&gt;

&lt;p&gt;Most processes are designed from scratch every time, with context living in someone's head. Each run costs the same as the first. &lt;strong&gt;In a loop, each run leaves things ready for the next. Starting again is almost free.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AI made this personal. When an agent produces garbage, the instinct is to fix the prompt. But that fix dies with the session. The real move is to fix the environment — add a test, tighten a boundary, write a rule. That fix sticks. Every future run inherits it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/pulse/making-sense-harness-engineering-henrique-bastos-ezotf/" rel="noopener noreferrer"&gt;Read more...&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Quality &amp;amp; Craft
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;How to think well in the AI era.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Below the Illusion of Progress
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Kent Beck — LinkedIn&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The new failure mode: When the code looks fine but isn't.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Most teams get through problems in a messy way — without really solving them. The result is &lt;strong&gt;software that mostly works, but is hard to change. Not great, but it holds.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There's a worse state: when it becomes possible to &lt;strong&gt;claim things are working when they aren't&lt;/strong&gt;, as AI tools do. Complexity builds, and progress slows down.&lt;/p&gt;

&lt;p&gt;No clear solution yet for working with AI here. Better data, tests, prompting — all might help, but none is enough. The first step is awareness.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/posts/kentbeck_most-teams-muddle-software-that-mostly-works-activity-7455790619098275840-uAW6" rel="noopener noreferrer"&gt;Read more...&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Principles Don't Change
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Robert C. Martin — X/Twitter&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;AI raises the level of abstraction — it doesn't change software engineering.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Uncle Bob Martin has been on a roll lately, and his core message is consistent: &lt;strong&gt;AI doesn't change software engineering — it just raises the level of abstraction.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"AI is just another step up the semantic expression ladder. We initially expressed our semantics in binary, then assembler, then Fortran, then C, then Java, then Python. AI is just the next step up that same old ladder."&lt;/p&gt;

&lt;p&gt;What we're losing is syntax — semicolons, braces — and good riddance. What stays is everything that actually matters: design, architecture, formalism, behavioral and structural semantics. Objects still matter (the AI is literally generating them). Principles from decades ago still apply.&lt;/p&gt;

&lt;p&gt;His warning to engineers: a few disciplines and tools aren't enough. You still need a mental model of what the AI is doing, the engineering insight to correct it, and the instinct to form suspicions and verify them — without falling back on exhaustive code reviews.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://x.com/unclebobmartin" rel="noopener noreferrer"&gt;Read more...&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creation Cost Approaching Zero
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Kent Beck — LinkedIn&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If anyone can clone your software with an AI, what happens to scale?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Software used to work like this: one person spends a long time building something great, and then millions of people use that same thing. The work pays off because it's spread across a huge number of users.&lt;/p&gt;

&lt;p&gt;AI may break this. Maybe people will be able to ask an AI to clone your software. &lt;strong&gt;So instead of everyone using your version, you get multiple near-identical copies floating around — and you never reach the scale you used to.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But here's the twist: building software is also cheaper now. You didn't spend as much time on it either. So maybe it doesn't matter that you have fewer users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/posts/kentbeck_ever-since-data-communication-became-free-activity-7453970638148370432-4wW4" rel="noopener noreferrer"&gt;Read more...&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Worth Knowing
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;On the radar this week&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Legacy Code Isn't Going Anywhere
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Vikas Pujar — LinkedIn&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Even when AI nails the headline task, the work around it doesn't disappear.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Vikas Pujar asked Claude how long it would actually take to convert the world's 800 billion lines of COBOL into Java, now that Anthropic claims AI can handle the translation. &lt;strong&gt;The answer: in the best case, 844 years.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The interesting part wasn't the timeline — it was the breakdown. Code translation is only about 20% of the effort. The other 80% is parallel testing, business approvals, regulatory compliance, and deployment — work where AI moves the needle far less.&lt;/p&gt;

&lt;p&gt;A useful reminder that even when AI is genuinely good at the headline task, the work around it doesn't disappear. It seems there's still a long career waiting for anyone willing to do it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/posts/vikaspujar_mainframehumor-activity-7441857962270228481-77r_" rel="noopener noreferrer"&gt;Read more...&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Structured-Prompt-Driven Development
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Wei Zhang — martinfowler.com&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Treating prompts as code — but is it too heavy for most teams?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thoughtworks recently published Structured Prompt-Driven Development (SPDD) on Martin Fowler's site — a method that treats prompts as first-class artifacts: version-controlled, reviewed, and reused. &lt;strong&gt;The core rule is when reality diverges, fix the prompt first, then update the code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's a serious framework, with its own seven-part canvas (REASONS) and a CLI tool (openspdd) to run the workflow.&lt;/p&gt;

&lt;p&gt;But here's the thing: a lot of ways to work with AI are emerging right now, and many of them come from the AI tools themselves — CLAUDE.md, skill files, AGENTS.md. These are lightweight, already integrated into the tools developers actually use, and easy to adopt one piece at a time. Heavyweight methodologies like SPDD might be the right fit for big consultancies and regulated environments, but will most teams actually adopt it — or will the simpler conventions baked into Claude Code or Codex win on adoption alone?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://martinfowler.com/articles/structured-prompt-driven/" rel="noopener noreferrer"&gt;Read more...&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GitHub Opted Everyone Into Training
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Gergely Orosz — LinkedIn&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Your private code is training Microsoft's AI — unless you opt out.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Gergely Orosz raised the alarm: &lt;strong&gt;GitHub quietly opted every user — paying customers included — into letting their private code train Microsoft's AI models.&lt;/strong&gt; Pro subscribers, Copilot subscribers, all of it. The opt-out lives under Settings → Privacy, and Orosz's point is sharp: a true platform for code wouldn't do this.&lt;/p&gt;

&lt;p&gt;Worth checking your settings if you haven't already.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/gergelyorosz/" rel="noopener noreferrer"&gt;Read more...&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>career</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
