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

Custom headers #1628

Closed
Hellek opened this issue May 19, 2022 · 3 comments · Fixed by #1635
Closed

Custom headers #1628

Hellek opened this issue May 19, 2022 · 3 comments · Fixed by #1635
Assignees
Milestone

Comments

@Hellek
Copy link

Hellek commented May 19, 2022

Is your feature request related to a problem? Please describe.
Hi, in current project we have an Auth check on the backend (Authorization header.
Without it, backend forbids all requests, also from Ketcher.
I guess that custom headers feature can be widely helpful

Describe the solution you'd like
Patch itself https://gist.github.com/Hellek/136678652331cbc098cf311a07fe08c8
Current interface looks like this

const structServiceProvider = new RemoteStructServiceProvider(
  createBackendRequestUrl('/v2'),
  {
    Authorization: `Bearer ${userStore.token.authToken}`,
  },
)
@AndreiMazol
Copy link
Contributor

Dear @Hellek ,

Thank you for your interest to Ketcher.
We will discuss your suggestion internally and put it in our backlog.
Right now I recommend you to create your own StructServiceProvider and pass it as a property to component to solve this issue (please refer to https://github.com/epam/ketcher/blob/master/packages/ketcher-core/src/infrastructure/services/struct/remoteStructServiceProvider.ts as an example)

Regards,
Ketcher team

@AndreiMazol AndreiMazol modified the milestones: Release 2.6.0, Backlog May 19, 2022
AndreiMazol pushed a commit that referenced this issue May 23, 2022
* #1628 added custom header param to indigo call

* added custom header to readme

* fix headers in request
@AndreiMazol AndreiMazol linked a pull request May 23, 2022 that will close this issue
@ZhannaNovikova
Copy link

Verified as fixed on Release 2.5.0.

@Hellek
Copy link
Author

Hellek commented Jul 18, 2022

Guys (@AndreiMazol, @ZhannaNovikova) that is great news!! But there are two extra request where extra headers still not exists. For now we still patching it

diff --git a/node_modules/ketcher-core/dist/index.modern.js b/node_modules/ketcher-core/dist/index.modern.js
index a7a4b85..d457bb9 100644
--- a/node_modules/ketcher-core/dist/index.modern.js
+++ b/node_modules/ketcher-core/dist/index.modern.js
@@ -9605,7 +9605,7 @@ var RemoteStructService = function () {
                 isAvailable = false;
                 _context.prev = 1;
                 _context.next = 4;
-                return request('GET', this.apiPath + 'info');
+                return request('GET', this.apiPath + 'info', null, this.customHeaders);
               case 4:
                 response = _context.sent;
                 indigoVersion = response.indigo_version;
@@ -9689,7 +9689,7 @@ var RemoteStructService = function () {
       var req = request('POST', this.apiPath + "imago/uploads".concat(parVersion), blob, {
         'Content-Type': blob.type || 'application/octet-stream'
       });
-      var status = request.bind(null, 'GET', this.apiPath + 'imago/uploads/:id');
+      var status = request.bind(null, 'GET', this.apiPath + 'imago/uploads/:id', null, this.customHeaders);
       return req.then(function (data) {
         return pollDeferred(status.bind(null, {
           id: data.upload_id

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.

4 participants