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

Keystone don't shows Sign In problem in production environment (Sign In works only for https) #2769

Closed
pahaz opened this issue Apr 17, 2020 · 8 comments

Comments

@pahaz
Copy link
Contributor

pahaz commented Apr 17, 2020

Bug report

Describe the bug

If I use yarn dev:
image

Then I use yarn build && yarn start with the same credentials:
image

To Reproduce

You can reproduce it with demo projects #2761 or with yarn create keystone-app my-app.

System information

  • OS: macOS
  • Browser: chrome

Additional context

Is the keystonejs ready for production? Do you have any production project based on the Keystonejs?

@jesstelford
Copy link
Contributor

Hey @pahaz can you have a read through this and see if it helps solve your problem? Depending on your hosting provider, it might be enough to set the trust proxy value.

https://gist.github.com/molomby/6fa22c165e0025f0f83d55195f3c6e37

@pahaz
Copy link
Contributor Author

pahaz commented Apr 17, 2020

@jesstelford I just try to run it locally without any proxy.

@pahaz
Copy link
Contributor Author

pahaz commented Apr 17, 2020

Steps to reproduce:

git clone https://github.com/keystonejs/keystone
cp -r keystone/demo-projects/blog my-blog-app
cd my-blog-app
yarn
yarn build
yarn start

@3lijah
Copy link

3lijah commented Apr 17, 2020

My understanding from #2729 is that keystonejs can only be used if you have access direct access to the server software and its configuration.

@pahaz
Copy link
Contributor Author

pahaz commented Apr 17, 2020

Ou. I understand my problem.

I added SSL cert for localhost by command openssl req -nodes -new -x509 -keyout server.key -out server.cert, and fix the keystone source:

const { server } = await new Promise((resolve, reject) => {
const server = app.listen(port, error => {
if (error) {
return reject(error);
}
return resolve({ server });
});
});

by this hack (just for test purposes 😁, don't do such staff in production):

  const { server } = await new Promise((resolve, reject) => {
    var https = require('https')
    var fs = require('fs')

    const server = https.createServer({
      key: fs.readFileSync('/Users/pahaz/Code/node-docker-compose-dev/keystone-blog/server.key'),
      cert: fs.readFileSync('/Users/pahaz/Code/node-docker-compose-dev/keystone-blog/server.cert')
    }, app)
        .listen(port, error => {
          if (error) {
            return reject(error);
          }
          return resolve({ server });
        })
  });

And after that, the Sign In form started working fine in https://localhost:3000/ .

In my opinion, it's quite counterintuitive. Keystone should write some warnings about such cases!

  • I need some less source hackable way to fix the Keystone server instance (if it's a part of public details of realization)
  • I need some warnings for such counterintuitive behavior

Thanks, @3lijah and @jesstelford !

@pahaz pahaz changed the title Keystone Sign In doesn't work in production environment Keystone don't shows Sign In problem in production environment (Sign In works only for https) Apr 17, 2020
@pahaz
Copy link
Contributor Author

pahaz commented Apr 18, 2020

I think server customization like in next.js (https://nextjs.org/docs/advanced-features/custom-server) will be a good choice for such things.

@jesstelford
Copy link
Contributor

jesstelford commented Apr 19, 2020

Hmm, curious! I've never had sign-in problems when running locally on http.

We do have custom server options, and they were in fact inspired by Next.js! https://www.keystonejs.com/guides/custom-server

@MadeByMike
Copy link
Contributor

Is there any further action required in this issue? @pahaz @jesstelford? We've spent a lot of time trying to discover all the issues documented in #2729

I think from here the best way forward is to start planning alternative authentication methods for the admin UI.

Closing this now and would welcome any new issues focused on features that improve sign-in\authentication.

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

No branches or pull requests

4 participants