mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-20 13:27:35 +00:00
fix: add api docs and http handler for openapi files (#1526)
* tests * chore: set vars for platform in dockerfile * simplyfy generate * correct dockerfile * add openapi to gitignore * object files * protos * update protoc version * admin only secuity missing * texts * start secutiry * add handler * add description * add descriptions and remove adddress * default limit * add mapping for openapi * generate statik for openapi * remove address converter * executable * operator test Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -76,6 +76,8 @@ func SetMappingsHTTP(
|
||||
k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.MgmtName, gomock.Any()).MinTimes(1).MaxTimes(1)
|
||||
SetReturnResourceVersion(k8sClient, group, version, kind, namespace, http.OauthName, "")
|
||||
k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.OauthName, gomock.Any()).MinTimes(1).MaxTimes(1)
|
||||
SetReturnResourceVersion(k8sClient, group, version, kind, namespace, http.OpenAPIName, "")
|
||||
k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, http.OpenAPIName, gomock.Any()).MinTimes(1).MaxTimes(1)
|
||||
}
|
||||
|
||||
func SetMappingsGRPC(
|
||||
|
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/caos/orbos/pkg/kubernetes"
|
||||
"github.com/caos/orbos/pkg/kubernetes/resources/ambassador/mapping"
|
||||
"github.com/caos/orbos/pkg/labels"
|
||||
|
||||
"github.com/caos/zitadel/operator"
|
||||
"github.com/caos/zitadel/operator/zitadel/kinds/iam/zitadel/configuration"
|
||||
)
|
||||
@@ -17,6 +18,7 @@ const (
|
||||
AuthorizeName = "authorize-v1"
|
||||
EndsessionName = "endsession-v1"
|
||||
IssuerName = "issuer-v1"
|
||||
OpenAPIName = "openapi"
|
||||
)
|
||||
|
||||
func AdaptFunc(
|
||||
@@ -67,6 +69,11 @@ func AdaptFunc(
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
destroySwagger, err := mapping.AdaptFuncToDestroy(namespace, OpenAPIName)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
destroyers := []operator.DestroyFunc{
|
||||
operator.ResourceDestroyToZitadelDestroy(destroyAdminR),
|
||||
operator.ResourceDestroyToZitadelDestroy(destroyMgmtRest),
|
||||
@@ -75,6 +82,7 @@ func AdaptFunc(
|
||||
operator.ResourceDestroyToZitadelDestroy(destroyAuthorize),
|
||||
operator.ResourceDestroyToZitadelDestroy(destroyEndsession),
|
||||
operator.ResourceDestroyToZitadelDestroy(destroyIssuer),
|
||||
operator.ResourceDestroyToZitadelDestroy(destroySwagger),
|
||||
}
|
||||
|
||||
return func(k8sClient kubernetes.ClientInt, queried map[string]interface{}) (operator.EnsureFunc, error) {
|
||||
@@ -208,6 +216,22 @@ func AdaptFunc(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
queryOpenAPI, err := mapping.AdaptFuncToEnsure(
|
||||
namespace,
|
||||
labels.MustForName(componentLabels, OpenAPIName),
|
||||
false,
|
||||
apiDomain,
|
||||
"/openapi/v2/swagger",
|
||||
"",
|
||||
httpUrl,
|
||||
30000,
|
||||
30000,
|
||||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
queriers := []operator.QueryFunc{
|
||||
operator.ResourceQueryToZitadelQuery(queryAdminR),
|
||||
operator.ResourceQueryToZitadelQuery(queryMgmtRest),
|
||||
@@ -216,6 +240,7 @@ func AdaptFunc(
|
||||
operator.ResourceQueryToZitadelQuery(queryAuthorize),
|
||||
operator.ResourceQueryToZitadelQuery(queryEndsession),
|
||||
operator.ResourceQueryToZitadelQuery(queryIssuer),
|
||||
operator.ResourceQueryToZitadelQuery(queryOpenAPI),
|
||||
}
|
||||
|
||||
return operator.QueriersToEnsureFunc(internalMonitor, false, queriers, k8sClient, queried)
|
||||
|
@@ -233,6 +233,29 @@ func TestHttp_Adapt(t *testing.T) {
|
||||
SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AuthRName, "")
|
||||
k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthRName, authR).MinTimes(1).MaxTimes(1)
|
||||
|
||||
openAPIName := labels.MustForName(componentLabels, OpenAPIName)
|
||||
openAPI := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"apiVersion": group + "/" + version,
|
||||
"kind": kind,
|
||||
"metadata": map[string]interface{}{
|
||||
"labels": labels.MustK8sMap(openAPIName),
|
||||
"name": openAPIName.Name(),
|
||||
"namespace": namespace,
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"connect_timeout_ms": 30000,
|
||||
"host": ".",
|
||||
"prefix": "/openapi/v2/swagger",
|
||||
"rewrite": "",
|
||||
"service": url,
|
||||
"timeout_ms": 30000,
|
||||
},
|
||||
},
|
||||
}
|
||||
SetReturnResourceVersion(k8sClient, group, version, kind, namespace, OpenAPIName, "")
|
||||
k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, OpenAPIName, openAPI).MinTimes(1).MaxTimes(1)
|
||||
|
||||
query, _, err := AdaptFunc(monitor, componentLabels, namespace, url, dns)
|
||||
assert.NoError(t, err)
|
||||
queried := map[string]interface{}{}
|
||||
@@ -442,6 +465,29 @@ func TestHttp_Adapt2(t *testing.T) {
|
||||
SetReturnResourceVersion(k8sClient, group, version, kind, namespace, AuthRName, "")
|
||||
k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, AuthRName, authR).MinTimes(1).MaxTimes(1)
|
||||
|
||||
openAPIName := labels.MustForName(componentLabels, OpenAPIName)
|
||||
openAPI := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"apiVersion": group + "/" + version,
|
||||
"kind": kind,
|
||||
"metadata": map[string]interface{}{
|
||||
"labels": labels.MustK8sMap(openAPIName),
|
||||
"name": openAPIName.Name(),
|
||||
"namespace": namespace,
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"connect_timeout_ms": 30000,
|
||||
"host": "api.domain",
|
||||
"prefix": "/openapi/v2/swagger",
|
||||
"rewrite": "",
|
||||
"service": url,
|
||||
"timeout_ms": 30000,
|
||||
},
|
||||
},
|
||||
}
|
||||
SetReturnResourceVersion(k8sClient, group, version, kind, namespace, OpenAPIName, "")
|
||||
k8sClient.EXPECT().ApplyNamespacedCRDResource(group, version, kind, namespace, OpenAPIName, openAPI).MinTimes(1).MaxTimes(1)
|
||||
|
||||
query, _, err := AdaptFunc(monitor, componentLabels, namespace, url, dns)
|
||||
assert.NoError(t, err)
|
||||
queried := map[string]interface{}{}
|
||||
|
Reference in New Issue
Block a user