Nueva publicación

Encontrar

Pregunta
· 23 jul, 2024

JWT and CORS

Hi

I'm trying to use JWT authentication on a REST application in IRIS. The login API are correctly "injected" into the application. Login works fine with Postman and other REST clients, and subsequent calls to my REST API using the bearer token work fine (correctly authenticated). So far, so good.

The problem is that it doesn't work with Axios, so I can only test it, I cannot integrate it into my application. I found out the reason for this is that Axios is applying CORS whereas Postman and other REST test clients do not; that is, they don't send the "preflight" OPTIONS request, they send the POST request directly, and apparently IRIS is happy not having to deal with CORS in this case (in other words, it does not check the "allow origin" header, probably because there was no OPTIONS call?) Unfortunately the reverse is not true. Axios sends the OPTIONS preflight, to which IRIS responds with a 500 internal server error and no "Access-Control-Allow-Origin" response header. Axios still attempts to send the POST, but it is getting a NS_ERROR_DOM_BAD_URI error because it failed CORS validation.

As far as I can tell based on the CORS specification, Axios is right to apply CORS in this case, as this query does not (and CAN not) match the criteria for not using CORS (as described on MDN: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). There does not seem to be a way to force Axios not to send the pre-flight when the situation is legitimate for CORS.

I have correctly configured the dispatch class to handle CORS; without JWT authentication, CORS is handled correctly. However the dispatch class is never invoked for the JWT authentication login API (not even OnPreHTTP). Apparently the CSP engine is handling the login API on its own and never delegates to the dispatch class. So as far as I can tell, there's no way to intercept the OPTIONS call to somehow ignore or accept it.

Is there a way to make this work in IRIS? Or conversely, does anyone knows of a (minimally invasive) way to force Axios to bypass the pre-flight for this specific call?

Thanks

9 comentarios
Comentarios (9)2
Inicie sesión o regístrese para continuar
Anuncio
· 23 jul, 2024

[Vidéo] La voix pour structurer le traitement dans le DPI : une innovation de POSOS, Nuance et InterSystems

Salut la Communauté!

Profitez de regarder la nouvelle vidéo sur la chaîne Youtube d'InterSystems France :

📺 La voix pour structurer le traitement dans le DPI

Intervenants : 
🗣 Emmanuel Bilbault, CEO et cofondateur de POSOS
🗣 Pierre Meyblum, Directeur des partenariats de Nuance (Microsoft)
🗣 Olivier Desvernois, Professional Services Director d'InterSystems

Suivre la collaboration entre POSOS, Nuance et InterSystems qui utilise la reconnaissance vocale pour simplifier et sécuriser la prescription médicale, permettant aux médecins de gagner du temps et d'améliorer la prise en charge des patients grâce à une documentation plus rapide et précise.

Abonnez-vous à notre chaîne youtube pour plus de vidéos et restez à l'écoute !

Comentarios (0)0
Inicie sesión o regístrese para continuar
Pregunta
· 23 jul, 2024

Issue with SOAP Service After Enabling Basic Authentication

Hi Team,

My SOAP functions were working perfectly before enabling basic authentication. To set up basic authentication, I created web applications for the SOAP service, checked the password option, and assigned a user to this web application. However, after enabling basic authentication, the SOAP service stopped working.

3 comentarios
Comentarios (3)2
Inicie sesión o regístrese para continuar
Artículo
· 22 jul, 2024 Lectura de 12 min

My take on the course Getting Started with InterSystems IRIS for Coders on InterSystems Learning Portal

One good thing about COVID-19 is that it taught people that online work and study are possible. I remember a week before the lockdown started, everyone said that working online was impossible, not secure, etc. And what do you know, it all became possible and "secure" in the blink of an eye. As with everything, it depends on whether a person is capable of organizing his or her day and their work or study attitude. Thus, I became a great believer in online education. As an associate professor who teaches databases, I find it beneficial to my schedule and students. One thing that studying online brings is flexibility. Another one is accepting third-party courses to grant credits to my students 😉 

Considering that I'm teaching the basics of IRIS, I thought a new course, Getting Started with InterSystems IRIS for Coders, could be a relevant addition to my course. Therefore, I decided to follow the new Learning Path and see how it corresponds to my Syllabus and how many ECTS credits I can give for finishing it.

The Learning path consists of 6 steps:

  1. Get an introduction
  2. Get familiar with the tools
  3. Develop an application
  4. Connect with an external language
  5. Expand your expertise
  6. Assess your knowledge

At the very beginning of the Learning path, there is a link to enroll in classroom courses at your earliest convenience: Developing with InterSystems Objects and SQL, which lasts 5 days. I haven't taken this exact class, but from the description you can find in this series of articles by @Yuri Marx, it is really useful.

But let's get back to the Learning path at hand.

The first part is Get an introduction. It should take around 15 minutes to complete if you don't make pauses. It consists of 3 videos and an exercise. The first video, "Welcome to InterSystems," provides a very short description of InterSystems, its core principles, and its products. The second one, "What Is InterSystems IRIS?", provides a 4-minute description of InterSystems IRIS

and mentions its key features, for example, a massively scalable multi-model database:

I'd say this is my favorite image and the reason InterSystems Caché was chosen as an example of a Postrelational database more than 10 years ago. It gives me the possibility to explain how non-relational databases work based on different models while using the same core and language.

The third task, "Receiving and Routing Data in a Production", consists of a video and an exercise. First, you watch a video on the basics of interoperability and how to share data between systems using InterSystems IRIS. Overall, it was a quick overview of IRIS's interoperability capability.

The next step is to do an exercise. Basically, it more or less shows the production described in the video. This step took me a lot of time because I waited for more than an hour for the VM-based Learning Lab to start. And then, when it started, it kept disconnecting. Interestingly, you don't even have to do the exercise for this course to be marked as completed 😁 Just tick the checkbox under the video, and you're good to proceed. It kind of defeats the purpose.

The second part is Get familiar with the tools. It should take around 8 minutes to complete if you don't make pauses, giving you a general understanding of the Management Portal, Terminal, and useful extension packs of VS Studio to work with IRIS and how to use them. It consists of 3 respective videos:

  1. Management Portal Overview for Developers
  2. Install and Use ObjectScript Extensions for VS Code
  3. Using the InterSystems Terminal

What was new to me was the possibility in the SQL section of the Management Portal to drag and drop the table name into the Execute Statement field to get the formed SQL select statement with all columns of this table mentioned in it — this is very handy!

Another useful tip is the usage of ! (exclamation point) to call the OS commands. For example:

The third part is Develop an application. It should take around 18 hours to complete and consists of 6 courses. 

The first course is called Building a Server-Side Application with InterSystems, and it itself consists of 4 courses:

The first course has 4 parts:

  1. a video called Get oriented, which is an intro to this course by @Derek Robinson and @Brenna Quirk 
  2. a video called InterSystems Architecture Overview, which talks about databases and namespaces by @Shane Rose 
  3. an online course (30 minutes): Creating an InterSystems IRIS Class Definition with quizzes after each part. This course was interesting because it gives you step-by-step instructions on how to create classes, properties, methods, parameters, and, of course, the syntax of ObjectScript while teaching people how to use VSCode instead of Studio.
  4. an online course (1 hour 30 minutes): InterSystems ObjectScript Basics with quizzes after each part. It shows how to use commands and operators in InterSystems ObjectScript to create variables, manipulate them in a number of expression types, and destroy them when needed. Moreover, it gave an overview of branching and loops to make decisions about manipulating variables and other operations.

The second course consists of 3 parts, one of which is optional:

1. a compulsory online course (30 minutes): InterSystems IRIS Objects Introduction with quizzes after each part. It goes into detail about working with classes, objects, methods, and properties.

 
A small comment

2. a compulsory online course (30 minutes): InterSystems SQL Overview with quizzes after each part. From it, you will learn how to test SQL queries using both Terminal and the Management Portal, as well as how to use class queries, dynamic SQL, and embedded SQL queries within an InterSystems class.

 
Some more comments

3. optional link to the documentation: Basic Ideas in Class Programming

The third course consists of one exercise: Building a Server-Side Application with InterSystems IRIS, which should take 1 hour and 30 minutes. You're required to create classes and work with SQL to store and retrieve information about an extensive book collection. This is the main task that gives you hands-on experience with using IRIS and VSCode.

 
More comments

The last one is a knowledge assessment, which I failed because the file that I was supposed to edit was read-only, and I didn't manage to either find the file where the correct answers to the test questions are stored or edit this file. Even the DDL statements were prohibited 😁

But if you do pass it, you will get a Credly badge:

Oh well, it is time to switch to the second course of the Develop an application series. It's called Getting Started with InterSystems ObjectScript and consists of 5 courses:

The first course consists of two parts: link to the documentation and an online course: InterSystems ObjectScript Basics. This one was already done in the previous course so everything is already marked as complete. 

The second course, "Dive deeper into commands and functions, " consists of a link to another documentation and two reasonably short videos. The first one is called "Using System Functions in ObjectScript," which shows the syntax for running system functions and how to use the values they return in other functions and commands. The second one is "Controlling Command Flow with Postconditional Expressions", which deals with adding a condition to a single command without using an If statement.

The third course, "Understand data types and variables", again consists of 2 videos and a link to the documentation. The first video, "Exploring Data Types in ObjectScript," explains different variable types in InterSystems ObjectScript and, in particular, three common data types: strings, lists, and objects. The second video is called "Using Variables in ObjectScript" and it deals with assigning values to the most common variable types and operator precedence.

The fourth course is called "Create a class definition" and is an online course that teaches how to create an InterSystems class definition in Visual Studio Code. And it's also already done in the previous parts 🤗

The last one is a test 🤞 which I passed, so I got my Credly badge that is displayed in my profile 😉:

The third course is called Using JSON in InterSystems IRIS. It should take around 30 minutes to complete and has exercises in each part. This course shows how to consume JSON data from an upstream system to use in your application and produce a JSON string from dynamic entities. 

The next course, Setting Up RESTful Services, should take around an hour and 30 minutes. From it, you will learn how to set up RESTful service and client and how the data flows between them: 

This course has quiz questions at the end of each part. 

The fifth course is called "Developing on an InterSystems Server Using VS Code". It consists of 4 courses:

Learning Path sections

The first course is Install and set up VS Code and consists of a link to the documentation, a 3-minute video called "Install and Use ObjectScript Extensions for VS Code," and an online course, "Installing VS Code and Configuring InterSystems Server Connections". From the video, you will learn how to install the ObjectScript extensions, export ObjectScript classes from the server, and write new methods in VS Code. The online course, which is an exercise, will teach you how to use Visual Studio Code to write code for an InterSystems server. It doesn't have any test within it.

The second course is called Configure a workspace and consists of a link to documentation and a 6-minute video. The video is called "Configuring VS Code Workspaces for Multiple ObjectScript Connections". Two configurations are shown in this video:

  • Use a multi-root workspace and virtual folders to view code and perform server-side editing across multiple InterSystems IRIS® data platform namespaces or servers.
  • Use multiple VS Code workspaces—each with a unique active connection—to view code and do client-side code editing for multiple namespaces or servers. It is also possible to enable server-side editing in single-folder workspaces.

Here, two InterSystems servers are depicted, each containing two namespaces. Stacked between the servers is a server labeled App Server.

Diagram of a multiroot workspace

Here, a single VS Code instance is depicted with a folder structure inside. The folder structure in the VS Code instance contains five folders. Each folder connects to one namespace on the left or to the App Server, representing an active connection. A pencil icon is located next to each namespace and the app server, indicating that code editing takes place on the server side.

Diagram of a single-folderworkspace

The third course is called Develop on an InterSystems server and consists of an article, two 5-minute videos, and an online course. The first video, "Working with Classes in VS Code for Client-Side Editing," shows the basics of working with InterSystems classes in VS Code and the creation of new classes in the VS Code Explorer using code completion. The second video, "VS Code Debugger for ObjectScript", shows how to write launch configurations for debugging class methods and production components, and gives an overview of the VS Code debugger interface — including the variables section, watch pane, and debug console. The course "Creating an InterSystems Class Definition in VS Code" will show how to work with classes in VSCode. 

 
Remark

At the end of this course, you will be able to assess your knowledge. And if you pass the quiz, you will get a Credly badge:

The final course of this part is Building Custom Integrations and consists of 4 courses:

Learning Path sections

This course teaches you to build custom interoperability components in InterSystems ObjectScript to add to your InterSystems IRIS productions. 

The first part is a 4-minute video called Receiving and Routing Data in a Production and an exercise. It's the same exercise you've already done in the first part of the general course Get an introduction.

The second part is called "Build Custom Production Messages" and is a short video that shows an example of healthcare message.

The third part, "Design and Build Custom Components", consists of three courses and deals with respective parts of the interoperability:

  • Building Custom Business Operations
  • Building BPL Business Processes
  • Building Custom Business Services

The final part is the assessment. If you successfully pass it, you will receive a Credly Badge.

This course marks the end of the very long third part which is Develop an application.

The fourth part is Connect with an external language and gives you four choices based on the programming language you prefer. Your choices are:

  • Java
  • .NET
  • Node.js
  • Python

For this article, I chose to study Python. Python course consists of 4 parts:

loved that there is a Python for Beginners course for those who have yet to study this language.

The first part is the Overview of Python in InterSystems Products page, which shows you the ways you can use Python to work with IRIS.

The second part is a link to the documentation on using pyodbc to connect to IRIS from Python.

The third part, "Run Python side-by-side with ObjectScript", deals with Embedded Python and consists of two links to the documentation, a 4-minute video called "What is Embedded Python?" and two exercises. The first one, "Embedded Python QuickStart", gives you a general idea of what can be done with Embedded Python and how to use it to work with objects. And the second one, "Parsing Images and Charting Data with Embedded Python", gives you an example of using Embedded Python for a "real-world" task.

The last part, "Build InterSystems IRIS applications in Python," consists of a link to the documentation, two videos, and two exercises. It deals with connecting to IRIS from outside using Python and working with classes and globals. The first video, "Using the Native API for Python", briefly explains what is Native API for Python and how to use it. The second video, "Evaluating Python Development Strategies", gives the sample-based examples of using IRIS with Python: traditional client/server APIs, Embedded Python, and the Python Gateway.

The fifth part is Expand your expertise and it is optional. It gives you a general understanding of running IRIS in Docker, API manager and using Angular with IRIS.

At the end of the course, if you have completed all the compulsory parts, you can assess your knowledge. If you pass this assessment, you will get another Credly badge 😉

This is it for this Learning Path.

As you can see, it takes quite a bit of time, but it covers the most essential parts of working with IRIS. Some of the courses and exercises overlap, so it saves a bit of time, but still, it's quite a commitment. In my opinion, it's a great introduction to the IRIS database platform.

Overall, the main disadvantage for me in using this Learning Path as a part of the curriculum is the inability to prove that the student actually did all the tasks because, for the most part, you can just tick courses as passed, and that's it. The only exception is that you really have to pass the quizzes at the end of some parts, and the final quiz will become available only when you complete all the compulsory parts.


Disclaimer: All images are taken from the mentioned videos/courses and are the intellectual property of InterSystems.

2 comentarios
Comentarios (2)1
Inicie sesión o regístrese para continuar
Pregunta
· 22 jul, 2024

SQL Gateway getClob() errors in Redshift and Postgresql

I'm trying to use the EnsLib.SQL.Operation.GenericOperation component in a production to read a column from a Redshift table that is set up as VARCHAR(65535) and am getting the following error.  

An error was received : ERROR #5023: Remote Gateway Error: JDBC Gateway getClob(0,1) errorRemote JDBC error: Cannot convert the column of type VARCHAR to requested type long..

The query I'm using is a simple 'SELECT column_name FROM table_name'.  I've done a little research and it sounds like Redshift doesn't support getClob().  Is there anything I can do to force the gateway to not use getClob() on this Redshift column, or some other work around?  Casting the column in my select statement doesn't work... it seems the getClob() call is done under the hood by the gateway, and I would potentially need some way to override that?  

Thanks,

Don Martin, Sanford Health

5 comentarios
Comentarios (5)3
Inicie sesión o regístrese para continuar