-
Notifications
You must be signed in to change notification settings - Fork 387
Don't include extra params when calculating local hmac #196
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.
Amazing, thank you for this! I had a question around host
, but once that's resolved I'm happy for this to be merged.
We got some nice CI errors (I think we're not expecting the Just checking: did you make sure that the hash matches on an actual request with the host? |
src/auth/oauth/types.ts
Outdated
shopify?: string[]; | ||
} | ||
|
||
export interface LocalHmacQuery { |
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.
Do we need the extra type here? We'll just ignore fields that we don't care about, so it wouldn't hurt to just use AuthQuery
instead, would it?
src/utils/hmac-validator.ts
Outdated
const {hmac, code, timestamp, state, shop} = query; | ||
const localHmac = generateLocalHmac({code, timestamp, state, shop}); | ||
const {hmac, code, timestamp, state, shop, host} = query; | ||
const localHmac = generateLocalHmac({code, timestamp, state, shop, ...host && {host}}); |
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.
I also realized that we might want to do this in generateLocalHmac
instead, to make sure we're always filtering out the keys we don't want.
WHY are these changes introduced?
Encountered a situation where the returned query contained an extra key:value (
shopify: ['callback']
) which was then added to the local HMAC querystring and resulted in a false match and broken auth flow.WHAT is this pull request doing?
This change makes sure we are only passing the key:values we want when creating the local hmac.
Type of change
Checklist