IntelliJ HTTP Client: OCI request signing or how to modify requests using external libraries ?
Answered
Hello IntelliJ-Support & Community ,
I am trying to use IntelliJ HTTP client with Oracle Cloud (OCI). Any OCI request must be signed. Actually this means adding an extra header calculated based on body content (and other ingredients). Just for reference: Java Script example from OCI Doc
My very first question: has anybody done this, yet? is modifying the http request (prior to flight) possible today?
A few challenges I see so far:
- IntelliJ HTTP Client Runtime env obviously does not have all the required libraries and does not support “require”
→ idea: bundle all libs via webpack ? - All of this code should be reusable across all HTTP requests in our project
→ working solution: import function from external js file as described in this post - How to modify HTTP client's request object prior to submission? e.g. add/update request headers ?
The solution in mind is something like
oci-signer.js:
require("oci-common");
...
export function signRequest( request ) {
...
signer.signHttpRequest( request )
return request
}
with WebPack bundling this into oci-signer-bundle.js, which is then used in oci.http:
###
< {%
import {signRequest} from '/dist/oci-signer-bundle.js';
signRequest( request );
%}
GET https://identity.{{region}}.oci.oraclecloud.com/20160918/regions
Is this the right direction?
Please sign in to leave a comment.
Hello, CK. Unfortunately, we currently don't support the possibility of adding a header the way you described; however, you can try to add a header with the variable value, and assign this variable in the script.
Thank you very much for your response, Olga! - We shall follow variable approach for adding header.
The current challenge is how to use any 3P libraries. As part of ticket #6700637 there seems to be a blocker when code uses slashy strings, typically used for regex which are used often in 3P libs.
Easy to reproduce problem:
I found these possibly related tickets: IJPL-159379, IJPL-156137 and IJPL-157554 (reported as fixed)
Use of 3P libs is required of OCI-Request signing which is mandatory for any calls to Oracle Cloud. - So unless we find some solution here, HTTP client is not usable for Oracle Cloud :-(
Any thoughs appreciated from anyone!
Could you please specify which IDE version you use now? It should have been fixed in the latest IntelliJ IDEA 2024.2.1 release, but the exact release version may vary depending on the particular product.
I am using latest IntelliJ Gateway (2024.2.0.2) → fails
Just tried with local IntelliJ (2024.2.1) → works!
So I guess I need to wait for fix to become available for IntelliJ Gateway ?
For the time being I will take up my request signing process on local IntelliJ … and move to remote dev, once fix is avail. - Will post further updates.
Thank you for your help, Olga Mulina
Updating the IDE backend to 2024.2.1 should be enough. The option Select Different IDE to install the new IDE backend to the existing connection should be presented in the three-dot menu near the connection name in the existing connections list.