Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Code changes for Issue #404 SSL enable Sequelize #413

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions app/persistence/postgreSQL/PgService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,27 @@ export class PgService {
* @memberof PgService
*/
getUserModel(attributes, options) {
const sequelize = new Sequelize(
`postgres://${this.pgconfig.user}:${this.pgconfig.password}@${this.pgconfig.host}:${this.pgconfig.port}/${this.pgconfig.database}`,
{ logging: false }
);

// Add SSL option for PostGresql- Issue #404
const isPostgresSslEnabled = process.env.DATABASE_SSL_ENABLED || false;
let sequelize;

if (isPostgresSslEnabled) {
logger.info('SSL to Postgresql enabled: set dialect SSL option');
sequelize = new Sequelize(
`postgres://${this.pgconfig.user}:${this.pgconfig.password}@${this.pgconfig.host}:${this.pgconfig.port}/${this.pgconfig.database}`,
{ logging: false, dialectOptions: { ssl: true, }, }
);
}else{
logger.info('SSL to Postgresql disabled: dialect options not set');
sequelize = new Sequelize(
`postgres://${this.pgconfig.user}:${this.pgconfig.password}@${this.pgconfig.host}:${this.pgconfig.port}/${this.pgconfig.database}`,
{ logging: false }
);

}


this.userModel = sequelize.define('users', attributes, options);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change the scope of 'sequelize' so that it can be accessed in the line 120.

Copy link
Author

Choose a reason for hiding this comment

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

updated code - kindly verify

Copy link
Contributor

Choose a reason for hiding this comment

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

@zicaden Thanks for the update. Need to discuss about the SSL enable functionality. Can you please join the maintainers by-weekly call? If so, it would be greatly appreciated!

Copy link
Author

Choose a reason for hiding this comment

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

Hello - Please share the details of the call

Copy link
Author

Choose a reason for hiding this comment

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

@Udhayakumari - tagging you. Please let me know the details of the call. Also I found some new issues - the SSL configuration is better to be done using environment variables -

e.g. DATABASE_MTLS_ENABLED = true | false
If false - then we can avoid placing the certificate and key (key: | cert:)

We encountered issue while connecting with Azure Postgres Flexible Server where these parameters are causing issues. If you want I can provide you an updated code with these changes.

Copy link
Author

Choose a reason for hiding this comment

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

@Udhayakumari - Hello I joined the meeting today but no one joined.

Wednesday, April 17th, 2024
2:00pm to 3:00pm
(UTC) Coordinated Universal Time 

Repeats:
Every 2 weeks on Wednesday
Location:
https://zoom.us/my/hyperledger.community?pwd=STZQd0xMZU9xRVVOVnpQM3JNQ2dqZz09
Organizer:
Blockchain Explorer Maintainers
Description:
Blockchain Explorer - Hyperledger Labs project weekly contributors meeting.

Meeting ID: 403 498 3298
Passcode: 475869
https://zoom.us/j/4034983298?pwd=STZQd0xMZU9xRVVOVnpQM3JNQ2dqZz09

Copy link
Contributor

Choose a reason for hiding this comment

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

@zicaden Yesterday call has been cancelled. Sorry for the inconvenience!

Copy link
Author

Choose a reason for hiding this comment

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

@Udhayakumari - please confirm if this can be discussed in your next meeting scheduled on 4th Sep, 2024 at 7:30 PM IST? If not, kindly confirm the specific meeting date / time when you can be available.

Copy link
Author

Choose a reason for hiding this comment

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

@Udhayakumari - I joined today but no one joined.

Copy link
Author

Choose a reason for hiding this comment

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

@Udhayakumari - I believe the meetings have been updated. Could you please share me the next meeting details. The calendar link is no longer active.

@ArchanaArige - FYI - tagging you for help as @Udhayakumari is not responding

return this.userModel;
}
Expand Down