-
Notifications
You must be signed in to change notification settings - Fork 6
SCAL-249159 ensuring the token type is a string before proceeding token validation #314
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
Changes from 1 commit
57e66f0
8338e32
6972fc2
51d37d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,14 @@ const validateAuthToken = async ( | |
suppressAlert?: boolean, | ||
): Promise<boolean> => { | ||
const cachedAuthToken = getCacheAuthToken(); | ||
// even if token verification is disabled, we will still validate | ||
// that the token is a string before proceeding. | ||
if (typeof authToken !== 'string') { | ||
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. Please write a unit test for this 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. Done! |
||
const errorMessage = `${ERROR_MESSAGE.INVALID_TOKEN_TYPE_ERROR} ${typeof authToken}.`; | ||
|
||
logger.error(errorMessage); | ||
throw new Error(errorMessage); | ||
} | ||
|
||
if (embedConfig.disableTokenVerification) { | ||
logger.info('Token verification is disabled. Assuming token is valid.'); | ||
return true; | ||
|
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.
move this line below the type check
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.
done