-
Notifications
You must be signed in to change notification settings - Fork 40
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
add bearer token check #5
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for adding this PR. Check my suggestions. We should try to keep the if (!token)
check in line 26. Also, check line 24, if you are setting the token in an if-else statement, make sure to use a mutable variable with let
because using const
inside of an if-else will limit the scope of that variable to that if-else block.
if(event.authorizationToken.split(' ')[0] == 'bearer') | ||
const token = event.authorizationToken.split(' ')[1] // for bearer token | ||
else | ||
const token = event.authorizationToken |
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.
if(event.authorizationToken.split(' ')[0] == 'bearer') | |
const token = event.authorizationToken.split(' ')[1] // for bearer token | |
else | |
const token = event.authorizationToken | |
if(event.authorizationToken.split(' ')[0] == 'bearer') | |
token = event.authorizationToken.split(' ')[1] // for bearer token | |
else | |
token = event.authorizationToken | |
if (!token) | |
return callback(null, 'Unauthorized') |
@@ -23,8 +23,10 @@ module.exports.auth = (event, context, callback) => { | |||
// check header or url parameters or post parameters for token | |||
const token = event.authorizationToken; |
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.
const token = event.authorizationToken; | |
let token |
No description provided.