Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeRed flow stops when callContext expires #10

Open
viveknarkhede opened this issue Jan 22, 2018 · 3 comments
Open

NodeRed flow stops when callContext expires #10

viveknarkhede opened this issue Jan 22, 2018 · 3 comments

Comments

@viveknarkhede
Copy link

If i have a node red flow which uses some of the oe-cloud offerings like find-data node or a model observer node, it should have a valid callContext linked to each msg of the flow to execute successfully. Usually this callContext gets merged with the msg object at the time of Deploying the flow. However my question here is, what will happen when the access_token associated with the msg callContext expires?
I have observed that flow doesn't work, as it fails to do find-data in absence of valid access_token.

So in order to keep running my node red flow, i need to keep deploying it after sometime so that the valid access_token remains attached always. Isn't it an additional overhead? Or i am missing something here?

@patelparthiv
Copy link

+1

@raghav135
Copy link
Member

It depends where you are using finddata, for example, if you are using within an observer, the callcontext of the observer will take presedence.

access token is not required for "find", right?

If you can give specific issue with sample node-red flow that you are using, it will help.

@viveknarkhede
Copy link
Author

I am using find-data directly in flow, not in observer. Find basically searches on a model based on the filter provided to it, and on model we have ACLs applied (Specific Role have access), so in order to fetch data from such model, context should have access_token of the User who belong to correct Role.

Flow example to search DefaultWorkGroup from Group Model:

[
    {
        "id": "866f64ab.1eb2a8",
        "type": "inject",
        "z": "f7b64739.6c3178",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 138.5,
        "y": 119,
        "wires": [
            [
                "87a08434.1eb078"
            ]
        ]
    },
    {
        "id": "87a08434.1eb078",
        "type": "find-data",
        "z": "f7b64739.6c3178",
        "name": "find data",
        "modelname": "Group",
        "filter": "{\"where\":{\"group_name\":\"DefaultWorkGroup\"}}",
        "x": 337.5,
        "y": 122,
        "wires": [
            [
                "ca1cbd19.6eb79"
            ],
            []
        ]
    },
    {
        "id": "ca1cbd19.6eb79",
        "type": "debug",
        "z": "f7b64739.6c3178",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "false",
        "x": 546.5,
        "y": 122,
        "wires": []
    }
]

Corresponding flow entries for it in NodeRedFlow collection:

[
  {
    "id": "866f64ab.1eb2a8",
    "type": "inject",
    "z": "f7b64739.6c3178",
    "name": "",
    "topic": "",
    "payload": "",
    "payloadType": "date",
    "repeat": "",
    "crontab": "",
    "once": false,
    "x": 138.5,
    "y": 119,
    "wires": [
      [
        "87a08434.1eb078"
      ]
    ],
    "callContext": {
      "ctx": {
        "remoteUser": "evadmin",
        "tenantId": "ae",
        "origin": "http://localhost:3000",
        "nodeRedDeploymentType": "full",
        "nodeRedApiVersion": "v2",
        "referer": "http://localhost:3000/red/",
        "acceptLanguage": "en-US,en;q=0.8",
        "lang": "en-US",
        "roles": [
          "ITAdmin",
          "admin"
        ],
        "username": "evadmin",
        "userTenantId": "ae",
        "userId": 1001,
        "currentWGName": "DefaultWorkGroup",
        "currentWGId": 1,
        "currentRole": "ITAdmin",
        "displayName": "evadmin"
      },
      "defaults": false,
      "ctxWeights": {
        "remoteUser": "1",
        "tenantId": "1",
        "origin": "1",
        "nodeRedDeploymentType": "1",
        "nodeRedApiVersion": "1",
        "referer": "1",
        "acceptLanguage": "1",
        "lang": "1",
        "roles": "1",
        "username": "1",
        "userTenantId": "1",
        "userId": "1",
        "currentWGName": "1",
        "currentWGId": "1",
        "currentRole": "1"
      },
      "txnId": "5a9fb150-00f6-11e8-adf8-adecfcfd076d",
      "modelName": "flows",
      "requestedWith": "XMLHttpRequest",
      "accessToken": "G8LQCyYgWCZaHKTQQLDo0x9ohiKDrvLmB7WM3OpMPrFr0m2cIgYe2hEykXwnZmOZ",
      "user-agent": {
        "ua": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
        "browser": {
          "name": "Chrome",
          "version": "56.0.2924.87",
          "major": "56"
        },
        "engine": {
          "name": "WebKit",
          "version": "537.36"
        },
        "os": {
          "name": "Windows",
          "version": "8.1"
        },
        "device": {
          "vendor": null,
          "model": null,
          "type": null
        },
        "cpu": {
          "architecture": "amd64"
        }
      },
      "whereKeysNodeRedFlow": []
    }
  },
  {
    "id": "87a08434.1eb078",
    "type": "find-data",
    "z": "f7b64739.6c3178",
    "name": "find data",
    "modelname": "Group",
    "filter": "{\"where\":{\"group_name\":\"DefaultWorkGroup\"}}",
    "x": 337.5,
    "y": 122,
    "wires": [
      [
        "ca1cbd19.6eb79"
      ],
      []
    ],
    "callContext": {
      "ctx": {
        "remoteUser": "evadmin",
        "tenantId": "ae",
        "origin": "http://localhost:3000",
        "nodeRedDeploymentType": "full",
        "nodeRedApiVersion": "v2",
        "referer": "http://localhost:3000/red/",
        "acceptLanguage": "en-US,en;q=0.8",
        "lang": "en-US",
        "roles": [
          "ITAdmin",
          "admin"
        ],
        "username": "evadmin",
        "userTenantId": "ae",
        "userId": 1001,
        "currentWGName": "DefaultWorkGroup",
        "currentWGId": 1,
        "currentRole": "ITAdmin",
        "displayName": "evadmin"
      },
      "defaults": false,
      "ctxWeights": {
        "remoteUser": "1",
        "tenantId": "1",
        "origin": "1",
        "nodeRedDeploymentType": "1",
        "nodeRedApiVersion": "1",
        "referer": "1",
        "acceptLanguage": "1",
        "lang": "1",
        "roles": "1",
        "username": "1",
        "userTenantId": "1",
        "userId": "1",
        "currentWGName": "1",
        "currentWGId": "1",
        "currentRole": "1"
      },
      "txnId": "5a9fb150-00f6-11e8-adf8-adecfcfd076d",
      "modelName": "flows",
      "requestedWith": "XMLHttpRequest",
      "accessToken": "G8LQCyYgWCZaHKTQQLDo0x9ohiKDrvLmB7WM3OpMPrFr0m2cIgYe2hEykXwnZmOZ",
      "user-agent": {
        "ua": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
        "browser": {
          "name": "Chrome",
          "version": "56.0.2924.87",
          "major": "56"
        },
        "engine": {
          "name": "WebKit",
          "version": "537.36"
        },
        "os": {
          "name": "Windows",
          "version": "8.1"
        },
        "device": {
          "vendor": null,
          "model": null,
          "type": null
        },
        "cpu": {
          "architecture": "amd64"
        }
      },
      "whereKeysNodeRedFlow": []
    }
  },
  {
    "id": "ca1cbd19.6eb79",
    "type": "debug",
    "z": "f7b64739.6c3178",
    "name": "",
    "active": true,
    "console": "false",
    "complete": "false",
    "x": 546.5,
    "y": 122,
    "wires": [],
    "callContext": {
      "ctx": {
        "remoteUser": "evadmin",
        "tenantId": "ae",
        "origin": "http://localhost:3000",
        "nodeRedDeploymentType": "full",
        "nodeRedApiVersion": "v2",
        "referer": "http://localhost:3000/red/",
        "acceptLanguage": "en-US,en;q=0.8",
        "lang": "en-US",
        "roles": [
          "ITAdmin",
          "admin"
        ],
        "username": "evadmin",
        "userTenantId": "ae",
        "userId": 1001,
        "currentWGName": "DefaultWorkGroup",
        "currentWGId": 1,
        "currentRole": "ITAdmin",
        "displayName": "evadmin"
      },
      "defaults": false,
      "ctxWeights": {
        "remoteUser": "1",
        "tenantId": "1",
        "origin": "1",
        "nodeRedDeploymentType": "1",
        "nodeRedApiVersion": "1",
        "referer": "1",
        "acceptLanguage": "1",
        "lang": "1",
        "roles": "1",
        "username": "1",
        "userTenantId": "1",
        "userId": "1",
        "currentWGName": "1",
        "currentWGId": "1",
        "currentRole": "1"
      },
      "txnId": "5a9fb150-00f6-11e8-adf8-adecfcfd076d",
      "modelName": "flows",
      "requestedWith": "XMLHttpRequest",
      "accessToken": "G8LQCyYgWCZaHKTQQLDo0x9ohiKDrvLmB7WM3OpMPrFr0m2cIgYe2hEykXwnZmOZ",
      "user-agent": {
        "ua": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
        "browser": {
          "name": "Chrome",
          "version": "56.0.2924.87",
          "major": "56"
        },
        "engine": {
          "name": "WebKit",
          "version": "537.36"
        },
        "os": {
          "name": "Windows",
          "version": "8.1"
        },
        "device": {
          "vendor": null,
          "model": null,
          "type": null
        },
        "cpu": {
          "architecture": "amd64"
        }
      },
      "whereKeysNodeRedFlow": []
    }
  }
]

If i remove the access_token (G8LQCyYgWCZaHKTQQLDo0x9ohiKDrvLmB7WM3OpMPrFr0m2cIgYe2hEykXwnZmOZ) from AuthSession collection or when it's ttl is expires, the flow doesn't output me the Group object and fails with Unexpected error 401. This seems correct as when we tries to search Model data from Swagger too, we need to set the access_token.

But how a flow (containing similar find-data node) will keep working, which gets triggered when a message comes into a queue or an email received and access_token attached to flow nodes (when flow was deployed from node-red UI) is now expired. To make it work i need to keep deploying flow on the access_token expiry interval, isn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants