// Generated by orrery. Edit the diagram spec and re-render instead of editing this file.
import { type SVGProps, useId } from "react";

export default function OAuth20AuthorizationCodeFlowWithPKCE(props: SVGProps<SVGSVGElement>) {
  const uid = useId().replace(/[^A-Za-z0-9_-]/g, "");
  return (
    <svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" width="798" height="986" viewBox="0 0 798 986" role="img" aria-labelledby={`${uid}-sdw-title ${uid}-sdw-desc`} fontFamily="Inter, 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif" {...props}>
      <title id={`${uid}-sdw-title`}>
        OAuth 2.0 authorization code flow with PKCE
      </title>
      <desc id={`${uid}-sdw-desc`}>
        OAuth 2.0 authorization code flow with PKCE. Sequence diagram with 4 participants (Browser, Web app, Authorization server, Resource API) and 15 messages. 1. Browser to Web app (GET /login); 2. Web app to itself (new code_verifier, S256 code_challenge); 3. Web app to Browser (302 to /authorize (code_challenge, state)); 4. Browser to Authorization server (GET /authorize (client_id, code_challenge)); 5. Authorization server to Browser (sign-in and consent page); 6. Browser to Authorization server (POST credentials, approve scopes); 7. Authorization server to Browser (302 to /callback (code, state)); 8. Browser to Web app (GET /callback (code, state)); 9. Web app to Authorization server (POST /token (code, code_verifier)); 10. Authorization server to itself (SHA-256(code_verifier) = code_challenge?); 11. Authorization server to Web app (access and refresh tokens); 12. Authorization server to Web app (400 invalid_grant); 13. Web app to Resource API (GET /me (Bearer access token)); 14. Resource API to Web app (200 profile); 15. Web app to Browser (session cookie, home page). Fragments: alt [verifier matches] over messages 11 to 12, else [no match] from 12.
      </desc>
      <defs>
        <symbol id={`${uid}-s1`} viewBox="0 0 24 24" overflow="visible">
          <path fill="none" stroke="#000000" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M4 8h16M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm4-2v4" />
        </symbol>
        <symbol id={`${uid}-s2`} viewBox="0 0 24 24" overflow="visible">
          <path fill="none" stroke="#000000" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M3 7a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v2a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3zm0 8a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v2a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3zm4-7v.01M7 16v.01" />
        </symbol>
        <symbol id={`${uid}-s3`} viewBox="0 0 24 24" overflow="visible">
          <g fill="none" stroke="#000000" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2">
            <path d="M12 3a12 12 0 0 0 8.5 3A12 12 0 0 1 12 21A12 12 0 0 1 3.5 6A12 12 0 0 0 12 3" />
            <path d="M11 11a1 1 0 1 0 2 0a1 1 0 1 0-2 0m1 1v2.5" />
          </g>
        </symbol>
        <symbol id={`${uid}-s4`} viewBox="0 0 24 24" overflow="visible">
          <path fill="none" stroke="#000000" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M4 13h5m3 3V8h3a2 2 0 0 1 2 2v1a2 2 0 0 1-2 2h-3m8-5v8M9 16v-5.5a2.5 2.5 0 0 0-5 0V16" />
        </symbol>
      </defs>
      <rect width="798" height="986" fill="#ffffff" />
      <text fontSize="20" fontWeight="600" fill="#000000">
        <tspan x="28" y="43.78">
          OAuth 2.0 authorization code flow with PKCE
        </tspan>
      </text>
      <text fontSize="13" fill="#5f6b7a">
        <tspan x="28" y="66.18">
          RFC 7636: the app proves at the token endpoint that it started the login, so a stolen code is useless
        </tspan>
      </text>
      <g>
        <rect x="267.63" y="663" width="268.98" height="131" rx="6" fill="#0972d3" fillOpacity="0.035" stroke="#a1a5aa" strokeWidth="1" />
        <path d="M62.25 187 V932" fill="none" stroke="#aaadb2" strokeWidth="1.25" strokeDasharray="5 4" />
        <rect x="28" y="932" width="68.5" height="25.6" rx="6" fill="#ffffff" stroke="#c6ccd4" strokeWidth="1" />
        <text fontSize="12" fontWeight="600" fill="#000000" textAnchor="middle">
          <tspan x="62.25" y="949.17">
            Browser
          </tspan>
        </text>
        <path d="M288.63 204 V932" fill="none" stroke="#aaadb2" strokeWidth="1.25" strokeDasharray="5 4" />
        <rect x="252.77" y="932" width="71.71" height="25.6" rx="6" fill="#ffffff" stroke="#c6ccd4" strokeWidth="1" />
        <text fontSize="12" fontWeight="600" fill="#000000" textAnchor="middle">
          <tspan x="288.63" y="949.17">
            Web app
          </tspan>
        </text>
        <path d="M515.61 187 V932" fill="none" stroke="#aaadb2" strokeWidth="1.25" strokeDasharray="5 4" />
        <rect x="446.13" y="932" width="138.96" height="25.6" rx="6" fill="#ffffff" stroke="#c6ccd4" strokeWidth="1" />
        <text fontSize="12" fontWeight="600" fill="#000000" textAnchor="middle">
          <tspan x="515.61" y="949.17">
            Authorization server
          </tspan>
        </text>
        <path d="M720.77 187 V932" fill="none" stroke="#aaadb2" strokeWidth="1.25" strokeDasharray="5 4" />
        <rect x="671.85" y="932" width="97.84" height="25.6" rx="6" fill="#ffffff" stroke="#c6ccd4" strokeWidth="1" />
        <text fontSize="12" fontWeight="600" fill="#000000" textAnchor="middle">
          <tspan x="720.77" y="949.17">
            Resource API
          </tspan>
        </text>
        <rect x="283.63" y="244" width="10" height="109" rx="2" fill="#ddebf9" stroke="#6e747b" strokeWidth="1" />
        <rect x="510.61" y="393" width="10" height="40" rx="2" fill="#ddebf9" stroke="#6e747b" strokeWidth="1" />
        <rect x="510.61" y="473" width="10" height="40" rx="2" fill="#ddebf9" stroke="#6e747b" strokeWidth="1" />
        <rect x="283.63" y="553" width="10" height="359" rx="2" fill="#ddebf9" stroke="#6e747b" strokeWidth="1" />
        <rect x="510.61" y="593" width="10" height="189" rx="2" fill="#ddebf9" stroke="#6e747b" strokeWidth="1" />
        <rect x="715.77" y="832" width="10" height="40" rx="2" fill="#ddebf9" stroke="#6e747b" strokeWidth="1" />
        <path d="M267.63 669 Q267.63 663 273.63 663 H302.71 V677 L296.71 683 H267.63 Z" fill="#ddebf9" stroke="#a1a5aa" strokeWidth="1" />
        <text fontSize="11" fontWeight="600" fill="#000000">
          <tspan x="275.63" y="677">
            alt
          </tspan>
        </text>
        <rect x="308.71" y="664.5" width="116" height="17" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000">
          <tspan x="312.71" y="677.18">
            [verifier matches]
          </tspan>
        </text>
        <path d="M267.63 733 H536.61" fill="none" stroke="#a1a5aa" strokeWidth="1" strokeDasharray="6 4" />
        <rect x="308.71" y="736" width="68" height="17" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000">
          <tspan x="312.71" y="748.68">
            [no match]
          </tspan>
        </text>
      </g>
      <g id={`${uid}-e-e1`}>
        <path d="M62.25 244 L275.63 244" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" />
        <path d="M283.63 244 L274.63 248.5 L276.13 244 L274.63 239.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e2`}>
        <path d="M293.63 264 L315.63 264 Q323.63 264 323.63 272 L323.63 292 Q323.63 300 315.63 300 L301.63 300" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" />
        <path d="M293.63 300 L302.63 295.5 L301.13 300 L302.63 304.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e3`}>
        <path d="M283.63 353 L70.25 353" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" strokeDasharray="6 4" />
        <path d="M62.25 353 L71.25 348.5 L69.75 353 L71.25 357.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e4`}>
        <path d="M62.25 393 L502.61 393" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" />
        <path d="M510.61 393 L501.61 397.5 L503.11 393 L501.61 388.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e5`}>
        <path d="M510.61 433 L70.25 433" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" strokeDasharray="6 4" />
        <path d="M62.25 433 L71.25 428.5 L69.75 433 L71.25 437.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e6`}>
        <path d="M62.25 473 L502.61 473" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" />
        <path d="M510.61 473 L501.61 477.5 L503.11 473 L501.61 468.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e7`}>
        <path d="M510.61 513 L70.25 513" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" strokeDasharray="6 4" />
        <path d="M62.25 513 L71.25 508.5 L69.75 513 L71.25 517.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e8`}>
        <path d="M62.25 553 L275.63 553" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" />
        <path d="M283.63 553 L274.63 557.5 L276.13 553 L274.63 548.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e9`}>
        <path d="M293.63 593 L502.61 593" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" />
        <path d="M510.61 593 L501.61 597.5 L503.11 593 L501.61 588.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e10`}>
        <path d="M520.61 613 L542.61 613 Q550.61 613 550.61 621 L550.61 641 Q550.61 649 542.61 649 L528.61 649" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" />
        <path d="M520.61 649 L529.61 644.5 L528.11 649 L529.61 653.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e11`}>
        <path d="M510.61 715 L301.63 715" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" strokeDasharray="6 4" />
        <path d="M293.63 715 L302.63 710.5 L301.13 715 L302.63 719.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e12`}>
        <path d="M510.61 782 L301.63 782" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" strokeDasharray="6 4" />
        <path d="M293.63 782 L302.63 777.5 L301.13 782 L302.63 786.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e13`}>
        <path d="M293.63 832 L707.77 832" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" />
        <path d="M715.77 832 L706.77 836.5 L708.27 832 L706.77 827.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e14`}>
        <path d="M715.77 872 L301.63 872" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" strokeDasharray="6 4" />
        <path d="M293.63 872 L302.63 867.5 L301.13 872 L302.63 876.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-e-e15`}>
        <path d="M283.63 912 L70.25 912" fill="none" stroke="#545b64" strokeWidth="1.5" strokeLinejoin="round" strokeDasharray="6 4" />
        <path d="M62.25 912 L71.25 907.5 L69.75 912 L71.25 916.5 Z" fill="#545b64" />
      </g>
      <g id={`${uid}-el-e1`}>
        <rect x="138.64" y="220" width="68.61" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="172.95" y="234.68">
            GET /login
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e2`}>
        <rect x="331.63" y="264" width="143.85" height="36" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="403.56" y="278.68">
            new code_verifier, S256
          </tspan>
          <tspan x="403.56" y="293.68">
            code_challenge
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e3`}>
        <rect x="72.25" y="314" width="201.38" height="36" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="172.94" y="328.68">
            302 to /authorize (code_challenge,
          </tspan>
          <tspan x="172.94" y="343.68">
            state)
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e4`}>
        <rect x="165.96" y="369" width="240.93" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="286.43" y="383.68">
            GET /authorize (client_id, code_challenge)
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e5`}>
        <rect x="211.22" y="409" width="150.42" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="286.43" y="423.68">
            sign-in and consent page
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e6`}>
        <rect x="186.31" y="449" width="200.25" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="286.44" y="463.68">
            POST credentials, approve scopes
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e7`}>
        <rect x="200.55" y="489" width="171.76" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="286.43" y="503.68">
            302 to /callback (code, state)
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e8`}>
        <rect x="93.23" y="529" width="159.41" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="172.94" y="543.68">
            GET /callback (code, state)
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e9`}>
        <rect x="303.63" y="569" width="196.98" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="402.12" y="583.68">
            POST /token (code, code_verifier)
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e10`}>
        <rect x="558.61" y="613" width="152.16" height="36" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="634.69" y="627.68">
            SHA-256(code_verifier) =
          </tspan>
          <tspan x="634.69" y="642.68">
            code_challenge?
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e11`}>
        <rect x="324.03" y="691" width="156.17" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="402.11" y="705.68">
            access and refresh tokens
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e12`}>
        <rect x="349.16" y="758" width="105.93" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="402.13" y="772.68">
            400 invalid_grant
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e13`}>
        <rect x="413.64" y="808" width="182.12" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="504.7" y="822.68">
            GET /me (Bearer access token)
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e14`}>
        <rect x="468.92" y="848" width="71.56" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="504.7" y="862.68">
            200 profile
          </tspan>
        </text>
      </g>
      <g id={`${uid}-el-e15`}>
        <rect x="92.79" y="888" width="160.3" height="21" rx="4" fill="#ffffff" fillOpacity="0.92" />
        <text fontSize="11.5" fill="#000000" textAnchor="middle">
          <tspan x="172.94" y="902.68">
            session cookie, home page
          </tspan>
        </text>
      </g>
      <g id={`${uid}-n-browser`}>
        <use href={`#${uid}-s1`} x="30.25" y="96" width="64" height="64" />
        <text fontSize="13" fill="#000000" textAnchor="middle">
          <tspan x="62.26" y="179.18">
            Browser
          </tspan>
        </text>
      </g>
      <g id={`${uid}-n-app`}>
        <use href={`#${uid}-s2`} x="256.63" y="96" width="64" height="64" />
        <text fontSize="13" fill="#000000" textAnchor="middle">
          <tspan x="288.63" y="179.18">
            Web app
          </tspan>
        </text>
        <text fontSize="11.5" fill="#5f6b7a" textAnchor="middle">
          <tspan x="288.64" y="196.58">
            OAuth client
          </tspan>
        </text>
      </g>
      <g id={`${uid}-n-auth`}>
        <use href={`#${uid}-s3`} x="483.61" y="96" width="64" height="64" />
        <text fontSize="13" fill="#000000" textAnchor="middle">
          <tspan x="515.61" y="179.18">
            Authorization server
          </tspan>
        </text>
      </g>
      <g id={`${uid}-n-api`}>
        <use href={`#${uid}-s4`} x="688.77" y="96" width="64" height="64" />
        <text fontSize="13" fill="#000000" textAnchor="middle">
          <tspan x="720.78" y="179.18">
            Resource API
          </tspan>
        </text>
      </g>
    </svg>
  );
}
