简体   繁体   中英

Express Gateway adding scopes to endpoints

I have a working autoregister gateway function, which fills my gateway-config.yml. We will be using scopes so I added scopes to postData, but it doesn't add scopes.

const postData = JSON.stringify({
      host: '*',
      path: currentKey,
      methods: methodsByPaths.get(currentKey),
      scopes:
        Scopes[`${process.env.ENDPOINT}${currentKey.split('/').join('')}`],
    });
  • Some console log of currentKey and the Scopes[...]

/api/users - undefined

/api/token - undefined

/api/createProject - PROJECT-MANAGER

Also, when the scope is undefined, it adds the endpoint, if it is not undefined (project-manager) it didn't even add the endpoint. I tried hard codding scopes to something and it still didn't work

You shouldn't send scopes in the POST request; they are strictly internal to Express Gateway.

When a user is authenticated by Express Gateway, the authentication credential defined in Express's config.yml file the user is authenticated against should include the list of scopes the user has access to; these are used internally by Express Gateway to control access to endpoints.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM