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

[legacy-framework] Use cookie prefix from config.blitz.js instead of package.json name field #2311

Merged
merged 13 commits into from
May 17, 2021

Conversation

mabadir
Copy link
Collaborator

@mabadir mabadir commented May 8, 2021

Replaces: #1976
Closes: blitz-js/legacy-framework#329, blitz-js/legacy-framework#335

Adds new cookiePrefix property to sessionMiddleware config.

What are the changes and their implications?

module.exports = {
  middleware: [
    sessionMiddleware({
+     cookiePrefix: 'cookie',
      isAuthorized: simpleRolesIsAuthorized,
    }),
  ],
}

Feature Checklist

@mabadir
Copy link
Collaborator Author

mabadir commented May 8, 2021

Next step is to PR the docs for that change.

Also, I think we need to have some test coverage.

Copy link
Member

@flybayer flybayer left a comment

Choose a reason for hiding this comment

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

Thanks! I fixed a bug where it wasn't working — example app test was failing.

A proper integration test can be added to test/integration/auth/ by setting the session cookie prefix and then adding a middleware to blitz.config.ts that checks and validates the res cookies. Probably should only do it on the first request? Or a certain request like login or something.

examples/custom-server/blitz.config.js Outdated Show resolved Hide resolved
packages/core/src/blitz-data.tsx Outdated Show resolved Hide resolved
@flybayer
Copy link
Member

Sweet, thanks Mina! I looked and the existing tests sufficiently cover this. I also just pushed a commit to docs canary to add this.

@flybayer flybayer merged commit af9df4c into canary May 17, 2021
@flybayer flybayer deleted the mabadir/pr-1976-cookie-prefix branch May 17, 2021 22:40
@blitzjs-bot
Copy link
Contributor

Added @mabadir contributions for code

@itsdillon itsdillon changed the title Use cookie prefix from config.blitz.js instead of package.json name field [legacy-framework] Use cookie prefix from config.blitz.js instead of package.json name field Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change session cookie prefix to have an explict config instead of using package.json name field
3 participants