intersystems-community / intersystems-servermanager

VS Code helper extension defining connections to InterSystems servers
https://marketplace.visualstudio.com/items?itemName=intersystems-community.servermanager
MIT License
13 stars 12 forks source link

Access error #138

Closed eduard93 closed 2 years ago

eduard93 commented 2 years ago

I'm getting an error trying to connect to a server with a user (without %ALL):

This server does not have specified namespace '%SYS'.
You must select one of the following: HSCUSTOM, HSLIB, USER.

But how do I specify a USER namespace as a default?

My settings.json looks like this:

{
    "intersystems.servers": {
        "myServer": {
            "webServer": {
                "scheme": "https",
                "host": "myaddress.com",
                "port": 443
            },
            "username": "eduard93",
        }
    }
}

In servers view I can view a list of namespaces but clicking on a Projects results in:

Cannot read properties of undefined (reading 'map')
eduard93 commented 2 years ago

I have validated that these queries work under eduard93 user (from the browser):

eduard93 commented 2 years ago

Clicking on a Projects as a %ALL user I see the same error.

But in VSCode explorer everything works.

gjsjohnmurray commented 2 years ago

Caused by the assumption made here.

https://github.com/intersystems-community/intersystems-servermanager/blob/4b4488e9c3b373f60cda066ab7c075a3be0b1b62/src/api/getPortalUriWithToken.ts#L26-L27

To run any query we need to specify a namespace.

I guess we should get the list of namespaces the user has access to and use the first one.

eduard93 commented 2 years ago

Is it hard to implement this change? USER could be a better default as a quick workaround.

eduard93 commented 2 years ago

@gjsjohnmurray are there any news on this issue?

Here's a pull request with a temporary workaround, please consider merging it: https://github.com/intersystems-community/intersystems-servermanager/pull/139

gjsjohnmurray commented 2 years ago

@eduard93 with Global Summit over I took a closer look at this issue. My previous response misdiagnosed the cause of the message you reported. The lines I pointed to are only used to try and pre-authenticate the Portal page when you use one of these command buttons in the Server Manager tree:

image

Based on my testing with a user who doesn't have the %DB_IRISSYS:R privilege, the only consequence is that they may have to enter credentials when launching Portal from Server Manager.

Your message actually comes from the vscode-objectscript extension here:

https://github.com/intersystems-community/vscode-objectscript/blob/14ded9b136f4f643990977a15ed0781c8f1137a0/src/api/index.ts#L445-L449

I'm guessing you're using the client-side editing paradigm, not server-side (isfs), right?

What does your objectscript.conn settings object contain? In particular, what is its ns property set to?

Please check this at the User level (i.e. your local settings.json file) and at the Workspace level (i.e. .vscode/settings.json in the folder you opened in VS Code).

eduard93 commented 2 years ago

@gjsjohnmurray Found it in the workspace. Looks like this:

{
    "objectscript.conn": {
        "server": "myServer",
        "ns": "USER",
        "active": true
    }
}
eduard93 commented 2 years ago

I see in console:

workbench.desktop.main.js:802 TypeError: Cannot read properties of undefined (reading 'map')
    at ProjectsTreeItem.<anonymous> (c:\Users\elebedyu\.vscode\extensions\intersystems-community.servermanager-2.0.9\out\ui\serverManagerView.js:429:46)
    at Generator.next (<anonymous>)
    at fulfilled (c:\Users\elebedyu\.vscode\extensions\intersystems-community.servermanager-2.0.9\out\ui\serverManagerView.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
eduard93 commented 2 years ago

That's here.

My user can execute SELECT Name, Description FROM %Studio.Project, but it returns no results.

I just need to browse the server.

gjsjohnmurray commented 2 years ago

@eduard93 please try the dev VSIX from the zip at https://github.com/intersystems-community/intersystems-servermanager/suites/7134425170/artifacts/283337062

With this, when you expand the Projects folder of a namespace and your user account doesn't have the %All role you should now see an error notification telling you the GRANT statement you need to run in that namespace (as a suitably privileged user).

gjsjohnmurray commented 2 years ago

@eduard93 the correction for this is now in 2.0.10-beta.3 which you can get at https://github.com/intersystems-community/intersystems-servermanager/releases/download/v2.0.10-beta.3/servermanager-2.0.10-beta.3.vsix

eduard93 commented 2 years ago

Thank you @gjsjohnmurray !

gjsjohnmurray commented 2 years ago

@eduard93 we have now published 2.0.10