-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into igor/iast-security-controls
- Loading branch information
Showing
77 changed files
with
1,928 additions
and
375 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict' | ||
|
||
const shimmer = require('../../datadog-shimmer') | ||
const { channel, addHook } = require('./helpers/instrument') | ||
|
||
const onPassportDeserializeUserChannel = channel('datadog:passport:deserializeUser:finish') | ||
|
||
function wrapDone (done) { | ||
return function wrappedDone (err, user) { | ||
if (!err && user) { | ||
const abortController = new AbortController() | ||
|
||
onPassportDeserializeUserChannel.publish({ user, abortController }) | ||
|
||
if (abortController.signal.aborted) return | ||
} | ||
|
||
return done.apply(this, arguments) | ||
} | ||
} | ||
|
||
function wrapDeserializeUser (deserializeUser) { | ||
return function wrappedDeserializeUser (fn, req, done) { | ||
if (typeof fn === 'function') return deserializeUser.apply(this, arguments) | ||
|
||
if (typeof req === 'function') { | ||
done = req | ||
arguments[1] = wrapDone(done) | ||
} else { | ||
arguments[2] = wrapDone(done) | ||
} | ||
|
||
return deserializeUser.apply(this, arguments) | ||
} | ||
} | ||
|
||
addHook({ | ||
name: 'passport', | ||
file: 'lib/authenticator.js', | ||
versions: ['>=0.3.0'] | ||
}, Authenticator => { | ||
shimmer.wrap(Authenticator.prototype, 'deserializeUser', wrapDeserializeUser) | ||
|
||
return Authenticator | ||
}) |
Oops, something went wrong.