简体   繁体   English

Express Gateway 向端点添加作用域

[英]Express Gateway adding scopes to endpoints

I have a working autoregister gateway function, which fills my gateway-config.yml.我有一个工作自动注册网关 function,它填充了我的 gateway-config.yml。 We will be using scopes so I added scopes to postData, but it doesn't add scopes.我们将使用范围,所以我将范围添加到 postData,但它不会添加范围。

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[...] currentKey 和 Scopes[...] 的一些控制台日志

/api/users - undefined /api/用户 - 未定义

/api/token - undefined /api/令牌 - 未定义

/api/createProject - PROJECT-MANAGER /api/createProject - 项目管理器

Also, when the scope is undefined, it adds the endpoint, if it is not undefined (project-manager) it didn't even add the endpoint.此外,当 scope 未定义时,它会添加端点,如果它不是未定义的(项目经理),它甚至不会添加端点。 I tried hard codding scopes to something and it still didn't work我尝试将示波器编码到某些东西上,但仍然没有用

You shouldn't send scopes in the POST request;您不应该在 POST 请求中发送范围; they are strictly internal to Express Gateway.它们严格属于 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;当用户通过 Express Gateway 进行身份验证时,Express 的 config.yml 文件中定义的用户身份验证凭据应包括用户有权访问的范围列表; these are used internally by Express Gateway to control access to endpoints.这些由 Express Gateway 在内部使用以控制对端点的访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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