Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add bearer token check #5

wants to merge 1 commit into from

Conversation

BelalH
Copy link

@BelalH BelalH commented Dec 21, 2020

No description provided.

@adnanrahic adnanrahic self-requested a review December 21, 2020 08:02
Copy link
Owner

@adnanrahic adnanrahic left a 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.

Comment on lines +26 to +29
if(event.authorizationToken.split(' ')[0] == 'bearer')
const token = event.authorizationToken.split(' ')[1] // for bearer token
else
const token = event.authorizationToken
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const token = event.authorizationToken;
let token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants