-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates code_challenge documentation #468
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,12 +37,11 @@ Correct Example | |
```ruby | ||
code_verifier = SecureRandom.hex | ||
=> "5787d673fb784c90f0e309883241803d" | ||
code_challenge = Digest::SHA256.digest(code_verifier) # binary data | ||
code_challenge = Digest::SHA256.digest(code_verifier) | ||
=> "\xD4\x15)\xC7-\xFBJ\x82\x0F\x98\xAC=\xEB\x06\xDD\xE8\xC0\xDC\xBD\xAC\x8Ebm\xE9\xB5?\xB3m\xEE\x8B\xFF3" # binary digest | ||
url_safe_code_challenge = Base64.urlsafe_encode64(code_challenge) | ||
# RFC 4648 URL-safe Base64 encoding replaces "+" with "-" and "/" with "_" and trims trailing "=" | ||
=> "1BUpxy37SoIPmKw96wbd6MDcvayOYm3ptT-zbe6L_zM" | ||
Base64.encode64(code_challenge) # wrong and URL-unsafe encoding | ||
=> "1BUpxy37SoIPmKw96wbd6MDcvayOYm3ptT+zbe6L/zM=" # wrong and URL-unsafe encoding | ||
# RFC 4648 URL-safe Base64 encoding replaces "+" with "-" and "/" with "_" | ||
=> "1BUpxy37SoIPmKw96wbd6MDcvayOYm3ptT-zbe6L_zM=" | ||
``` | ||
|
||
Incorrect Example | ||
|
@@ -53,13 +52,7 @@ Base64.encode64(code_challenge) # wrong and URL-unsafe encoding | |
=> "1BUpxy37SoIPmKw96wbd6MDcvayOYm3ptT+zbe6L/zM=" # wrong and URL-unsafe encoding | ||
``` | ||
{% endcapture %} | ||
{% capture code_challenge_incorrect %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this capture is unused |
||
```ruby | ||
=> "1BUpxy37SoIPmKw96wbd6MDcvayOYm3ptT-zbe6L_zM" | ||
Base64.encode64(code_challenge) # wrong and URL-unsafe encoding | ||
=> "1BUpxy37SoIPmKw96wbd6MDcvayOYm3ptT+zbe6L/zM=" # wrong and URL-unsafe encoding | ||
``` | ||
{% endcapture %} | ||
|
||
{% capture scope_possible_values %} | ||
Possible values are: | ||
- `openid` | ||
|
@@ -113,8 +106,8 @@ In an **unsuccessful authorization**, the URI will contain the parameters `error | |
<div class="grid-row grid-gap"> | ||
<div class="desktop:grid-col-9 mobile:grid-col-full"> | ||
<h2 class="margin-top-neg-1">Authorization</h2> | ||
<p>The authorization endpoint handles authentication and authorization of a user. | ||
To present the Login.gov authorization page to a user, direct them to the | ||
<p>The authorization endpoint handles authentication and authorization of a user. | ||
To present the Login.gov authorization page to a user, direct them to the | ||
<code class="language-plaintext highlighter-rouge">/openid_connect/authorize</code>. View an example for <strong>private_key_jwt</strong> or <strong>PKCE</strong> in the side panel.</p> | ||
<h3 class="margin-top-4" id="request-parameters">Request Parameters</h3> | ||
<ul class="doc-sub-nav"> | ||
|
@@ -139,7 +132,7 @@ In an **unsuccessful authorization**, the URI will contain the parameters `error | |
{% include accordion.html content=loa_values accordion_id="loa_accordion" title="Level of Assurance (LOA) Values (Deprecated)" id="loa_values" %} | ||
</div> | ||
<p id="fn:1"> | ||
1. Login.gov continues to work toward achieving certification of compliance with NIST’s IAL2 standard from a third-party assessment organization. | ||
1. Login.gov continues to work toward achieving certification of compliance with NIST’s IAL2 standard from a third-party assessment organization. | ||
<a href="#fnref:1">↩</a>1 <a href="#fnref:1:2">↩</a>2 <a href="#fnref:1:3">↩</a>3 | ||
</p> | ||
</div> | ||
|
@@ -157,12 +150,12 @@ In an **unsuccessful authorization**, the URI will contain the parameters `error | |
<h4 class="parameters clearfix">code_challenge</h4><span class="float-left text-italic">required for PKCE</span> | ||
</div> | ||
<div class="grid-col-7 padding-bottom-2"> | ||
The <a class="usa-link usa-link--external" href="https://datatracker.ietf.org/doc/html/rfc4648">RFC 4648</a> URL-safe Base64 encoding of the SHA256 digest of a random value generated by the client. The original random value is referred to as the <code class="language-plaintext highlighter-rouge">code_verifier</code> and is later used with the token endpoint. Generating these values in Ruby might look like this, for example: | ||
The <a class="usa-link usa-link--external" href="https://datatracker.ietf.org/doc/html/rfc4648">RFC 4648</a> URL-safe Base64 encoding of the SHA256 binary digest of a random value generated by the client. The original random value is referred to as the <code class="language-plaintext highlighter-rouge">code_verifier</code> and is later used with the token endpoint. Generating these values in Ruby might look like this, for example: | ||
</div> | ||
</div> | ||
<div class="grid-row"> | ||
<div class="usa-accordion padding-top-2"> | ||
{% include accordion.html content=code_challenge accordion_id="code_challenge_accordion" title="Code Challenge Example" id="code_challenge" %} | ||
{% include accordion.html content=code_challenge accordion_id="code_challenge_accordion" title="Code Challenge Example" id="code_challenge" %} | ||
</div> | ||
</div> | ||
</div> | ||
|
@@ -231,12 +224,12 @@ In an **unsuccessful authorization**, the URI will contain the parameters `error | |
<h4 class="parameters clearfix">nonce</h4> | ||
</div> | ||
<div class="grid-col-7"> | ||
A unique value, at least 22 characters in length, used to verify the integrity | ||
of the <code class="language-plaintext highlighter-rouge">id_token</code> and mitigate | ||
<a class="usa-link usa-link usa-link--external" href="https://en.wikipedia.org/wiki/Replay_attack">replay attacks</a>. | ||
This value should include per-session state and be unguessable by attackers. This value will be present in the | ||
<code class="language-plaintext highlighter-rouge">id_token</code> of the <a class="usa-link" href="{{ '/oidc/token/#token-response' | prepend: site.baseurl }}">token endpoint response</a>, | ||
where clients will verify that the nonce claim value is equal to the value of the nonce parameter sent in the authentication request. | ||
A unique value, at least 22 characters in length, used to verify the integrity | ||
of the <code class="language-plaintext highlighter-rouge">id_token</code> and mitigate | ||
<a class="usa-link usa-link usa-link--external" href="https://en.wikipedia.org/wiki/Replay_attack">replay attacks</a>. | ||
This value should include per-session state and be unguessable by attackers. This value will be present in the | ||
<code class="language-plaintext highlighter-rouge">id_token</code> of the <a class="usa-link" href="{{ '/oidc/token/#token-response' | prepend: site.baseurl }}">token endpoint response</a>, | ||
where clients will verify that the nonce claim value is equal to the value of the nonce parameter sent in the authentication request. | ||
Read more about <a class="usa-link usa-link--external" href="https://openid.net/specs/openid-connect-core-1_0.html#NonceNotes">nonce implementation</a> in the spec. | ||
</div> | ||
</div> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] if we want to remove the trailing
=
we can do that by adding padding:false
as an option toBase64.urlsafe_encode64
but it was unclear to me if that was necessary. does anyone know offhand?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we need it or not, but since it works with it (based on my test integration I made forever ago) I'd be inclined to leave it in our docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like we remove the padding if it exists, so it doesn't matter.
https://github.com/18F/identity-idp/blob/main/app/forms/openid_connect_token_form.rb#L191-L195