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

@vendure/create TypeORM SSL Option #1205

Closed
Sean12697 opened this issue Nov 3, 2021 · 5 comments
Closed

@vendure/create TypeORM SSL Option #1205

Sean12697 opened this issue Nov 3, 2021 · 5 comments

Comments

@Sean12697
Copy link

Is your feature request related to a problem? Please describe.

Yes, currently my npx @vendure/create log looks like the following, and I'm certain it's due to SSL being off / false (and should not be strict in development).

sean@pop-os:~/temp/e2e-vendure$ NODE_TLS_REJECT_UNAUTHORIZED='0' npx @vendure/create project-name
(node:23618) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)

Welcome to @vendure/create v1.3.2!

Let's configure a new Vendure project. First a few questions:

✔ Which database are you using? › Postgres
✔ What's the database host address? … ec2-xx-xx-xxx-xxxx.eu-west-1.compute.amazonaws.com
✔ What port is the database listening on? … 5432
✔ What's the name of the database? … xxxxxxxxxxxxxxxxxxxx
✔ What's the database user name? … xxxxxxxx
✔ What's the database password? … ****************************************************************
✔ Which programming language will you be using? › TypeScript
✔ Populate with some sample product data? … no / yes
✔ What identifier do you want to use for the superadmin user? … superadmin
✔ What password do you want to use for the superadmin user? … superadmin

Setting up your new Vendure project in /home/sean/temp/e2e-vendure/project-name
This may take a few minutes...

  ✔ Installing dependencies
  ✔ Generating app scaffold
  ⠙ Initializing server
Error: Could not connect to the database. Please check the connection settings in your Vendure config.
[no pg_hba.conf entry for host "xxx.xxx.xxx.xx", user "xxxxxxxx", database "xxxxxxxxxxxxxxxxxxxx", SSL off]
    at throwConnectionError (/home/sean/.npm/_npx/fca31bc9a717a0f3/node_modules/@vendure/create/src/helpers.ts:345:11)
    at checkPostgresDbExists (/home/sean/.npm/_npx/fca31bc9a717a0f3/node_modules/@vendure/create/src/helpers.ts:336:9)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
  ✔ Installing dependencies
  ✔ Generating app scaffold
  ✖ Initializing server
    → [no pg_hba.conf entry for host "185.205.172.64", user "xxxxxxxx", database "xxxxxxxxxxxxxxxxxxxx", SSL off]
{"context":{"configFile":"/home/sean/temp/e2e-vendure/project-name/src/vendure-config.ts"}}
sean@pop-os:~/temp/e2e-vendure$

Describe the solution you'd like

An SSL option added into the the following user response gather and the value integrated into all of the relevant area's when initiating the project and then creating the dbConnectionOptions config.

const answers = await prompts(
[
{
type: 'select',
name: 'dbType',
message: 'Which database are you using?',
choices: [
{ title: 'MySQL', value: 'mysql' },
{ title: 'MariaDB', value: 'mariadb' },
{ title: 'Postgres', value: 'postgres' },
{ title: 'SQLite', value: 'sqlite' },
{ title: 'SQL.js', value: 'sqljs' },
// Don't show these until they have been tested.
// { title: 'MS SQL Server', value: 'mssql' },
// { title: 'Oracle', value: 'oracle' },
],
initial: 0 as any,
},
{
type: (() => (dbType === 'sqlite' || dbType === 'sqljs' ? null : 'text')) as any,
name: 'dbHost',
message: `What's the database host address?`,
initial: 'localhost',
},
{
type: (() => (dbType === 'sqlite' || dbType === 'sqljs' ? null : 'text')) as any,
name: 'dbPort',
message: `What port is the database listening on?`,
initial: (() => defaultDBPort(dbType)) as any,
},
{
type: (() => (dbType === 'sqlite' || dbType === 'sqljs' ? null : 'text')) as any,
name: 'dbName',
message: `What's the name of the database?`,
initial: 'vendure',
},
{
type: (() => (dbType === 'sqlite' || dbType === 'sqljs' ? null : 'text')) as any,
name: 'dbUserName',
message: `What's the database user name?`,
initial: 'root',
},
{
type: (() => (dbType === 'sqlite' || dbType === 'sqljs' ? null : 'password')) as any,
name: 'dbPassword',
message: `What's the database password?`,
},
{
type: 'select',
name: 'language',
message: 'Which programming language will you be using?',
choices: [
{ title: 'TypeScript', value: 'ts' },
{ title: 'JavaScript', value: 'js' },
],
initial: 0 as any,
},
{
type: 'toggle',
name: 'populateProducts',
message: 'Populate with some sample product data?',
initial: true,
active: 'yes',
inactive: 'no',
},
{
type: 'text',
name: 'superadminIdentifier',
message: 'What identifier do you want to use for the superadmin user?',
initial: SUPER_ADMIN_USER_IDENTIFIER,
},
{
type: 'text',
name: 'superadminPassword',
message: 'What password do you want to use for the superadmin user?',
initial: SUPER_ADMIN_USER_PASSWORD,
},
],
{
onSubmit,
onCancel() {
/* */
},
},
);

Additional context

Even though the npx @vendure/create run does error, it does still generate the project. Modifying the vendure-config.ts files dbConnectionOptions to include ssl: true is a valid / hacky solution, although it does not populate the database with some sample product data if that option was selected during the create process.

@michaelbromley
Copy link
Member

Thanks for the report. I think adding an ssl option to the prompts is a good solution.

@dipanshuhappy
Copy link

Thanks for the report. I think adding an ssl option to the prompts is a good solution.

Hey any plan on this ? on when it will be released ?

@michaelbromley
Copy link
Member

Hi, thanks for bringing this back to my attention.

I'm actually not that familiar with the ssl option, and looking at the docs for node-postgres and for mysql it looks like they take an object which specifies paths to certs.

It's not clear to me what setting it to true actually does. The TypeORM docs don't go into it - they just link to the mysql docs and there it does not even mention the boolean option.

Do you have an idea about this?

@dipanshuhappy
Copy link

Hi, thanks for bringing this back to my attention.

I'm actually not that familiar with the ssl option, and looking at the docs for node-postgres and for mysql it looks like they take an object which specifies paths to certs.

It's not clear to me what setting it to true actually does. The TypeORM docs don't go into it - they just link to the mysql docs and there it does not even mention the boolean option.

Do you have an idea about this?

yes i do , actually its just required if you are using neon or azure postgres so it would be helpful if ssl mode would be set to true , at most it gonna affect the connection protocol

@michaelbromley
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🚀 Shipped
Development

No branches or pull requests

3 participants