i2group / analyze-connect-node-sdk

Develop connectors that bring data from external sources into i2 Analyze by using the i2 Connect Node SDK. The SDK is comprised of documentation, tools, and sample code.
https://i2group.github.io/analyze-connect-node-sdk/
MIT License
3 stars 3 forks source link

services.IRequestInformation.user has no data #14

Closed CharlesMarriott-VA closed 10 months ago

CharlesMarriott-VA commented 11 months ago

Morning.

I'm having issues with services.IRequestInformation.user.

When I try to call this, it appears that it's not storing any data. I'm simply trying to hide services based on the groups the user is assigned to.

For example, we have the standard 'Jenny' user and I try to simply log if this user is an Analyst as per the test below:

if (requestInformation.user.groups.includes('Analyst')) {
        console.log("I AM AN ANALYST!");
      } else {
        console.log("I SHOULD NOT PRINT!");
      }

Running the above, it logs I SHOULD NOT PRINT.

If I try to log what groups the user is in, it is blank.

Could you point me in the direction of getting this to work?

Anthony-Johnson-i2 commented 11 months ago

Hi @CharlesMarriott-VA

I suspect, as you say it is empty, that the reason you are experiencing this is that the connector has not been set up to send the sensitive header information required for this.

Looking at our documentation I can see we don't seem to mention this anywhere.

I did find reference to it when searching our knowledge base as part of some Fixpack notes here

At the bottom of that it says:

Enabling user information to be sent to a connector in header messages
By default, user information is not sent to a connector in header messages. To enable this information being sent to the connector do the following:

Update topology.xml and add send-sensitive-headers="true" to all appropriate connector entries.
For example:
<connector base-url="[http://localhost:3700/"](http://localhost:3700/)" name="Example Connector" id="example-connector" send-sensitive-headers="true"/>
Redeploy and restart each Liberty server.

In the deployed Liberty/Gateway you can see this gets written to connectors.json

We will get the documentation improved so that we include reference to this.

Cheers

Gregory-Matthews-i2 commented 11 months ago

Hi @CharlesMarriott-VA,

it sounds like you're trying to generate user specific configurations. You can find information and an example of how to do this here: https://i2group.github.io/analyze-connect/content/example-connectors/user-configuration.html#enable-user-specific-configurations

The connector needs to be configured to declare that it is going to provide user specific configurations, and the i2 Connect Gateway needs to be configured to send sensitive header information. Both of these are illustrated in the link above.

Anthony-Johnson-i2 commented 11 months ago

Hi @CharlesMarriott-VA

I am just checking to see if, given the responses above, you were able to resolve your issue?

Cheers

Anthony-Johnson-i2 commented 10 months ago

Closing this issue as the responses given should have solved this and there has been no reply.