-
Notifications
You must be signed in to change notification settings - Fork 2.7k
AT Proof-Of-Possession #2: Handle proof-of-possession tokens correctly in responses #2153
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c5608c8
Returns token as Proof-of-possession token
efe1dea
Revert "Returns token as Proof-of-possession token"
03e051d
msal-common changes only
b883959
Merge branch 'pop-req-thumbprint' into pop-handle-response
4d8104c
Update authConfig.js
9ee748b
change to authenticationScheme
224f9a7
Update CryptoOps.ts
536987e
removing id token references from JwtToken class
ab4d418
Updating token exports in browser
a28a61a
Merge branch 'pop-req-thumbprint' into pop-handle-response
7719ee4
rename JwtToken to AuthToken
19f9780
Adding changes from PR feedback
56070a9
Fixing msal-common tests
21add17
update browser tests
ef47cd8
All tests fixed and passing
372a3eb
Update CryptoProvider.ts
572bbda
Update CryptoProvider.ts
d9a92c7
Update CryptoProvider.ts
f6aa724
Update CryptoOps.spec.ts
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 hidden or 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
This file contains hidden or 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
63 changes: 36 additions & 27 deletions
63
lib/msal-browser/test/app/PublicClientApplication.spec.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
import { TokenClaims } from "./TokenClaims"; | ||
import { DecodedAuthToken } from "./DecodedAuthToken"; | ||
import { ClientAuthError } from "../error/ClientAuthError"; | ||
import { StringUtils } from "../utils/StringUtils"; | ||
import { ICrypto } from "../crypto/ICrypto"; | ||
|
||
/** | ||
* JWT Token representation class. Parses token string and generates claims object. | ||
*/ | ||
export class AuthToken { | ||
|
||
// Raw Token string | ||
rawToken: string; | ||
// Claims inside token | ||
claims: TokenClaims; | ||
constructor(rawToken: string, crypto: ICrypto) { | ||
if (StringUtils.isEmpty(rawToken)) { | ||
throw ClientAuthError.createTokenNullOrEmptyError(rawToken); | ||
} | ||
|
||
this.rawToken = rawToken; | ||
this.claims = AuthToken.extractTokenClaims(rawToken, crypto); | ||
} | ||
|
||
/** | ||
* Extract token by decoding the rawToken | ||
* | ||
* @param encodedToken | ||
*/ | ||
static extractTokenClaims(encodedToken: string, crypto: ICrypto): TokenClaims { | ||
// token will be decoded to get the username | ||
const decodedToken: DecodedAuthToken = StringUtils.decodeAuthToken(encodedToken); | ||
if (!decodedToken) { | ||
return null; | ||
} | ||
try { | ||
const base64TokenPayload = decodedToken.JWSPayload; | ||
// base64Decode() should throw an error if there is an issue | ||
const base64Decoded = crypto.base64Decode(base64TokenPayload); | ||
return JSON.parse(base64Decoded) as TokenClaims; | ||
} catch (err) { | ||
throw ClientAuthError.createTokenParsingError(err); | ||
} | ||
} | ||
} |
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
Should this also pass in
request.resourceRequestMethod
andrequest.resourceRequestUri
given that they were added toRefreshTokenRequest
?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've handled this in a later PR, this PR only covers the authorization code 2 legged flow, not the refresh flow.