我有一个 KONG 容器正在运行,我想向其中添加一个自定义插件,特别是JWT Crafter。我已经下载了插件,但我不知道如何让它从我的 KONG 容器开始。所以请如果有人进入相同的位置或知道任何可遵循的路线,这将非常有帮助。
在 AWS API Gateway 中,
- 我们可以设置一个资源来请求 API Key 进行访问。
- 我们还可以设置另一个需要授权的资源(例如 JWT 令牌,通过 lambda 函数或 AWS Cognito 处理)。
问题:我们可以将资源配置为在上述两种情况中的任何一种情况下都可以访问吗?目前,如果我们同时启用“API Key Required”和“Authorization”,则请求同时需要 API Key 和 Authorization。我们希望它通过两者中的一个。
破解/解决方法:创建相同资源的两个副本,并分别授权每个副本,一个使用 API 密钥,另一个使用授权方。
我使用 Krakend 作为 API 网关,我的配置如下所示:
{
"plugin": {
"folder": "/etc/krakend/plugins/authenticator/",
"pattern":".so"
},
"port": 8080,
"extra_config": {
"github_com/devopsfaith/krakend/transport/http/server/handler": {
"name": "authenticator"
}
},
"endpoints": [
{
"output_encoding": "no-op",
"backend": [
{
"encoding": "no-op",
"host": [
"127.0.0.1:8080"
],
"url_pattern": "/api/v1/address/{id}",
"method": "GET"
}
],
"endpoint": "/api/v1/addresses/{id}",
"method": "GET"
}
],
"name": "gateway",
"timeout": "30s",
"version": 2
}
Run Code Online (Sandbox Code Playgroud)
我想为每个端点传递一些元数据并在我的预定义插件中访问它。在这种情况下authenticator插件。
大家好,我正在使用 API 网关来公开 API,当我调用 API 时,它会返回header调用x-amz-apigw-id=some_value。这个标题是什么意思?
这不等于我的API网关ID,我发现一些博客说这是base64编码字符串。我尝试解码,但没有检索到我的原始 API 网关 ID
我已经去了为什么 springfox-swagger2 UI 告诉我“无法推断基本 url”。并且在使用 Spring Boot 配置 Swagger并且根本不使用 Spring Security 时获得意外结果,对于每个服务,我使用的是@EnableSwagger2注释。
我正在关注链接中的教程:https : //dzone.com/articles/quick-guide-to-microservices-with-spring-boot-20-e并gateway-service用于项目运行而不是proxy-service.
网关服务.yml
server:
port: 8060
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8061/eureka/
logging:
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} ${LOG_LEVEL_PATTERN:-%5p} %m%n"
spring:
cloud:
gateway:
discovery:
locator:
enabled: true
routes:
- id: employee-service
uri: lb://employee-service
predicates:
- Path=/employee/**
filters:
- RewritePath=/employee/(?<path>.*), /$\{path}
- id: department-service
uri: lb://department-service
predicates:
- Path=/department/**
filters:
- RewritePath=/department/(?<path>.*), /$\{path}
- id: organization-service …Run Code Online (Sandbox Code Playgroud) 我一直在努力通过aws提供的回调url(https://******.execute-api.us-east-1.amazonaws.com/test/@connections)向连接的客户端发送响应。
在我的后端中有以下代码来发送响应,这是一种单向通信。
AwsClientBuilder.EndpointConfiguration config =
new AwsClientBuilder.EndpointConfiguration("https://*********.execute-api.us-east-1.amazonaws.com/test", "us-east-1");
AmazonApiGatewayManagementApi client = AmazonApiGatewayManagementApiClientBuilder.standard()
.withEndpointConfiguration(config).build();
PostToConnectionRequest request = new PostToConnectionRequest();
request.withConnectionId("bGYcWek5oAMCKwA=");
Charset charset = Charset.forName("UTF-8");
CharsetEncoder encoder = charset.newEncoder();
ByteBuffer buff = null;
try {
buff = encoder.encode(CharBuffer.wrap("Hello from lambda"));
} catch (CharacterCodingException e) {
log.error("Error while encoding", e);
}
request.withData(buff);
PostToConnectionResult result = client.postToConnection(request);
log.info("Result of websocket send:\n" + result);
Run Code Online (Sandbox Code Playgroud)
获取服务:AmazonApiGatewayManagementApi;状态代码:403;错误代码:InvalidSignatureException异常。
注意:我已经设置了所有内容,例如证书和 aws 访问密钥。
正如 aws 文档中提到的,我尝试过使用awscurl,它有效。我可以在 websocket 连接的客户端上看到响应。 https://docs.amazonaws.cn/en_us/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html
目前还没有专门集成 API 网关和 Codebuild 的实际指南,因此我正在研究几个并尝试适应。
我已根据本文档设置了我的角色和策略,并且已成功设置并运行了我的 CodeBuild 项目。
我已经设置了一个 POST 端点,参考CodeBuild API 文档中的操作:
我正在使用端点的测试选项卡来发送
{ "project": "my-project" }
但我得到了这个回应
{
"Output": {
"__type": "com.amazon.coral.service#UnknownOperationException",
"message": null
},
"Version": "1.0"
}
Run Code Online (Sandbox Code Playgroud)
日志
Execution log for request b0ee0d54-c1d0-11e9-9ff3-e9448aaf711c
Sun Aug 18 15:56:07 UTC 2019 : Starting execution for request: b0ee0d54-c1d0-11e9-9ff3-e9448aaf711c
Sun Aug 18 15:56:07 UTC 2019 : HTTP Method: POST, Resource Path: /vegankit/stage
Sun Aug 18 15:56:07 UTC 2019 : Method request path: {}
Sun Aug 18 15:56:07 UTC …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-api-gateway aws-codebuild api-gateway
如何设置time-outa spring cloud gateway?
routeLocatorBuilder.routes()
.route("test-api", r -> r.path("/api/**")).uri(apiLb))
.route("test-doc", r -> r.path("/doc/**")).uri(docLb));
Run Code Online (Sandbox Code Playgroud)
有没有办法只为一个人设置一个超时ROUTE- doc.
我一直在尝试跨多个 SAM 模板使用单个 APIGateway。为此,我尝试从其他 SAM 模板上的基本模板导入 RestApiId,并在 lambda 的事件部分下使用它。但 SAM 有限制说
RestApiId 必须是对同一模板中“AWS::Serverless::Api”资源的有效引用。
经过3个小时的研究,我了解到我们可以通过在基础模板中定义API网关并创建角色/策略/定义来实现它,以便允许调用所需的功能。将 Lambda 拆分为多个仅 Lambda 的 SAM 文件,但在其下不定义任何 Api 类型事件。这样,我们就可以创建彼此独立的 Lambda 和 API Gateway,并使用 Swagger/OpenAPI 进行集成并分别安排权限。
以下是推荐上述方法的有用链接。
我觉得这种方法有点复杂,如果 API 在 swagger 文件上得到更多,这可能会超出基本模板的 CFN 200 限制。如果有人建议一种更简单的方法来跨不同模板导入 apiGateway,我将不胜感激。
amazon-web-services aws-lambda aws-api-gateway api-gateway serverless-application-model
我已成功在以前版本的 NextJS 中使用页面/api 路由连接到 AWS API Gateway。我正在尝试使用新的应用程序路由器在 app/api/route 中执行相同的操作。但我无法让aws-amplify图书馆工作,即
const {Auth: ssrAuth} = withSSRContext({ req: request }); //works
const user = await ssrAuth.currentAuthenticatedUser(); //fails
Run Code Online (Sandbox Code Playgroud)
这与页面路由器配合得很好,我能够获取用户令牌以将授权者附加到 API 网关请求。
知道为什么吗?请求就在那里,我可以看到带有用户令牌的 cookie。我究竟做错了什么?
非常感谢任何反馈/提示
api-gateway aws-amplify aws-amplify-sdk-js nextjs-dynamic-routing next.js13
api-gateway ×10
java ×2
spring ×2
api ×1
api-key ×1
aws-amplify ×1
aws-lambda ×1
docker ×1
dockerfile ×1
go ×1
kong ×1
krakend ×1
next.js13 ×1
serverless-application-model ×1
spring-boot ×1
swagger ×1
websocket ×1