{"id":125796,"date":"2022-06-09T14:00:39","date_gmt":"2022-06-09T14:00:39","guid":{"rendered":"https:\/\/developer.apple.com\/news\/?id=huqjyh7k"},"modified":"2022-06-09T14:00:39","modified_gmt":"2022-06-09T14:00:39","slug":"challenge-private-access-tokens","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2022\/06\/09\/challenge-private-access-tokens\/","title":{"rendered":"Challenge: Private Access Tokens"},"content":{"rendered":"<div class=\"inline-article-image\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2022\/06\/challenge-private-access-tokens.jpg\" data-hires=\"false\" alt><\/div>\n<p>Private Access Tokens are powerful tools that prove when HTTP requests are coming from legitimate devices without disclosing someone&#8217;s identity. This proof can help you reduce how often you show CAPTCHAs to people. They are simple to set up and test \u2014&nbsp;and so we&#8217;re inviting you in this challenge to try out Private Access Tokens on your own server.<\/p>\n<p>Before you begin, be sure to watch &#8220;Replace CAPTCHAs with Private Access Tokens&#8221; for an overview of the feature.<\/p>\n<section class=\"grid activity\">\n<section class=\"row\">\n<section class=\"column large-4 small-4 no-padding-top no-padding-bottom\"> <a href=\"https:\/\/developer.apple.com\/wwdc22\/10077\" class=\"activity-image-link\"> <img decoding=\"async\" class=\"actiity-image medium-scale\" width=\"250\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2022\/06\/challenge-private-access-tokens-1.jpg\" data-hires=\"false\" alt> <\/a> <\/section>\n<section class=\"column large-8 small-8 padding-left-small padding-top-small padding-bottom-small no-padding-top no-padding-bottom\"> <a href=\"https:\/\/developer.apple.com\/wwdc22\/10077\"> <\/p>\n<h4 class=\"no-margin-bottom activity-title\">Replace CAPTCHAs with Private Access Tokens<\/h4>\n<p class=\"activity-description\">Don\u2019t be captured by CAPTCHAs! Private Access Tokens are a powerful alternative that help you identify HTTP requests from legitimate devices and people without compromising their identity or personal information. We\u2019ll show you how your app and server can take advantage of this tool to add&#8230;<\/p>\n<p> <\/a> <\/section>\n<\/section>\n<\/section>\n<h3>Begin the challenge<\/h3>\n<p>It\u2019s easy to add support for Private Access Tokens on your servers: Your server can send an HTTP authentication challenge to request clients to present a token that is signed by a token issuer you trust. You can then validate tokens using that issuer\u2019s public key.<\/p>\n<div class=\"inline-article-image\"><img decoding=\"async\" src=\"https:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2022\/06\/challenge-private-access-tokens-2.jpg\" data-hires=\"false\" alt><\/div>\n<p><strong>Choose a Token Issuer<\/strong><br \/>To adopt Private Access tokens, you&#8217;ll first need to choose a token issuer. Your server must include the token issuer\u2019s hostname and public key in challenges sent to clients. You can test with token issuers from Cloudflare and Fastly when using iOS 16 and macOS Ventura. For each issuer, you can look up the public key using the URL format <code>https:\/\/&lt;issuer name&gt;\/.well-known\/token-issuer-directory<\/code>. You can fetch one of the following URLs from your server to get the issuer information:<\/p>\n<pre class=\"code-source\"><code>Cloudflare&nbsp;\u2014&nbsp;https:\/\/demo-pat.issuer.cloudflare.com\/.well-known\/token-issuer-directory Fastly \u2014&nbsp;https:\/\/demo-issuer.private-access-tokens.fastly.com\/.well-known\/token-issuer-directory<\/code><\/pre>\n<p><a href=\"https:\/\/blog.cloudflare.com\/eliminating-captchas-on-iphones-and-macs-using-new-standard\" class=\"icon icon-after icon-chevronright\">Learn more about Private Access Tokens and Cloudflare<\/a><\/p>\n<p><a href=\"https:\/\/www.fastly.com\/blog\/private-access-tokens-stepping-into-the-privacy-respecting-captcha-less\" class=\"icon icon-after icon-chevronright\">Learn more about Private Access Tokens and Fastly<\/a><\/p>\n<p><strong>Token Challenge and Redemption<\/strong><br \/>\nTo send a challenge, your server needs to post a HTTP 401 response to a request made by the client with a \u201cWWW-Authenticate\u201d header containing a \u201cPrivateToken\u201d challenge. This header contains two attributes: \u201cchallenge\u201d, which contains a TokenChallenge structure in base64url encoding; and \u201ctoken-key\u201d, which contains a token issuer\u2019s public key using base64url encoding.<\/p>\n<pre class=\"code-source\"><code>WWW-Authenticate: PrivateToken challenge=, token-key=<\/code><\/pre>\n<p>The TokenChallenge structure contains the type of token, the hostname of the issuer, an optional context to bind to your challenge, and the hostname of your server. iOS 16 and macOS Ventura support token type 2, which uses publicly verifiable RSA Blind Signatures.<\/p>\n<pre class=\"code-source\"><code>struct { uint16_t token_type; \/\/ 0x0002, in network-byte order uint16_t issuer_name_length; \/\/ Issuer name length, in network-byte order char issuer_name[]; \/\/ Hostname of the token issuer uint8_t redemption_context_length; \/\/ Redemption context length (0 or 32) uint8_t redemption_context[]; \/\/ Redemption context, either 0 or 32 bytes uint16_t origin_info_length; \/\/ Origin info length, in network-byte order char origin_info[]; \/\/ Hostname of your server\n} TokenChallenge; <\/code><\/pre>\n<p>Token responses come in an \u201cAuthorization\u201d header. This contains the \u201ctoken\u201d attribute, which is a RSA Blind Signature token using base64url encoding. Use the token issuer\u2019s public key to verify this token.<\/p>\n<pre class=\"code-source\"><code>Authorization: PrivateToken token=<\/code><\/pre>\n<p>Note: When you send token challenges, don\u2019t block the main page load. Make sure that any clients that don\u2019t support tokens still can access your website!<\/p>\n<p><a href=\"https:\/\/www.ietf.org\/archive\/id\/draft-ietf-privacypass-auth-scheme-02.html\" class=\"icon icon-after icon-chevronright\">Adopt the &#8220;PrivateToken&#8221; HTTP authentication scheme<\/a><\/p>\n<p><a href=\"https:\/\/www.ietf.org\/archive\/id\/draft-ietf-privacypass-protocol-04.html#name-issuance-protocol-for-publi\" class=\"icon icon-after icon-chevronright\">Issuance Protocol for Publicly Verifiable Tokens<\/a><\/p>\n<p>Now that you know how to set up Private Access Tokens, explore sending token challenges in your own website. Test your site with clients that support Private Access Tokens&nbsp;\u2014 and ones that don\u2019t! \u2014&nbsp;and discover how you can make your CAPTCHAs only show for clients that don\u2019t support Private Access Tokens.<\/p>\n<p>Have questions about adopting this feature? Check out our Q&amp;A on Private Access Tokens on Thursday morning. And don&#8217;t forget to share your CAPTCHA-free experiences on Twitter with the hashtag #WWDC22Challenges! <\/p>\n<p><a href=\"https:\/\/twitter.com\/search?q=%23WWDC22Challenges\" class=\"icon icon-after icon-chevronright\">Explore #WWDC22Challenges on social media<\/a><\/p>\n<p><a href=\"https:\/\/developer.apple.com\/wwdc22\/challenges\/terms\/WWDC22_Challenge_Terms_Conditions.pdf\" class=\"icon icon-after icon-chevronright\">Read the WWDC22 Challenges Terms and Conditions<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Private Access Tokens are powerful tools that prove when HTTP requests are coming from legitimate devices without disclosing someone&#8217;s identity. This proof can help you reduce how often you show CAPTCHAs to people. They are simple to set up and test \u2014&nbsp;and so we&#8217;re inviting you in this challenge to try out Private Access Tokens [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":125797,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[],"class_list":["post-125796","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apple-developer-news"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/125796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=125796"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/125796\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media\/125797"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=125796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=125796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=125796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}