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

Allow insecure connections to self-hosted Gitlab instances #1125

Closed
vonBrax opened this issue Jul 4, 2024 · 1 comment · Fixed by #1129
Closed

Allow insecure connections to self-hosted Gitlab instances #1125

vonBrax opened this issue Jul 4, 2024 · 1 comment · Fixed by #1129

Comments

@vonBrax
Copy link
Contributor

vonBrax commented Jul 4, 2024

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch release-it@17.4.1 for the project I'm working on.

The problem we have is that we host our own private Gitlab instance deployed to our internal network using a self signed certificate.

I understand there is already an option to pass our certificate to release-it, but it is not very ergonomic since we need to keep passing the certificate around to everyone in the project before they can create a release.

The got library used internally by release-it already provides an option to allow insecure https connection.

I was wondering if it would be possible to extend the Gitlab options to also accept a secure flag and pass it down to got?

I'll be more than happy to open a PR if you accept this suggestion.

Here is the diff that solved our problem:

diff --git a/node_modules/release-it/lib/plugin/gitlab/GitLab.js b/node_modules/release-it/lib/plugin/gitlab/GitLab.js
index 60dc8ac..fd20c81 100644
--- a/node_modules/release-it/lib/plugin/gitlab/GitLab.js
+++ b/node_modules/release-it/lib/plugin/gitlab/GitLab.js
@@ -169,7 +169,13 @@ class GitLab extends Release {
   }
 
   async request(endpoint, options) {
-    const { baseUrl } = this.getContext();
+    const { baseUrl, secure } = this.getContext();
+    
+    if (secure === false) {
+      options.https = options.https || {};
+      options.https.rejectUnauthorized = false;
+    }
+
     this.debug(Object.assign({ url: `${baseUrl}/${endpoint}` }, options));
     const method = (options.method || 'POST').toLowerCase();
     const response = await this.client[method](endpoint, options);

This issue body was partially generated by patch-package.

@vonBrax vonBrax changed the title Allow insecure connections to self-hosted Gitlab instancs Allow insecure connections to self-hosted Gitlab instances Jul 4, 2024
@webpro
Copy link
Collaborator

webpro commented Jul 8, 2024

I was wondering if it would be possible to extend the Gitlab options to also accept a secure flag and pass it down to got?

I'll be more than happy to open a PR if you accept this suggestion.

Sounds good! Looks all reasonable and sound :)

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

Successfully merging a pull request may close this issue.

2 participants