mirror of
https://github.com/alibaba/higress.git
synced 2026-02-25 21:21:01 +08:00
Compare commits
9 Commits
v1.0.0-rc.
...
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e68ae75d1 | ||
|
|
18ad817edb | ||
|
|
d48e0ce773 | ||
|
|
9734ffeb3e | ||
|
|
1421ce8667 | ||
|
|
625c06e58f | ||
|
|
e4a47dfb46 | ||
|
|
6b483189ac | ||
|
|
74ad9a555a |
@@ -139,8 +139,8 @@ install: pre-install
|
||||
cd helm/higress; helm dependency build
|
||||
helm install higress helm/higress -n higress-system --create-namespace --set 'global.local=true'
|
||||
|
||||
ENVOY_LATEST_IMAGE_TAG ?= 1.0.0-rc
|
||||
ISTIO_LATEST_IMAGE_TAG ?= 1.0.0-rc
|
||||
ENVOY_LATEST_IMAGE_TAG ?= 1.0.0
|
||||
ISTIO_LATEST_IMAGE_TAG ?= 1.0.0
|
||||
|
||||
install-dev: pre-install
|
||||
helm install higress helm/core -n higress-system --create-namespace --set 'controller.tag=$(TAG)' --set 'gateway.replicas=1' --set 'gateway.tag=$(ENVOY_LATEST_IMAGE_TAG)' --set 'global.local=true'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
apiVersion: v2
|
||||
appVersion: 1.0.0-rc
|
||||
appVersion: 1.0.0
|
||||
description: Helm chart for deploying higress gateways
|
||||
icon: https://higress.io/img/higress_logo_small.png
|
||||
home: http://higress.io/
|
||||
@@ -10,4 +10,4 @@ name: higress-core
|
||||
sources:
|
||||
- http://github.com/alibaba/higress
|
||||
type: application
|
||||
version: 1.0.0-rc
|
||||
version: 1.0.0
|
||||
|
||||
@@ -95,3 +95,9 @@ higress: {{ include "controller.name" . }}
|
||||
{{- print "first-party-jwt" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "skywalking.enabled" -}}
|
||||
{{- if and .Values.skywalking.enabled .Values.skywalking.service.address }}
|
||||
true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -122,7 +122,7 @@ data:
|
||||
{{- include "mesh" . }}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if .Values.enableSkywalking }}
|
||||
{{- if include "skywalking.enabled" . }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
@@ -154,7 +154,6 @@ data:
|
||||
"type": "LOGICAL_DNS",
|
||||
"connect_timeout": "5s",
|
||||
"http2_protocol_options": {
|
||||
|
||||
},
|
||||
"dns_lookup_family": "V4_ONLY",
|
||||
"lb_policy": "ROUND_ROBIN",
|
||||
@@ -167,8 +166,8 @@ data:
|
||||
"endpoint": {
|
||||
"address": {
|
||||
"socket_address": {
|
||||
"address": "{{ .Values.Skywalking.address }}",
|
||||
"port_value": "{{ .Values.Skywalking.port }}"
|
||||
"address": "{{ .Values.skywalking.service.address }}",
|
||||
"port_value": "{{ .Values.skywalking.service.port }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ spec:
|
||||
value: "{{ $.Values.clusterName | default `Kubernetes` }}"
|
||||
- name: INSTANCE_NAME
|
||||
value: "higress-gateway"
|
||||
{{- if .Values.enableSkywalking }}
|
||||
{{- if include "skywalking.enabled" . }}
|
||||
- name: ISTIO_BOOTSTRAP_OVERRIDE
|
||||
value: /etc/istio/custom-bootstrap/custom_bootstrap.json
|
||||
{{- end }}
|
||||
@@ -202,7 +202,7 @@ spec:
|
||||
mountPath: /etc/istio/pod
|
||||
- name: proxy-socket
|
||||
mountPath: /etc/istio/proxy
|
||||
{{- if .Values.enableSkywalking }}
|
||||
{{- if include "skywalking.enabled" . }}
|
||||
- mountPath: /etc/istio/custom-bootstrap
|
||||
name: custom-bootstrap-volume
|
||||
{{- end }}
|
||||
@@ -242,7 +242,7 @@ spec:
|
||||
- name: config
|
||||
configMap:
|
||||
name: higress-config
|
||||
{{- if .Values.enableSkywalking }}
|
||||
{{- if include "skywalking.enabled" . }}
|
||||
- configMap:
|
||||
defaultMode: 420
|
||||
name: higress-custom-bootstrap
|
||||
|
||||
@@ -45,7 +45,7 @@ global:
|
||||
# Dev builds from prow are on gcr.io
|
||||
hub: higress-registry.cn-hangzhou.cr.aliyuncs.com/higress
|
||||
# Default tag for Istio images.
|
||||
tag: 1.0.0-rc
|
||||
tag: 1.0.0
|
||||
|
||||
# Specify image pull policy if default behavior isn't desired.
|
||||
# Default behavior: latest images will be Always else IfNotPresent.
|
||||
@@ -369,7 +369,7 @@ gateway:
|
||||
name: "higress-gateway"
|
||||
replicas: 2
|
||||
image: gateway
|
||||
tag: "1.0.0-rc"
|
||||
tag: "1.0.0"
|
||||
# revision declares which revision this gateway is a part of
|
||||
revision: ""
|
||||
|
||||
@@ -457,7 +457,7 @@ controller:
|
||||
name: "higress-controller"
|
||||
replicas: 1
|
||||
image: higress
|
||||
tag: "1.0.0-rc"
|
||||
tag: "1.0.0"
|
||||
env: {}
|
||||
|
||||
labels: {}
|
||||
@@ -547,7 +547,7 @@ pilot:
|
||||
rollingMaxUnavailable: 25%
|
||||
|
||||
hub: higress-registry.cn-hangzhou.cr.aliyuncs.com/higress
|
||||
tag: 1.0.0-rc
|
||||
tag: 1.0.0
|
||||
|
||||
# Can be a full hub/image:tag
|
||||
image: pilot
|
||||
@@ -610,7 +610,8 @@ pilot:
|
||||
|
||||
|
||||
# Skywalking config settings
|
||||
enableSkywalking: false
|
||||
Skywalking:
|
||||
address: "skywalking-oap.higress-system.svc"
|
||||
port: 11800
|
||||
skywalking:
|
||||
enabled: false
|
||||
service:
|
||||
address: ~
|
||||
port: 11800
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
dependencies:
|
||||
- name: higress-core
|
||||
repository: file://../core
|
||||
version: 1.0.0-rc
|
||||
version: 1.0.0
|
||||
- name: higress-console
|
||||
repository: https://higress.io/helm-charts/
|
||||
version: 1.0.0-rc.2
|
||||
digest: sha256:6cd5c09946a6d365b03fe9bd5e8cf266bc8bdc94017fae8703920a2cb700e4f7
|
||||
generated: "2023-05-09T17:16:27.7257491+08:00"
|
||||
version: 1.0.0
|
||||
digest: sha256:fb0f1b6816df5f5ac6888a93fb148b55b669affc9ac99336dd1ac818b8f84ace
|
||||
generated: "2023-05-22T17:42:02.506864+08:00"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
apiVersion: v2
|
||||
appVersion: 1.0.0-rc.2
|
||||
appVersion: 1.0.0
|
||||
description: Helm chart for deploying Higress gateways
|
||||
icon: https://higress.io/img/higress_logo_small.png
|
||||
home: http://higress.io/
|
||||
@@ -12,9 +12,9 @@ sources:
|
||||
dependencies:
|
||||
- name: higress-core
|
||||
repository: "file://../core"
|
||||
version: 1.0.0-rc
|
||||
version: 1.0.0
|
||||
- name: higress-console
|
||||
repository: "https://higress.io/helm-charts/"
|
||||
version: 1.0.0-rc.2
|
||||
version: 1.0.0
|
||||
type: application
|
||||
version: 1.0.0-rc.2
|
||||
version: 1.0.0
|
||||
|
||||
@@ -244,12 +244,14 @@ public class GenerateJwtDemo {
|
||||
- 只有当`from_headers`,`from_params`,`from_cookies`均未配置时,才会使用默认值
|
||||
|
||||
`from_headers` 中每一项的配置字段说明如下:
|
||||
|
||||
| 名称 | 数据类型 | 填写要求| 默认值 | 描述 |
|
||||
| ---------------- | --------------- | ------- | ------ | --------------------------------------------------------- |
|
||||
| `name` | string | 必填 | - | 抽取JWT的请求header |
|
||||
| `value_prefix` | string | 必填 | - | 对请求header的value去除此前缀,剩余部分作为JWT |
|
||||
|
||||
`claims_to_headers` 中每一项的配置字段说明如下:
|
||||
|
||||
| 名称 | 数据类型 | 填写要求| 默认值 | 描述 |
|
||||
| ---------------- | --------------- | ------- | ------ | --------------------------------------------------------- |
|
||||
| `claim` | string | 必填 | - | JWT payload中的指定字段,要求必须是字符串或无符号整数类型 |
|
||||
|
||||
@@ -390,10 +390,10 @@ consumers:
|
||||
```
|
||||
|
||||
# Common Error Codes
|
||||
|
|
||||
HTTP Status Code | Error Message | Reason Description|
|
||||
| ----------- | ---------------------- | -------------------------------------------------------------------------------- |
|
||||
| 401 | JWT missing | The JWT is not provided in the request header. |
|
||||
| 401 | JWT expired | The JWT has expired. |
|
||||
| 401 | JWT verification fails | The JWT payload verification failed, such as the iss mismatch. |
|
||||
| 403 | Access denied | Access to the current route is denied. |
|
||||
|
||||
| HTTP Status Code | Error Message | Reason Description|
|
||||
|------------------| ---------------------- | -------------------------------------------------------------------------------- |
|
||||
| 401 | JWT missing | The JWT is not provided in the request header. |
|
||||
| 401 | JWT expired | The JWT has expired. |
|
||||
| 401 | JWT verification fails | The JWT payload verification failed, such as the iss mismatch. |
|
||||
| 403 | Access denied | Access to the current route is denied. |
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
| limit_keys | array of object | 必填 | - | 配置匹配键值后的限流次数 |
|
||||
|
||||
`limit_keys`中每一项的配置字段说明
|
||||
|
||||
| 名称 | 数据类型 | 填写要求 | 默认值 | 描述 |
|
||||
| -------- | -------- | -------- | -------- | -------- |
|
||||
| key | string | 必填 | - | 匹配的键值 |
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
| limit_keys | array of object | Required | - | Rate-limiting thresholds when matching specific key-values |
|
||||
|
||||
Field descriptions of `limit_keys` items:
|
||||
|
||||
| Name | Type | Requirement | Default Value | Description |
|
||||
| -------- | -------- | -------- | -------- | -------- |
|
||||
| key | string | Required | - | Value to match of the specific key |
|
||||
|
||||
@@ -26,6 +26,7 @@ build:
|
||||
build-image:
|
||||
DOCKER_BUILDKIT=1 docker build --build-arg PLUGIN_NAME=${PLUGIN_NAME} \
|
||||
--build-arg BUILDER=${BUILDER} \
|
||||
--build-arg GOPROXY=$(GOPROXY) \
|
||||
-t ${IMG} \
|
||||
--load \
|
||||
.
|
||||
|
||||
@@ -100,10 +100,6 @@ curl 'https://api.github.com/graphql' -X POST \
|
||||
| `gql` | graphql 查询 | 不能为空 |
|
||||
| `endpoint` | graphql 查询端点 | `/graphql` |
|
||||
| `timeout` | 查询连接超时,单位毫秒 | `5000` |
|
||||
| `serviceSource` | 服务来源:k8s, nacos,dns, ip | 不能为空 |
|
||||
| `serviceName` | 服务名称 | 不能为空 |
|
||||
| `servicePort` | 服务端口 | 不能为空 |
|
||||
| `namespace` | 服务命名空间, 当服务来源是nacos需要配置 | |
|
||||
| `domain` | 服务域名,当服务来源是dns配置 | |
|
||||
|
||||
### 插件使用
|
||||
@@ -158,9 +154,6 @@ spec:
|
||||
config:
|
||||
timeout: 5000
|
||||
endpoint: /graphql
|
||||
serviceSource: dns
|
||||
serviceName: github
|
||||
servicePort: 443
|
||||
domain: api.github.com
|
||||
gql: |
|
||||
query ($owner:String! $name:String!){
|
||||
|
||||
@@ -16,7 +16,6 @@ package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -46,10 +45,10 @@ type Variable struct {
|
||||
}
|
||||
|
||||
type DeGraphQLConfig struct {
|
||||
client wrapper.HttpClient
|
||||
gql string
|
||||
endpoint string
|
||||
timeout uint32
|
||||
domain string
|
||||
variables []Variable
|
||||
}
|
||||
|
||||
@@ -63,6 +62,14 @@ func (d *DeGraphQLConfig) SetEndpoint(endpoint string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DeGraphQLConfig) GetDomain() string {
|
||||
return d.domain
|
||||
}
|
||||
|
||||
func (d *DeGraphQLConfig) SetDomain(domain string) {
|
||||
d.domain = domain
|
||||
}
|
||||
|
||||
func (d *DeGraphQLConfig) GetEndpoint() string {
|
||||
return d.endpoint
|
||||
}
|
||||
@@ -79,14 +86,6 @@ func (d *DeGraphQLConfig) SetTimeout(timeout uint32) {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DeGraphQLConfig) SetClient(client wrapper.HttpClient) {
|
||||
d.client = client
|
||||
}
|
||||
|
||||
func (d *DeGraphQLConfig) GetClient() wrapper.HttpClient {
|
||||
return d.client
|
||||
}
|
||||
|
||||
func (d *DeGraphQLConfig) SetGql(gql string) error {
|
||||
if strings.TrimSpace(gql) == "" {
|
||||
return errors.New("gql can't be empty")
|
||||
|
||||
@@ -22,7 +22,7 @@ static_resources:
|
||||
- match:
|
||||
prefix: "/api"
|
||||
route:
|
||||
cluster: mock_service
|
||||
cluster: github
|
||||
http_filters:
|
||||
- name: envoy.filters.http.wasm
|
||||
typed_config:
|
||||
@@ -35,9 +35,6 @@ static_resources:
|
||||
value: |-
|
||||
{
|
||||
"gql": "query ($owner:String! $name:String!){\n repository(owner:$owner, name:$name) {\n name\n forkCount\n description\n}\n}",
|
||||
"serviceSource": "dns",
|
||||
"serviceName": "github",
|
||||
"servicePort": 443,
|
||||
"domain": "api.github.com",
|
||||
"endpoint": "/graphql",
|
||||
"timeout": 2000
|
||||
@@ -96,7 +93,7 @@ static_resources:
|
||||
socket_address:
|
||||
address: 127.0.0.1
|
||||
port_value: 8099
|
||||
- name: outbound|443||github.dns
|
||||
- name: github
|
||||
connect_timeout: 0.5s
|
||||
type: STRICT_DNS
|
||||
lb_policy: ROUND_ROBIN
|
||||
@@ -107,7 +104,7 @@ static_resources:
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
|
||||
load_assignment:
|
||||
cluster_name: outbound|443||github.dns
|
||||
cluster_name: github
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
|
||||
@@ -2,6 +2,8 @@ module de-graphql
|
||||
|
||||
go 1.19
|
||||
|
||||
replace github.com/alibaba/higress/plugins/wasm-go => ../..
|
||||
|
||||
require (
|
||||
github.com/alibaba/higress/plugins/wasm-go v0.0.0-20230410091208-df60dd43079c
|
||||
github.com/stretchr/testify v1.8.0
|
||||
|
||||
@@ -51,11 +51,9 @@ spec:
|
||||
description
|
||||
}
|
||||
}
|
||||
serviceName: github
|
||||
servicePort: 443
|
||||
serviceSource: dns
|
||||
timeout: 5000
|
||||
configDisable: false
|
||||
ingress:
|
||||
- github-api
|
||||
url: oci://docker.io/2456868764/de-graphql:1.0.0
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
@@ -42,7 +41,8 @@ func parseConfig(json gjson.Result, config *config.DeGraphQLConfig, log wrapper.
|
||||
gql := json.Get("gql").String()
|
||||
endpoint := json.Get("endpoint").String()
|
||||
timeout := json.Get("timeout").Int()
|
||||
log.Debugf("gql:%s endpoint:%s timeout:%d", gql, endpoint, timeout)
|
||||
domain := json.Get("domain").String()
|
||||
log.Debugf("gql:%s endpoint:%s timeout:%d domain:%s", gql, endpoint, timeout, domain)
|
||||
err := config.SetGql(gql)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -52,48 +52,7 @@ func parseConfig(json gjson.Result, config *config.DeGraphQLConfig, log wrapper.
|
||||
return err
|
||||
}
|
||||
config.SetTimeout(uint32(timeout))
|
||||
serviceSource := json.Get("serviceSource").String()
|
||||
serviceName := json.Get("serviceName").String()
|
||||
servicePort := json.Get("servicePort").Int()
|
||||
log.Debugf("serviceSource:%s serviceName:%s servicePort:%d", serviceSource, serviceName, servicePort)
|
||||
if serviceName == "" || servicePort == 0 {
|
||||
return errors.New("invalid service config")
|
||||
}
|
||||
switch serviceSource {
|
||||
case "k8s":
|
||||
namespace := json.Get("namespace").String()
|
||||
config.SetClient(wrapper.NewClusterClient(wrapper.K8sCluster{
|
||||
ServiceName: serviceName,
|
||||
Namespace: namespace,
|
||||
Port: servicePort,
|
||||
}))
|
||||
return nil
|
||||
case "nacos":
|
||||
namespace := json.Get("namespace").String()
|
||||
config.SetClient(wrapper.NewClusterClient(wrapper.NacosCluster{
|
||||
ServiceName: serviceName,
|
||||
NamespaceID: namespace,
|
||||
Port: servicePort,
|
||||
}))
|
||||
return nil
|
||||
case "ip":
|
||||
config.SetClient(wrapper.NewClusterClient(wrapper.StaticIpCluster{
|
||||
ServiceName: serviceName,
|
||||
Port: servicePort,
|
||||
}))
|
||||
return nil
|
||||
case "dns":
|
||||
domain := json.Get("domain").String()
|
||||
config.SetClient(wrapper.NewClusterClient(wrapper.DnsCluster{
|
||||
ServiceName: serviceName,
|
||||
Port: servicePort,
|
||||
Domain: domain,
|
||||
}))
|
||||
return nil
|
||||
default:
|
||||
return errors.New("unknown service source: " + serviceSource)
|
||||
}
|
||||
|
||||
config.SetDomain(domain)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -122,8 +81,9 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config config.DeGraphQLConfig
|
||||
}
|
||||
// Add header Content-Type: application/json
|
||||
headers = append(headers, [2]string{"Content-Type", "application/json"})
|
||||
client := wrapper.NewClusterClient(wrapper.RouteCluster{Host: config.GetDomain()})
|
||||
// Call upstream graphql endpoint
|
||||
config.GetClient().Post(config.GetEndpoint(), headers, []byte(replaceBody),
|
||||
client.Post(config.GetEndpoint(), headers, []byte(replaceBody),
|
||||
func(statusCode int, responseHeaders http.Header, responseBody []byte) {
|
||||
// Pass response headers and body to client
|
||||
headers := make([][2]string, 0, len(responseHeaders)+3)
|
||||
|
||||
@@ -17,6 +17,8 @@ package wrapper
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
|
||||
)
|
||||
|
||||
type Cluster interface {
|
||||
@@ -24,6 +26,25 @@ type Cluster interface {
|
||||
HostName() string
|
||||
}
|
||||
|
||||
type RouteCluster struct {
|
||||
Host string
|
||||
}
|
||||
|
||||
func (c RouteCluster) ClusterName() string {
|
||||
routeName, err := proxywasm.GetProperty([]string{"cluster_name"})
|
||||
if err != nil {
|
||||
proxywasm.LogErrorf("get route cluster failed, err:%v", err)
|
||||
}
|
||||
return string(routeName)
|
||||
}
|
||||
|
||||
func (c RouteCluster) HostName() string {
|
||||
if c.Host != "" {
|
||||
return c.Host
|
||||
}
|
||||
return GetRequestHost()
|
||||
}
|
||||
|
||||
type K8sCluster struct {
|
||||
ServiceName string
|
||||
Namespace string
|
||||
|
||||
@@ -115,7 +115,7 @@ func HttpCall(cluster Cluster, method, path string, headers [][2]string, body []
|
||||
requestID, code, normalResponse, respBody)
|
||||
callback(code, headers, respBody)
|
||||
})
|
||||
proxywasm.LogDebugf("http call start, id: %s, cluster: %+v, method: %s, path: %s, body: %s, timeout: %d",
|
||||
requestID, cluster, method, path, body, timeout)
|
||||
proxywasm.LogDebugf("http call start, id: %s, cluster: %s, method: %s, path: %s, body: %s, timeout: %d",
|
||||
requestID, cluster.ClusterName(), method, path, body, timeout)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ type HttpContext interface {
|
||||
type ParseConfigFunc[PluginConfig any] func(json gjson.Result, config *PluginConfig, log Log) error
|
||||
type onHttpHeadersFunc[PluginConfig any] func(context HttpContext, config PluginConfig, log Log) types.Action
|
||||
type onHttpBodyFunc[PluginConfig any] func(context HttpContext, config PluginConfig, body []byte, log Log) types.Action
|
||||
type onHttpStreamDoneFunc[PluginConfig any] func(context HttpContext, config PluginConfig, log Log)
|
||||
|
||||
type CommonVmCtx[PluginConfig any] struct {
|
||||
types.DefaultVMContext
|
||||
@@ -51,6 +52,7 @@ type CommonVmCtx[PluginConfig any] struct {
|
||||
onHttpRequestBody onHttpBodyFunc[PluginConfig]
|
||||
onHttpResponseHeaders onHttpHeadersFunc[PluginConfig]
|
||||
onHttpResponseBody onHttpBodyFunc[PluginConfig]
|
||||
onHttpStreamDone onHttpStreamDoneFunc[PluginConfig]
|
||||
}
|
||||
|
||||
func SetCtx[PluginConfig any](pluginName string, setFuncs ...SetPluginFunc[PluginConfig]) {
|
||||
@@ -89,6 +91,12 @@ func ProcessResponseBodyBy[PluginConfig any](f onHttpBodyFunc[PluginConfig]) Set
|
||||
}
|
||||
}
|
||||
|
||||
func ProcessStreamDoneBy[PluginConfig any](f onHttpStreamDoneFunc[PluginConfig]) SetPluginFunc[PluginConfig] {
|
||||
return func(ctx *CommonVmCtx[PluginConfig]) {
|
||||
ctx.onHttpStreamDone = f
|
||||
}
|
||||
}
|
||||
|
||||
func parseEmptyPluginConfig[PluginConfig any](gjson.Result, *PluginConfig, Log) error {
|
||||
return nil
|
||||
}
|
||||
@@ -289,3 +297,13 @@ func (ctx *CommonHttpCtx[PluginConfig]) OnHttpResponseBody(bodySize int, endOfSt
|
||||
}
|
||||
return ctx.plugin.vm.onHttpResponseBody(ctx, *ctx.config, body, ctx.plugin.vm.log)
|
||||
}
|
||||
|
||||
func (ctx *CommonHttpCtx[PluginConfig]) OnHttpStreamDone() {
|
||||
if ctx.config == nil {
|
||||
return
|
||||
}
|
||||
if ctx.plugin.vm.onHttpStreamDone == nil {
|
||||
return
|
||||
}
|
||||
ctx.plugin.vm.onHttpStreamDone(ctx, *ctx.config, ctx.plugin.vm.log)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2022 Alibaba Group Holding Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alibaba/higress/test/ingress/conformance/utils/http"
|
||||
"github.com/alibaba/higress/test/ingress/conformance/utils/roundtripper"
|
||||
"github.com/alibaba/higress/test/ingress/conformance/utils/suite"
|
||||
)
|
||||
|
||||
func init() {
|
||||
HigressConformanceTests = append(HigressConformanceTests, HttpForceRedirectHttps)
|
||||
}
|
||||
|
||||
var HttpForceRedirectHttps = suite.ConformanceTest{
|
||||
ShortName: "HttpForceRedirectHttps",
|
||||
Description: " The ingress in the higress-conformance-infra namespace enforces server-side HTTPS with forced redirection.",
|
||||
Manifests: []string{"tests/httproute-force-redirect-https.yaml"},
|
||||
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
|
||||
testcases := []http.Assertion{
|
||||
{
|
||||
Meta: http.AssertionMeta{
|
||||
TargetBackend: "infra-backend-v1",
|
||||
TargetNamespace: "higress-conformance-infra",
|
||||
},
|
||||
Request: http.AssertionRequest{
|
||||
ActualRequest: http.Request{
|
||||
Host: "test.com",
|
||||
Path: "/test",
|
||||
UnfollowRedirect: true,
|
||||
},
|
||||
RedirectRequest: &roundtripper.RedirectRequest{
|
||||
Scheme: "https",
|
||||
Host: "test.com",
|
||||
Path: "/test",
|
||||
},
|
||||
},
|
||||
Response: http.AssertionResponse{
|
||||
ExpectedResponse: http.Response{
|
||||
StatusCode: 308,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
t.Run("HTTPFORCEREDIRCTHTTPS", func(t *testing.T) {
|
||||
for _, testcase := range testcases {
|
||||
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, suite.GatewayAddress, testcase)
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
# Copyright (c) 2022 Alibaba Group Holding Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||
name: http-redirect-as-https
|
||||
namespace: higress-conformance-infra
|
||||
spec:
|
||||
ingressClassName: higress
|
||||
tls:
|
||||
- hosts:
|
||||
- "test.com"
|
||||
secretName: my-app-tls-secret
|
||||
rules:
|
||||
- host: "test.com"
|
||||
http:
|
||||
paths:
|
||||
- pathType: Prefix
|
||||
path: "/test"
|
||||
backend:
|
||||
service:
|
||||
name: infra-backend-v1
|
||||
port:
|
||||
number: 8080
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: my-app-tls-secret
|
||||
namespace: higress-conformance-infra
|
||||
type: kubernetes.io/tls
|
||||
data:
|
||||
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQxekNDQXIrZ0F3SUJBZ0lVWXh4dE1Ia0tIQXpxM25yUG0rd0Y2UEtNdmw4d0RRWUpLb1pJaHZjTkFRRUwKQlFBd2V6RUxNQWtHQTFVRUJoTUNRMDR4Q3pBSkJnTlZCQWdNQWxOWU1Rc3dDUVlEVlFRSERBSllRVEVOTUFzRwpBMVVFQ2d3RVdGVlFWREVUTUJFR0ExVUVDd3dLVEVsT1ZWaEhVazlWVURFTU1Bb0dBMVVFQXd3RFJsbFVNU0F3CkhnWUpLb1pJaHZjTkFRa0JGaEZtWjNrNE9UTTJRR2R0WVdsc0xtTnZiVEFlRncweU16QTFNRGd4TkRVM016UmEKRncweU5EQTFNRGN4TkRVM016UmFNSHN4Q3pBSkJnTlZCQVlUQWtOT01Rc3dDUVlEVlFRSURBSlRXREVMTUFrRwpBMVVFQnd3Q1dFRXhEVEFMQmdOVkJBb01CRmhWVUZReEV6QVJCZ05WQkFzTUNreEpUbFZZUjFKUFZWQXhEREFLCkJnTlZCQU1NQTBaWlZERWdNQjRHQ1NxR1NJYjNEUUVKQVJZUlptZDVPRGt6TmtCbmJXRnBiQzVqYjIwd2dnRWkKTUEwR0NTcUdTSWIzRFF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ZHZGOTVleG41dncvd0s4SUczb25xM0FvR0FiYVV6UGZJWkRiTlJvM2tKeEZxawoxellzd3ZUUTdqU1lvMGlSbUVNSG9KTStvYWJPaFZjN0NZSjFoK1ZXelBmWXJCUFE5VEZjZEI3b1hueW9OTlZOClBjdGtUYXc1LyszNWdJWThHcmJsdzlqWmtmalFFVDJPNkFmMG5tQTd4a1F2djZkZkgzQTI0WlRyTExrY0pJTzYKZGVtNFpXbitiUWFRNnBvYThJdngvelU9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
|
||||
@@ -0,0 +1,50 @@
|
||||
# Copyright (c) 2022 Alibaba Group Holding Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
name: http-redirect-as-https
|
||||
namespace: higress-conformance-infra
|
||||
spec:
|
||||
ingressClassName: higress
|
||||
tls:
|
||||
- hosts:
|
||||
- "test.com"
|
||||
secretName: my-app-tls-secret
|
||||
rules:
|
||||
- host: "test.com"
|
||||
http:
|
||||
paths:
|
||||
- pathType: Prefix
|
||||
path: "/test"
|
||||
backend:
|
||||
service:
|
||||
name: infra-backend-v1
|
||||
port:
|
||||
number: 8080
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: my-app-tls-secret
|
||||
namespace: higress-conformance-infra
|
||||
type: kubernetes.io/tls
|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||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alibaba/higress/test/ingress/conformance/utils/http"
|
||||
"github.com/alibaba/higress/test/ingress/conformance/utils/roundtripper"
|
||||
"github.com/alibaba/higress/test/ingress/conformance/utils/suite"
|
||||
)
|
||||
|
||||
func init() {
|
||||
HigressConformanceTests = append(HigressConformanceTests, HttpRedirectAsHttps)
|
||||
}
|
||||
|
||||
var HttpRedirectAsHttps = suite.ConformanceTest{
|
||||
ShortName: "HttpRedirectAsHttps",
|
||||
Description: "The Ingress in the higress-conformance-infra namespace Server-side HTTPS enforcement through redirect.",
|
||||
Manifests: []string{"tests/httproute-redirct-as-https.yaml"},
|
||||
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
|
||||
testcases := []http.Assertion{
|
||||
{
|
||||
Meta: http.AssertionMeta{
|
||||
TargetBackend: "infra-backend-v1",
|
||||
TargetNamespace: "higress-conformance-infra",
|
||||
},
|
||||
Request: http.AssertionRequest{
|
||||
ActualRequest: http.Request{
|
||||
Host: "test.com",
|
||||
Path: "/test",
|
||||
UnfollowRedirect: true,
|
||||
},
|
||||
RedirectRequest: &roundtripper.RedirectRequest{
|
||||
Scheme: "https",
|
||||
Host: "test.com",
|
||||
Path: "/test",
|
||||
},
|
||||
},
|
||||
Response: http.AssertionResponse{
|
||||
ExpectedResponse: http.Response{
|
||||
StatusCode: 308,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
t.Run("HTTPREDIRCTASHTTPS", func(t *testing.T) {
|
||||
for _, testcase := range testcases {
|
||||
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, suite.GatewayAddress, testcase)
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
}
|
||||
@@ -70,6 +70,8 @@ func TestHigressConformanceTests(t *testing.T) {
|
||||
tests.HTTPRouteWhitelistSourceRange,
|
||||
tests.HTTPRouteCanaryWeight,
|
||||
tests.HTTPRouteMatchPath,
|
||||
tests.HttpForceRedirectHttps,
|
||||
tests.HttpRedirectAsHttps,
|
||||
}
|
||||
|
||||
cSuite.Run(t, higressTests)
|
||||
|
||||
Reference in New Issue
Block a user