<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Samuele Illuminati on Medium]]></title>
        <description><![CDATA[Stories by Samuele Illuminati on Medium]]></description>
        <link>https://medium.com/@samuele8?source=rss-d806dacb035b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tBKF242IDmhx30FAnZwRWw.jpeg</url>
            <title>Stories by Samuele Illuminati on Medium</title>
            <link>https://medium.com/@samuele8?source=rss-d806dacb035b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 18:56:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samuele8/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Personal access token rotation in 3scale]]></title>
            <link>https://medium.com/3scale-ninja-toolbook/personal-access-token-rotation-in-3scale-d1f535b3c23f?source=rss-d806dacb035b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1f535b3c23f</guid>
            <category><![CDATA[configuration]]></category>
            <category><![CDATA[access-token]]></category>
            <category><![CDATA[3scale]]></category>
            <category><![CDATA[webhooks]]></category>
            <dc:creator><![CDATA[Samuele Illuminati]]></dc:creator>
            <pubDate>Mon, 28 Sep 2020 07:17:15 GMT</pubDate>
            <atom:updated>2020-09-29T14:40:02.805Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to rotate 3scale access tokens</h4><p>Co-author: <a href="https://medium.com/@kev.price83">Kev Price</a></p><h3>Summary</h3><p>This guide is meant to show how it is possible to enable “Access token rotation”, allowing 3scale to use temporary Access Tokens that will be invalidated once they have been used for their purpose.</p><p>By the end of this tutorial you should be able to implement a similar setup where the Access token rotation is taken care of completely by 3scale and your external webhook listener service and will take place automatically after a specific event occurs upon which a webhook is triggered.</p><p><strong>Important:</strong> This guide has nothing to do with access tokens used with the 3scale gateway as part of any OAuth or OpenID Connect flows.</p><h3>Example scenario</h3><p>Creating an Application via the 3scale API requires an Access Token to be provided in order for the request to be authorized. Access tokens need Read and Write permissions to the Account Management API and do not expire by default: for this reason the default settings may not be considered secure enough and hence this solution would be applicable.</p><p>It is possible to configure 3scale to revoke (delete) an Access Token that was specifically created to be used against the Application Create endpoint, once the task that it was meant for is finalised.</p><p>This guide demonstrates how this configuration can be implemented for the following scenario: <em>I want my Access Tokens to be single-use, so that after the token is used for creating an Application via the 3scale API it will be automatically revoked.</em></p><h3>Step by step guide</h3><h3>Prerequisites</h3><ul><li>3scale 2.8 On-premises and later OR 3scale SaaS Enterprise</li><li>Webhook listener service (<a href="https://github.com/samugi/3scale-AccessTokenRevoker/tree/demo">example app</a> can be used to follow this tutorial)</li></ul><h3>Setup</h3><p>The following steps should be completed in full before proceeding to the <em>End to End flow in action</em> section. For the purpose of following this tutorial the example app <a href="https://github.com/samugi/3scale-AccessTokenRevoker/tree/demo">AccessTokenRevoker</a> can be used but it’s recommended that you implement your own webhook listener service in the language you prefer.</p><ul><li><a href="https://access.redhat.com/documentation/en-us/red_hat_3scale_api_management/2.9/html/creating_the_developer_portal/custom-signup-fields">Create a custom field definition</a> on the <em>Application</em> object, make it <em>Hidden</em>. Set the <em>Name</em> field and<em> Label</em> field, in this example they will be token_value and Token Value respectively. The <em>Name</em> field is important here because that is the parameter which will be parsed from the webhook object later.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*TO5ti66FXeODwlen-rpmhQ.png" /><figcaption>Creation of a new custom field definition</figcaption></figure><ul><li><a href="https://access.redhat.com/documentation/en-us/red_hat_3scale_api_management/2.9/html/creating_the_developer_portal/webhooks#introducing_webhooks">Configure 3scale webhooks</a> to deliver upon admin portal actions and specifically for the<em> Application created</em> event.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_GgMl4BY6X7Z1um27oaQnw.png" /><figcaption>Webhooks configuration</figcaption></figure><ul><li>Deploy an application running as an external service to 3scale where the 3scale webhooks will be delivered, parsed and that subsequently makes an API call to 3scale to rotate the <em>Access token</em>.</li><li>See the <a href="https://github.com/samugi/3scale-AccessTokenRevoker/blob/demo/README.md">example app instructions</a> to deploy and configure it to follow along with the steps. Here is an example command that can be used to start the example app:</li></ul><pre>node app.js --url &quot;https://{TENANT | ACCOUNT}-admin.{WILDCARD_DOMAIN | 3scale.net}&quot;</pre><ul><li>API call to 3scale should pass the value of the custom field <em>Token Value</em> as both the access_token and id parameters to the <em>Personal Access Token Delete</em> API. Here is an example of a curl request the application should implement in order to successfully revoke the token:</li></ul><pre>curl -X DELETE &quot;https://{TENANT | ACCOUNT}-admin.{WILDCARD_DOMAIN | 3scale.net}/admin/api/personal/access_tokens/${ACCESS_TOKEN}.json&quot; -d &#39;access_token=${ACCESS_TOKEN}&#39;</pre><h3>End to end flow in action</h3><ul><li>Admin user <a href="https://access.redhat.com/documentation/en-us/red_hat_3scale_api_management/2.9/html/admin_portal_guide/tokens#creating-access-tokens">creates an access token</a> with read/write permissions and scope for the Account Management API</li><li>User creates an application from the 3scale API and will be required to add a value to the field created in the <em>Setup </em>section. The value of this field should be equal to the <em>Access Token</em> created in the previous step.</li><li>Here is an example of a curl request to the 3scale API that can be used to create a new application and rotate the token (notice the <em>token_value </em>field is being assigned the <em>Access Token</em> as a value in the request POST data):</li></ul><pre>curl -X POST &quot;https://{TENANT | ACCOUNT}-admin.{WILDCARD_DOMAIN | 3scale.net}/admin/api/accounts/${ACCOUNT_ID}/applications.xml&quot; -d &#39;access_token=${ACCESS_TOKEN}&amp;plan_id=${PLAN_ID}&amp;name=${APPLICATION_NAME}&amp;description=demo&amp;token_value=${ACCESS_TOKEN}&#39;</pre><ul><li>The 3scale webhook will be triggered on the <em>Application created</em> event.</li><li>This is an example of what the webhook’s request body looks like. The token value is visible as part of the extra_fields object in: req.body.event.object[0].application[0].extra_fields[0].token_value[0]</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*b4TCKZqyiSx_Kpuj6CKQag.png" /><figcaption>Webhook object</figcaption></figure><ul><li>The external service listening for 3scale webhooks will receive the object and should parse the body for the custom field defined previously e.g. token_value and then store this value for the API call to 3scale.</li></ul><p>Once the token has been deleted then it will no longer function and cleaning it up from the hidden field on the Application at this point is optional given that the field is configured as <em>hidden</em> at the beginning and is no longer valid.</p><p>Alternatively in the set up phase you can set the custom field definition to <em>required</em> instead of <em>hidden</em> which will prevent the user from creating an application without setting this important field. Bear in mind that by doing this the custom field will be visible by default to developers if they have access to the developer portal and that can pose a security threat while the access token is still valid. As a further step you can ensure that the field is not rendered in HTML by customising the liquid templates in the developer portal. That’s beyond the scope of this article, hence will not be covered.</p><h3>Conclusion</h3><p>In this article you have learned how some of the 3scale features can be combined to form a flow that can be used for access tokens rotation. This is an example of how 3scale users can make use of access tokens to access all the features available via the 3scale API, by still avoiding any security leak thanks to the temporary tokens.</p><h3>What’s next?</h3><p>This workflow can be configured to fit the requirements of the API provider to rotate tokens after any of the supported webhook events are triggered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dz_NoX-tTaXY_6DJ6Sh54g.png" /><figcaption>Available webhook events</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1f535b3c23f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/3scale-ninja-toolbook/personal-access-token-rotation-in-3scale-d1f535b3c23f">Personal access token rotation in 3scale</a> was originally published in <a href="https://medium.com/3scale-ninja-toolbook">3scale-ninja-toolbook</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>