-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat: options to customize cookie names #272
Conversation
index.js
Outdated
const stateCookie = request.cookies['oauth2-redirect-state'] | ||
const stateCookie = | ||
request.cookies[ | ||
this.redirectStateCookieName || DEFAULT_REDIRECT_STATE_COOKIE_NAME |
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.
this is a potential security issue - we can't try to read both cookie
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.
hmm, I don't think it is reading both. If you have provided redirectStateCookieName
in options it will read request.cookies[this.redirectStateCookieName]
otherwise it uses a default value and takes request.cookies[DEFAULT_REDIRECT_STATE_COOKIE_NAME]
- never tries to read both.
index.js
Outdated
@@ -116,10 +134,14 @@ function fastifyOauth2 (fastify, options, next) { | |||
tokenRequestParams = {}, | |||
scope, | |||
generateStateFunction = defaultGenerateStateFunction, | |||
checkStateFunction = defaultCheckStateFunction, | |||
checkStateFunction = defaultCheckStateFunction.bind({ | |||
redirectStateCookieName: configured.redirectStateCookieName |
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.
redirectStateCookieName: configured.redirectStateCookieName | |
redirectStateCookieName: configured.redirectStateCookieName || DEFAULT_REDIRECT_STATE_COOKIE_NAME |
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.
oh, ok, I see. Sure I can move that default value from defaultCheckStateFunction
here, it should effectively do the same
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.
We should update the Readme too
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.
lgtm
@Eomm PTAL |
Hi, I do realize that these are very short-lived cookies, but I have a project where I have to follow a naming convention for all cookies, so it would be great if we could customize these too.
Checklist
npm run test
andnpm run benchmark
and the Code of conduct