Nouvelle publication

查找

Article
· Jan 6 2m de lecture

Causa e solução do erro <SLMSPAN> ao eliminar uma global

Rubrica de FAQ da InterSystems

Se você tentar eliminar uma global que está mapeada no nível de subscrito a partir do nó raiz, você receberá um erro e ela não será excluída. Isso ocorre porque o comando kill para globais mapeadas no nível de subscrito não pode ser usado atravessando mapeamentos.

// Suppose subscript-mapped globals exist in different databases, as shown below:
^TEST(A*~K*) -> database A
^TEST(L*~Z*) -> database B

// Trying to kill from the top level will result in a <SLMSPAN> error.
NAMESPACE>Kill ^TEST
<SLMSPAN> <- This error is output.

Para excluir apenas a global no namespace (banco de dados) atual, use o seguinte:

NAMESPACE>Kill ^["^^."]TEST

Globais mapeadas no nível de subscrito devem ser movidas para o banco de dados e eliminadas diretamente.

Para alternar para o banco de dados, use o seguinte:

zn "^^c:\intersystems\iris\mgr\user"
or
set $namespace="^^c:\intersystems\iris\mgr\user"

Ao importar globais com $System.OBJ.Load, o comportamento padrão é eliminar as globais antes de importá-las.
Como resultado, se as globais de destino estiverem mapeadas no nível de subscrito, ocorre um erro <SLMSPAN>. Nesse caso, especifique o parâmetro /mergeglobal como segundo argumento de $System.OBJ.Load, conforme abaixo, para evitar a eliminação prévia:

Set sc = $System.OBJ.Load(path," /mergeglobal",.errors)

enlightened [Referências]
Mapped globals cannot be exported.
How do I compile mapped classes and routines?

Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer
Article
· Jan 6 3m de lecture

Gerando JWT sem acesso aos certificados/chaves x509 do sistema

Se você quiser gerar um JWT a partir de um certificado/chave x509, qualquer operação (inclusive leitura) em %SYS.X509Credentials exige permissão U no recurso %Admin_Secure. O %Admin_Secure é necessário porque %SYS.X509Credentials é persistente e foi implementado dessa forma para impedir que todos os usuários tenham acesso às chaves privadas.

Se o recurso %Admin_Secure não estiver disponível em tempo de execução, você pode usar a seguinte alternativa.

Ao revisar o código de geração de JWT, descobri que o código de JWT utiliza %SYS.X509Credentials apenas como fonte de dados em tempo de execução para PrivateKey, PrivateKeyPassword, e Certificate. Como alternativa, você pode usar uma implementação não persistente da interface X.509 em tempo de execução, expondo apenas essas propriedades.Se você estiver usando interoperabilidade, o certificado/chave privada (Cert/PK) pode ser armazenado em credenciais para acesso seguro.

Class User.X509 Extends %RegisteredObject
{

Property PrivateKey As %VarString;
Property PrivateKeyPassword As %String;
Property Certificate As %VarString;
Property HasPrivateKey As %Boolean [ InitialExpression = {$$$YES} ];
ClassMethod GetX509() As User.X509
{
    set x509 = ..%New()
    set x509.PrivateKey = ..Key()
    set x509.Certificate = ..Cert()
    quit x509
}

/// Get X509 object from credential.
/// Username is a Cert, Password is a Private Key
ClassMethod GetX509FromCredential(credential) As User.X509
{
    set credentialObj = ##class(Ens.Config.Credentials).%OpenId(credential,,.sc)
    throw:$$$ISERR(sc) ##class(%Exception.StatusException).ThrowIfInterrupt(sc)
    
    set x509 = ..%New()
    set x509.PrivateKey = credentialObj.Password
    set x509.Certificate = credentialObj.Username
    quit x509
}

ClassMethod Key()
{
    q "-----BEGIN RSA PRIVATE KEY-----"_$C(13,10)
    _"YOUR_TEST_KEY"_$C(13,10)
    _"-----END RSA PRIVATE KEY-----"
}

ClassMethod Cert() As %VarString
{
    q "-----BEGIN CERTIFICATE-----"_$C(13,10)
    _"YOUR_TEST_CERT"_$C(13,10)
    _"-----END CERTIFICATE-----"
}

}

E você pode gerar o JWT da seguinte forma:

ClassMethod JWT() As %Status
{
    Set sc = $$$OK
    //Set x509 = ##class(%SYS.X509Credentials).GetByAlias("TempKeyPair")
    Set x509 = ##class(User.X509).GetX509()
    
    Set algorithm ="RS256"
    Set header = {"alg": (algorithm), "typ": "JWT"}
    Set claims= {"Key": "Value" }
    
    #; create JWK
    Set sc = ##class(%Net.JSON.JWK).CreateX509(algorithm,x509,.privateJWK)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    #; Create JWKS
    Set sc = ##class(%Net.JSON.JWKS).PutJWK(privateJWK,.privateJWKS)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    Set sc = ##Class(%Net.JSON.JWT).Create(header,,claims,privateJWKS,,.pJWT)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }
    
    Write pJWT
	Return sc
}

Como alternativa, você pode usar um objeto dinâmico para evitar a criação de uma classe; nesse caso, ficaria assim:

ClassMethod JWT(credential) As %Status
{
    Set sc = $$$OK
    //Set x509 = ##class(%SYS.X509Credentials).GetByAlias("TempKeyPair")
    Set credentialObj = ##class(Ens.Config.Credentials).%OpenId(credential,,.sc)
    throw:$$$ISERR(sc) ##class(%Exception.StatusException).ThrowIfInterrupt(sc)
    
    Set x509 = {
        "HasPrivateKey": true,
        "PrivateKey": (credentialObj.Password),
        "PrivateKeyPassword":"",
        "Certificate":(credentialObj.Username)
    }

    Set algorithm ="RS256"
    Set header = {"alg": (algorithm), "typ": "JWT"}
    Set claims= {"Key": "Value" }
    
    #; create JWK
    Set sc = ##class(%Net.JSON.JWK).CreateX509(algorithm,x509,.privateJWK)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    #; Create JWKS
    Set sc = ##class(%Net.JSON.JWKS).PutJWK(privateJWK,.privateJWKS)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    Set sc = ##Class(%Net.JSON.JWT).Create(header,,claims,privateJWKS,,.pJWT)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }
    
    Write pJWT
    Return sc
}
Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer
Question
· Jan 6

API Manager - Invite Admin" button missing and unable to bootstrap first RBAC user

Hi everyone,

I am currently setting up InterSystems API Manager (IAM) 3.4.3.11 using Docker. The installation is successful, the license is active, and I can access the Manager (port 8002).

I am now trying to secure the Administration Portal using basic-auth. I've found some documentation stating that I should:

  1. Go to the Teams section in the UI.
  2. Click on Invite Admin to create the first user.
  3. Only then, enable KONG_ENFORCE_RBAC and KONG_ADMIN_GUI_AUTH in the docker-compose.yml.

The Problem: When I access the Manager (with RBAC disabled), I do not see any "Invite Admin" button or "Teams" management section. It seems that without RBAC enabled, the UI doesn't show the Enterprise security features, but if I enable RBAC first, I am immediately locked out by the login page with no user to log in with.

My Setup:

  • Image: intersystems/iam:3.4
  • Goal: Enable basic-auth for the Admin Portal.

My Questions:

  1. How am I supposed to create the very first "Super Admin" user if the "Invite" button is missing from the UI?
  2. Is there a specific curl command to the Admin API (port 8001) to bootstrap this first user (creation + password + role) before enabling RBAC?
  3. In version 3.4, is there a default "bootstrap" environment variable I missed?

Any guidance or a working script to initialize the first admin would be greatly appreciated!

Thanks

Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer
Article
· Jan 6 8m de lecture

Introduction à l'interopérabilité sur Python (IoP) - Partie 1

Interoperability on Python (IoP) (Interopérabilité sur Python) est un projet de validation de concept conçu pour démontrer la puissance du cadre d'interopérabilité InterSystems IRIS lorsqu'il est associé à une approche axée sur Python. IoP exploite Embedded Python (une fonctionnalité d'InterSystems IRIS) pour permettre aux développeurs d'écrire des composants d'interopérabilité en Python, qui s'intègrent de manière transparente à la plateforme IRIS robuste. Ce guide a été conçu pour les débutants et fournit une introduction complète à l'IoP, à sa configuration et aux étapes pratiques pour créer votre premier composant d'interopérabilité. À la fin de cet article, vous comprendrez clairement comment utiliser l'IoP pour créer des solutions d'interopérabilité évolutives basées sur Python. IoP est particulièrement utile pour les développeurs qui travaillent avec InterSystems IRIS ou IRIS for Health, car il simplifie la création de services métier, de processus métier et d'opérations métier qui utilisent Python. Une telle approche réduit la dépendance à ObjectScript (le langage traditionnel pour le développement IRIS), le rendant plus accessible aux développeurs Python.


Pourquoi utilisons-nous IoP?

IoP offre plusieurs avantages aux développeurs:

  1. Dévelopment Python-First: Python est un langage largement adopté, convivial pour les débutants et doté d'un riche écosystème de bibliothèques. IoP permet aux développeurs de tirer parti de leur expertise Python au sein de l'écosystème IRIS.
  2. Interopérabilité simplifiée: IoP résume les configurations complexes basées sur ObjectScript, permettant un développement plus rapide des composants d'interopérabilité.
  3. Applications de santé Healthcare: IoP est particulièrement adapté aux intégrations dans le domaine de la santé, telles que celles impliquant FHIR (Fast Healthcare Interoperability Resources), grâce à la prise en charge robuste des normes de santé par IRIS for Health.
  4. Communauté et Open Source: IoP est disponible sur PyPI et GitHub et bénéficie d'un soutien actif de la communauté, notamment grâce aux contributions de développeurs tels que Guillaume Rongier (développeur évangéliste pour InterSystems).

Conditions préalables

Avant de vous lancer dans IoP, assurez-vous d'avoir les éléments suivants:

  • InterSystems IRIS ou IRIS for Health: une installation locale ou un conteneur Docker exécutant IRIS (la version Community Edition suffit pour les tests).
  • Python 3.10 ou version ultérieure: requis pour exécuter IoP et ses dépendances.
  • Connaissances de base en Python: bonne connaissance des classes, des fonctions et de l'installation des paquets Python.

Dans ce tutoriel, nous utiliserons à l'aide d'une installation IRIS locale pour créer une production InterSystems IRIS comportant une fonctionnalité basée sur Python qui enregistre un message 'Hello World' à la réception d'une requête. Cela devrait démontrer une intégration transparente avec le cadre d'interopérabilité IRIS.

Les étapes suivantes décrivent le processus permettant d'atteindre cet objectif :

  • Étape 1: configuration de l'environnement virtuel
  • Étape 2: installation du paquet IoP
  • Étape 3: configuration des variables d'environnement pour la connexion IRIS
  • Étape 4: initialisation du module IoP dans IRIS à l'aide de l'interface de ligne de commande (CLI)
  • Étape 5: création d'une opération métier Python: exemple Hello World
  • Étape 6: migration des composants IoP vers IRIS
  • Étape 7: aperçu de la production
  • Étape 8: Test du composant d'opération de production

 

Commençons par l'étape 1.

Étape1: configuration de l'environnement virtuel

Tout d'abord, configurez un environnement virtuel Python afin d'isoler les dépendances de votre projet et d'assurer la compatibilité avec IoP et InterSystems IRIS. Un environnement virtuel est un répertoire autonome contenant une version spécifique de Python et les packages requis pour votre projet. Une telle configuration évite les conflits avec d'autres projets Python et rationalise le processus de développement. Pour ce tutoriel, créez un dossier nommé IOP afin d'organiser vos fichiers de projets.

Accédez au dossier IOP et exécutez la commande suivante pour configurer l'environnement virtuel:

python -m venv .venv

Cette commande crée un répertoire .venv dans votre dossier IOP, contenant un interpréteur Python et tous les paquets que vous installez pour votre projet IoP.

Pour activer l'environnement virtuel sous Windows, exécutez la commande suivante:

.venv\Scripts\activate

 

Pour Unix ou MacOS, utilisez la commande suivante:

source .venv/bin/activate

 

Étape 2: installation du paquet IoP

Une fois votre environnement virtuel activé, installez le paquet iris-pex-embedded-python, dépendance principale de votre projet IoP, afin d'activer l'interopérabilité basée sur Python au moyen d'InterSystems IRIS. Exécutez la commande suivante dans votre terminal:

pip install iris-pex-embedded-python

Cette commande installe le paquet iris-pex-embedded-python et ses dépendances à partir du Python Package Index (PyPI) dans votre environnement virtuel. Après l'installation, vous pouvez utiliser le module IoP à l'aide de composants d'interopérabilité basés sur Python, tels que les activités commerciales pour votre projet IoP.

 

Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer
Article
· Jan 5 1m de lecture

クロスプラットフォームで開発する際のちょっとした落とし穴

MacOS(Linux)とWindows両方で動作するObjectScriptプログラムを開発する際に、よくやらかしてしまうミスを共有します。

WindowsとUNIX系のファイルシステムの1つの違いは、ディレクトリのセパレータです。

UNIX系は、/(スラッシュ)

Windows系は、\(バックスラッシュ)

です。

ファイルを読み書きするプログラムでセパレータをOS別に選択するという以下のようなコードをよく書くのですが、

if ($system.Version.GetOS() = "UNIX") {
    set sep = "/"
}
else {
    set sep = "\"
}

 

ここでこのバックスラッシュをキーボードで入力すると、日本語キーボードの場合、バックスラッシュの代わりに¥(円マーク)が入力されてしまいます。

ソースコードがSJISの場合は、これでも問題ないのですが、クロスプラットフォームで開発する場合は、UTF8で通常作成するので、Macで動かすと問題ないのにWindowsで動かすとエラーになるということがちょくちょく起こります。

そして、これは意外に間違いに気づきにくいです。

ちなみにPythonでは、どちらでも/を使っておけば問題ないので、こんな問題は起こることはないと思います。

3 Comments
Discussion (3)1
Connectez-vous ou inscrivez-vous pour continuer