forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
58 additions
and
18 deletions.
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
2 changes: 2 additions & 0 deletions
2
samples/19.a.single-sign-on-for-enterprise-apps/rest-api/src/encodeBase64URL.js
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// For information about Base 64 URL encoding, please refer to https://en.wikipedia.org/wiki/Base64#URL_applications and https://tools.ietf.org/html/rfc4648#section-5 | ||
module.exports = buffer => buffer.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=$/, ''); |
6 changes: 4 additions & 2 deletions
6
samples/19.a.single-sign-on-for-enterprise-apps/rest-api/src/exchangeAccessToken.js
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
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
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
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
14 changes: 14 additions & 0 deletions
14
...ngle-sign-on-for-enterprise-apps/rest-api/src/routes/aad/oauth/createPKCECodeChallenge.js
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { createHash } = require('crypto'); | ||
const encodeBase64URL = require('../../../encodeBase64URL'); | ||
|
||
const createPKCECodeVerifier = require('./createPKCECodeVerifier'); | ||
|
||
// Create a PKCE code challenge. | ||
module.exports = seed => { | ||
const verifier = createPKCECodeVerifier(seed); | ||
const hash = createHash('sha256'); | ||
|
||
hash.update(verifier); | ||
|
||
return encodeBase64URL(hash.digest()); | ||
}; |
14 changes: 14 additions & 0 deletions
14
...ingle-sign-on-for-enterprise-apps/rest-api/src/routes/aad/oauth/createPKCECodeVerifier.js
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { createHash } = require('crypto'); | ||
|
||
const { AAD_OAUTH_PKCE_SALT } = process.env; | ||
|
||
// Creating a PKCE code verifier based on salt and seed. | ||
// We are using seed and salt to simplify the creation of PKCE code in a distributed manner. | ||
module.exports = seed => { | ||
const hash = createHash('sha512'); | ||
|
||
hash.update(seed); | ||
hash.update(AAD_OAUTH_PKCE_SALT); | ||
|
||
return hash.digest().toString('base64'); | ||
}; |