From d987216a318cd2f10261df54a2a82d3e395b77b5 Mon Sep 17 00:00:00 2001 From: Nathalia Satie Gomazako Date: Tue, 26 Jul 2022 12:20:36 -0300 Subject: [PATCH] Refactor schema for common structures (#11) * Create codeql.yml * Update codeql.yml * Refactor schema for common structures * Update Dockerfile image for api-doc Signed-off-by: Nathalia --- .github/workflows/codeql.yml | 72 ++ .github/workflows/trivy.yml | 2 +- README.md | 6 +- cmd/server/main.go | 8 +- dev/api/Dockerfile | 4 +- oapi-codegen/harvester.cfg.yaml | 9 + .../harvester.yaml | 87 +- oapi-codegen/schemas.cfg.yaml | 9 + oapi-codegen/schemas.yaml | 70 ++ oapi-codegen/server.cfg.yaml | 9 + .../server.yaml | 133 +-- pkg/common/.gitkeep | 0 pkg/common/schemas.gen.go | 144 +++ pkg/harvester/.gitkeep | 0 .../harvester.gen.go} | 78 +- pkg/server/api/{v1 => server}/handler.go | 2 +- pkg/server/api/server/handler_test.go | 1 + .../server.gen.go} | 114 +-- pkg/server/api/v1/api.go | 324 ------- pkg/server/api/v1/api.yaml | 848 ------------------ pkg/server/api/v1/handler_test.go | 1 - 21 files changed, 417 insertions(+), 1504 deletions(-) create mode 100644 .github/workflows/codeql.yml create mode 100644 oapi-codegen/harvester.cfg.yaml rename pkg/server/api/v1/api_harvester.yaml => oapi-codegen/harvester.yaml (62%) create mode 100644 oapi-codegen/schemas.cfg.yaml create mode 100644 oapi-codegen/schemas.yaml create mode 100644 oapi-codegen/server.cfg.yaml rename pkg/server/api/v1/api_server.yaml => oapi-codegen/server.yaml (86%) delete mode 100644 pkg/common/.gitkeep create mode 100644 pkg/common/schemas.gen.go delete mode 100644 pkg/harvester/.gitkeep rename pkg/server/api/{v1/api_harvester.gen.go => harvester/harvester.gen.go} (72%) rename pkg/server/api/{v1 => server}/handler.go (98%) create mode 100644 pkg/server/api/server/handler_test.go rename pkg/server/api/{v1/api_server.gen.go => server/server.gen.go} (87%) delete mode 100644 pkg/server/api/v1/api.go delete mode 100644 pkg/server/api/v1/api.yaml delete mode 100644 pkg/server/api/v1/handler_test.go diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..5f300352 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,72 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '41 2 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index b2966861..4262d432 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -3,7 +3,7 @@ # separate terms of service, privacy policy, and support # documentation. -name: build +name: trivy on: push: diff --git a/README.md b/README.md index 5e0391f0..1462b351 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,12 @@ Server and Client Go code is generated from the OpenAPI definition by [oapi-codegen](https://github.com/deepmap/oapi-codegen). -Run the following command to generate the code: +Run the following command to generate the code, from the root folder: ```bash -oapi-codegen --package api api.yaml > api.gen.go +oapi-codegen --config=oapi-codegen/schemas.cfg.yaml oapi-codegen/schemas.yaml +oapi-codegen --config=oapi-codegen/harvester.cfg.yaml oapi-codegen/harvester.yaml +oapi-codegen --config=oapi-codegen/server.cfg.yaml oapi-codegen/server.yaml ``` Run the following command to have a live view of the API documentation: diff --git a/cmd/server/main.go b/cmd/server/main.go index f3977aed..a26fc7ff 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -17,7 +17,7 @@ import ( "fmt" "os" - api "github.com/HewlettPackard/Galadriel/pkg/server/api/v1" + serverapi "github.com/HewlettPackard/Galadriel/pkg/server/api/server" "github.com/deepmap/oapi-codegen/pkg/middleware" "github.com/labstack/echo/v4" echomiddleware "github.com/labstack/echo/v4/middleware" @@ -27,7 +27,7 @@ func main() { var port = flag.Int("port", 8080, "Port for HTTP Galadriel server") flag.Parse() - swagger, err := api.GetSwagger() + swagger, err := serverapi.GetSwagger() if err != nil { fmt.Fprintf(os.Stderr, "Error loading swagger spec\n: %s", err) os.Exit(1) @@ -37,7 +37,7 @@ func main() { // that server names match. We don't know how this thing will be run. swagger.Servers = nil - server := api.MyDumbServer{} + galadriel_server := serverapi.MyDumbServer{} // This is how you set up a basic Echo router router := echo.New() @@ -50,7 +50,7 @@ func main() { router.Use(middleware.OapiRequestValidator(swagger)) // We now register our store above as the handler for the interface - api.RegisterHandlers(router, server) + serverapi.RegisterHandlers(router, galadriel_server) // And we serve HTTP until the world ends. router.Logger.Fatal(router.Start(fmt.Sprintf("0.0.0.0:%d", *port))) diff --git a/dev/api/Dockerfile b/dev/api/Dockerfile index 31f3808e..2d66f203 100644 --- a/dev/api/Dockerfile +++ b/dev/api/Dockerfile @@ -1,5 +1,5 @@ -# python:3.10.5-alpine3.16 (linux/amd64) -FROM python@sha256:52ce18e9d7a2556a3632d093f8f77700307735b7e7049dce3339c9bf9221ae7f +# python:3.11.0b4-alpine3.15 (linux/amd64) +FROM python@sha256:70825f4d36b31382c5b06e5c0d37de0c0bde49a42f26e77e6b3479d37662eb95 EXPOSE 8000 diff --git a/oapi-codegen/harvester.cfg.yaml b/oapi-codegen/harvester.cfg.yaml new file mode 100644 index 00000000..83355cad --- /dev/null +++ b/oapi-codegen/harvester.cfg.yaml @@ -0,0 +1,9 @@ +package: harvester +generate: + echo-server: true + client: false + models: true + embedded-spec: true +output: pkg/server/api/harvester/harvester.gen.go +output-options: + skip-prune: true \ No newline at end of file diff --git a/pkg/server/api/v1/api_harvester.yaml b/oapi-codegen/harvester.yaml similarity index 62% rename from pkg/server/api/v1/api_harvester.yaml rename to oapi-codegen/harvester.yaml index f5507379..78ecd04b 100644 --- a/pkg/server/api/v1/api_harvester.yaml +++ b/oapi-codegen/harvester.yaml @@ -7,75 +7,6 @@ info: servers: - url: http://localhost:32308/ -components: - schemas: - FederationRelationship: - # Represents a federated relationship between SPIRE server - type: object - properties: - id: - type: integer - format: int64 - federationGroupId: - type: integer - format: int64 - spireServer: - type: string - format: string - spireServerFederatedWith: - type: string - format: string - spireServerFederatedWithConsent: - type: string - format: string - spireServerConsent: - type: string - format: string - status: - type: string - enum: - - active - - inactive - - invited - required: - - id - - federationGroupId - - spireServer - - spireServerFederatedWith - TrustBundle: - # Represents the trust bundle of a SPIRE Server that is a member of the bridge - type: object - properties: - id: - type: integer - format: int64 - trustDomain: - type: string - format: string - bundle: - type: string - format: bytes - status: - type: string - enum: - - active - - inactive - - to_delete - required: - - id - - trustdomain - - bundle - Error: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - required: - - code - - message paths: /FederationRelationship: get: @@ -108,13 +39,13 @@ paths: schema: type: array items: - $ref: '#/components/schemas/FederationRelationship' + $ref: './schemas.yaml' default: description: unexpected error content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /FederationRelationship/{relationshipID}: get: description: get data for one organization @@ -133,13 +64,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/FederationRelationship' + $ref: './schemas.yaml' default: description: unexpected error content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' put: description: update an the status of a relationship by ID operationId: updateFederatedRelationshipStatus @@ -156,7 +87,7 @@ paths: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/FederationRelationship' + $ref: './schemas.yaml' responses: '204': description: no content @@ -165,7 +96,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /trustBundles/{trustBundleId}: put: description: Upload a TrustBundle @@ -183,18 +114,18 @@ paths: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/TrustBundle' + $ref: './schemas.yaml' responses: '200': description: get trust bundle's response content: application/json: schema: - $ref: '#/components/schemas/TrustBundle' + $ref: './schemas.yaml' default: description: unexpected error content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' diff --git a/oapi-codegen/schemas.cfg.yaml b/oapi-codegen/schemas.cfg.yaml new file mode 100644 index 00000000..ab2566ca --- /dev/null +++ b/oapi-codegen/schemas.cfg.yaml @@ -0,0 +1,9 @@ +package: common +generate: + echo-server: false + client: false + models: true + embedded-spec: true +output: pkg/common/schemas.gen.go +output-options: + skip-prune: true \ No newline at end of file diff --git a/oapi-codegen/schemas.yaml b/oapi-codegen/schemas.yaml new file mode 100644 index 00000000..80c9bee2 --- /dev/null +++ b/oapi-codegen/schemas.yaml @@ -0,0 +1,70 @@ + +components: + schemas: + FederationRelationship: + # Represents a federated relationship between SPIRE server + type: object + properties: + id: + type: integer + format: int64 + federationGroupId: + type: integer + format: int64 + spireServer: + type: string + format: string + spireServerFederatedWith: + type: string + format: string + spireServerFederatedWithConsent: + type: string + format: string + spireServerConsent: + type: string + format: string + status: + type: string + enum: + - active + - inactive + - invited + required: + - id + - federationGroupId + - spireServer + - spireServerFederatedWith + TrustBundle: + # Represents the trust bundle of a SPIRE Server that is a member of the bridge + type: object + properties: + id: + type: integer + format: int64 + trustDomain: + type: string + format: string + bundle: + type: string + format: bytes + status: + type: string + enum: + - active + - inactive + - to_delete + required: + - id + - trustdomain + - bundle + Error: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + required: + - code + - message \ No newline at end of file diff --git a/oapi-codegen/server.cfg.yaml b/oapi-codegen/server.cfg.yaml new file mode 100644 index 00000000..1b506fd1 --- /dev/null +++ b/oapi-codegen/server.cfg.yaml @@ -0,0 +1,9 @@ +package: server +generate: + echo-server: true + client: false + models: true + embedded-spec: true +output: pkg/server/api/server/server.gen.go +output-options: + skip-prune: true \ No newline at end of file diff --git a/pkg/server/api/v1/api_server.yaml b/oapi-codegen/server.yaml similarity index 86% rename from pkg/server/api/v1/api_server.yaml rename to oapi-codegen/server.yaml index 9cf939d6..0d4a0824 100644 --- a/pkg/server/api/v1/api_server.yaml +++ b/oapi-codegen/server.yaml @@ -97,74 +97,7 @@ components: - spireServerId - federationGroupId - status - FederationRelationship: - # It is a representation of two SPIRE server's consent to exchange trust bundles in a particular - # FederationGroup (bridge) - type: object - properties: - id: - type: integer - format: int64 - federationGroupId: - type: integer - format: int64 - spireServer1: - type: integer - format: int64 - spireServer2: - type: integer - format: int64 - spireServer1Consent: - type: string - format: string - spireServer2Consent: - type: string - format: string - status: - type: string - enum: - - active - - inactive - - invited - required: - - id - - federationGroupId - - spireServer1 - - spireServer2 - TrustBundle: - # A trustbundle belongs uniquely to the SPIRESERVER, not to the bridge - type: object - properties: - id: - type: integer - format: int64 - trustDomain: - type: string - format: string - bundle: - type: string - format: bytes - status: - type: string - enum: - - active - - inactive - - to_delete - required: - - id - - trustdomain - - bundle - Error: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - required: - - code - - message + paths: /organizations: post: @@ -189,7 +122,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' get: description: Returns all Organizations operationId: getOrganizations @@ -214,7 +147,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /organizations/{orgID}: get: description: get data for one organization @@ -239,7 +172,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' put: description: update an organizaion by ID operationId: updateOrganizaion @@ -265,7 +198,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' delete: description: delete an organization operationId: deleteOrganization @@ -285,7 +218,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /federationGroups: post: description: Create a new federation group @@ -309,7 +242,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' get: description: Returns all federation groups operationId: getFederationGroups @@ -346,7 +279,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /federationGroups/{federationGroupID}: get: description: get data for one FederationGroup @@ -371,7 +304,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' put: description: update a federationGroup by ID operationId: updatefederationGroup @@ -397,7 +330,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' delete: description: delete a federationGroup operationId: deletefederationGroup @@ -417,7 +350,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /spireServers: post: @@ -442,7 +375,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' get: description: Returns all the SpireServers operationId: getSpireServers @@ -476,7 +409,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /spireServers/{spireServerId}: put: @@ -508,7 +441,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' delete: description: delete a SpireServer operationId: deleteSpireServer @@ -528,7 +461,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /federationGroupMemberships: post: description: Associate a SpireServer to a Federation Group @@ -552,7 +485,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' get: description: Returns all federation groups memberships operationId: getFederationGroupMemberships @@ -597,7 +530,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /federationGroupMemberships/{membershipID}: get: description: get data for one FederationGroup @@ -622,7 +555,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' put: description: update a federationGroupMembership by ID operationId: updatefederationGroupMembership @@ -648,7 +581,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' delete: description: delete a federationGroup membership operationId: deletefederationGroupMembership @@ -668,7 +601,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /federationRelationships: post: description: Creates inital request for trustbundle exchange between two SpireServers active in the same federation group @@ -679,20 +612,20 @@ paths: content: application/jason: schema: - $ref: '#/components/schemas/FederationRelationship' + $ref: './schemas.yaml' responses: '201': description: Federation relationship creation response content: application/json: schema: - $ref: '#/components/schemas/FederationRelationship' + $ref: './schemas.yaml' default: description: unexpected error content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' get: description: Returns all federation relationships operationId: getFederationRelationships @@ -732,13 +665,13 @@ paths: schema: type: array items: - $ref: '#/components/schemas/FederationRelationship' + $ref: './schemas.yaml' default: description: unexpected error content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /federationRelationships/{relationshipID}: get: description: get data for one FederationGroup @@ -757,20 +690,20 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/FederationRelationship' + $ref: './schemas.yaml' default: description: unexpected error content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' put: description: update a federationGroupMembership by ID operationId: updateFederationRelationshipship parameters: - name: relationshipID in: path - description: Id of the federatio relationship to update + description: Id of the federation relationship to update required: true schema: type: integer @@ -780,7 +713,7 @@ paths: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/FederationRelationship' + $ref: './schemas.yaml' responses: '204': description: no content @@ -789,7 +722,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' /trustBundles/{trustBundleId}: put: @@ -808,18 +741,18 @@ paths: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/TrustBundle' + $ref: './schemas.yaml' responses: '200': description: get trust bundle's response content: application/json: schema: - $ref: '#/components/schemas/TrustBundle' + $ref: './schemas.yaml' default: description: unexpected error content: application/json: schema: - $ref: '#/components/schemas/Error' + $ref: './schemas.yaml' diff --git a/pkg/common/.gitkeep b/pkg/common/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/common/schemas.gen.go b/pkg/common/schemas.gen.go new file mode 100644 index 00000000..7ba6f1d8 --- /dev/null +++ b/pkg/common/schemas.gen.go @@ -0,0 +1,144 @@ +// Package common provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT. +package common + +import ( + "bytes" + "compress/gzip" + "encoding/base64" + "fmt" + "net/url" + "path" + "strings" + + "github.com/getkin/kin-openapi/openapi3" +) + +// Defines values for FederationRelationshipStatus. +const ( + FederationRelationshipStatusActive FederationRelationshipStatus = "active" + FederationRelationshipStatusInactive FederationRelationshipStatus = "inactive" + FederationRelationshipStatusInvited FederationRelationshipStatus = "invited" +) + +// Defines values for TrustBundleStatus. +const ( + TrustBundleStatusActive TrustBundleStatus = "active" + TrustBundleStatusInactive TrustBundleStatus = "inactive" + TrustBundleStatusToDelete TrustBundleStatus = "to_delete" +) + +// Error defines model for Error. +type Error struct { + Code int32 `json:"code"` + Message string `json:"message"` +} + +// FederationRelationship defines model for FederationRelationship. +type FederationRelationship struct { + FederationGroupId int64 `json:"federationGroupId"` + Id int64 `json:"id"` + SpireServer string `json:"spireServer"` + SpireServerConsent *string `json:"spireServerConsent,omitempty"` + SpireServerFederatedWith string `json:"spireServerFederatedWith"` + SpireServerFederatedWithConsent *string `json:"spireServerFederatedWithConsent,omitempty"` + Status *FederationRelationshipStatus `json:"status,omitempty"` +} + +// FederationRelationshipStatus defines model for FederationRelationship.Status. +type FederationRelationshipStatus string + +// TrustBundle defines model for TrustBundle. +type TrustBundle struct { + Bundle string `json:"bundle"` + Id int64 `json:"id"` + Status *TrustBundleStatus `json:"status,omitempty"` + TrustDomain *string `json:"trustDomain,omitempty"` +} + +// TrustBundleStatus defines model for TrustBundle.Status. +type TrustBundleStatus string + +// Base64 encoded, gzipped, json marshaled Swagger object +var swaggerSpec = []string{ + + "H4sIAAAAAAAC/6RSy07rMBD9l1l7de/VXWTJU2wBiQVCyI1Pm0GJbcaTSlWVf0dOSugjoFSsPLZnjs5j", + "tlSGJgYPr4mKLaWyQmP78lokSC6ihAhRRv9cBod8LoM0Vqkg9vr3DxnSTcRwxQpCnaEGKdlV3737TCrs", + "V9R1hgTvLQscFc8D5lf/ywgWFm8oNWPdwEGscvD3qPszVRxP6S3HvlsJbbxzx1z//5vkynMbU2TBA2QN", + "OZjYSTPHUg8mLoNP8Hr+4E4+3BNr9cvxM0mo1ba3Fr5tclq2VF7nvNjvlWtWuL3ovomaHZmJkA59/UH6", + "1G48Spv0ovWuxulCLMb3Uexio0hTWucvwSxTNLw61FBM2GJIM+ur0Fj2s6KYMrLHcAOG+ZR6alGeZb8M", + "VPi2rg2FCG8jU0FkKFqt0vDTfQQAAP//WwXWvg8EAAA=", +} + +// GetSwagger returns the content of the embedded swagger specification file +// or error if failed to decode +func decodeSpec() ([]byte, error) { + zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) + if err != nil { + return nil, fmt.Errorf("error base64 decoding spec: %s", err) + } + zr, err := gzip.NewReader(bytes.NewReader(zipped)) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + var buf bytes.Buffer + _, err = buf.ReadFrom(zr) + if err != nil { + return nil, fmt.Errorf("error decompressing spec: %s", err) + } + + return buf.Bytes(), nil +} + +var rawSpec = decodeSpecCached() + +// a naive cached of a decoded swagger spec +func decodeSpecCached() func() ([]byte, error) { + data, err := decodeSpec() + return func() ([]byte, error) { + return data, err + } +} + +// Constructs a synthetic filesystem for resolving external references when loading openapi specifications. +func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { + var res = make(map[string]func() ([]byte, error)) + if len(pathToFile) > 0 { + res[pathToFile] = rawSpec + } + + return res +} + +// GetSwagger returns the Swagger specification corresponding to the generated code +// in this file. The external references of Swagger specification are resolved. +// The logic of resolving external references is tightly connected to "import-mapping" feature. +// Externally referenced files must be embedded in the corresponding golang packages. +// Urls can be supported but this task was out of the scope. +func GetSwagger() (swagger *openapi3.T, err error) { + var resolvePath = PathToRawSpec("") + + loader := openapi3.NewLoader() + loader.IsExternalRefsAllowed = true + loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { + var pathToFile = url.String() + pathToFile = path.Clean(pathToFile) + getSpec, ok := resolvePath[pathToFile] + if !ok { + err1 := fmt.Errorf("path not found: %s", pathToFile) + return nil, err1 + } + return getSpec() + } + var specData []byte + specData, err = rawSpec() + if err != nil { + return + } + swagger, err = loader.LoadFromData(specData) + if err != nil { + return + } + return +} diff --git a/pkg/harvester/.gitkeep b/pkg/harvester/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/pkg/server/api/v1/api_harvester.gen.go b/pkg/server/api/harvester/harvester.gen.go similarity index 72% rename from pkg/server/api/v1/api_harvester.gen.go rename to pkg/server/api/harvester/harvester.gen.go index ce07d958..b0f8046c 100644 --- a/pkg/server/api/v1/api_harvester.gen.go +++ b/pkg/server/api/harvester/harvester.gen.go @@ -1,7 +1,7 @@ -// Package api_harvester provides primitives to interact with the openapi HTTP API. +// Package harvester provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT. -package api_harvester +package harvester import ( "bytes" @@ -18,51 +18,6 @@ import ( "github.com/labstack/echo/v4" ) -// Defines values for FederationRelationshipStatus. -const ( - FederationRelationshipStatusActive FederationRelationshipStatus = "active" - FederationRelationshipStatusInactive FederationRelationshipStatus = "inactive" - FederationRelationshipStatusInvited FederationRelationshipStatus = "invited" -) - -// Defines values for TrustBundleStatus. -const ( - TrustBundleStatusActive TrustBundleStatus = "active" - TrustBundleStatusInactive TrustBundleStatus = "inactive" - TrustBundleStatusToDelete TrustBundleStatus = "to_delete" -) - -// Error defines model for Error. -type Error struct { - Code int32 `json:"code"` - Message string `json:"message"` -} - -// FederationRelationship defines model for FederationRelationship. -type FederationRelationship struct { - FederationGroupId int64 `json:"federationGroupId"` - Id int64 `json:"id"` - SpireServer string `json:"spireServer"` - SpireServerConsent *string `json:"spireServerConsent,omitempty"` - SpireServerFederatedWith string `json:"spireServerFederatedWith"` - SpireServerFederatedWithConsent *string `json:"spireServerFederatedWithConsent,omitempty"` - Status *FederationRelationshipStatus `json:"status,omitempty"` -} - -// FederationRelationshipStatus defines model for FederationRelationship.Status. -type FederationRelationshipStatus string - -// TrustBundle defines model for TrustBundle. -type TrustBundle struct { - Bundle string `json:"bundle"` - Id int64 `json:"id"` - Status *TrustBundleStatus `json:"status,omitempty"` - TrustDomain *string `json:"trustDomain,omitempty"` -} - -// TrustBundleStatus defines model for TrustBundle.Status. -type TrustBundleStatus string - // GetFederationRelationshipsParams defines parameters for GetFederationRelationships. type GetFederationRelationshipsParams struct { // filter relationships by spireServer @@ -214,22 +169,19 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/9RXwW7jNhD9FWJaoBdl5SaLotBt02xT34Kkix4WQUGLI5kLiWSGI2fdQP9ekLJsKZYT", - "Z4sN0lMkeYZ88+bNI/MAua2dNWjYQ/YAPl9iLePjRyJL4cGRdUisMX7OrcLwt7BUS4YMtOGzU0iA1w67", - "VyyRoE2gRu9lGaM3P3ombUpo2wQI7xpNqCD73K25i7/dLmYXXzDnsNbvqJAka2uusYp//VK7fXjFNu6S", - "bOPm6jHWX95PYtXHBnqnCW+QVkijjE1pyeNSRxm/WePR8MsTN+Wj+kvz8j+mvxAES24itWiaOnRL5qxX", - "oV/aDB5XmlENWneg1VpBMtGkMa9PlD6ljT+p8XzeGFXhviAW2+/bYhdrRj9V6/EiOIoUtn8rrJBxgpYE", - "OKC+sLXU5qhWTBEZ11DdGklf6j5FIVebwoZ9FPqctAvkQwYfruaCrVigaDwqUVgSoUwKNZhS3Gteij8k", - "rdAzkn8XttQc6ISbq/n1R3FOWpUoTsSlrKQijVUXTiFefLiaQwLhrdvt53ezd7NQu3VopNOQwVn8lICT", - "vIyEpocnvUTer+AauSHjhawqUfRSETRI9cIWQooOsI+aEtoIXuIAte+VF7QTU4N1wCXyNB4fMZOsMRAD", - "2efHuApdBQrGQBZrMdZ56D3cNUhrSMDIOjZ8PAnRkY9UyNEgOv0e2L//8fW3njSGfRSHBrO9DTPiXTC4", - "KKbT2aw7swxvHE86V+k8bpF+8dbsDr3wpBnrmPgjYQEZ/JDujsd0czYeEmi7xSOJ5LqbujEnJfKYkJ+8", - "6PFCjC5kU/GLID+FtDvCJ4A0Br86zMOkYB/TJodmL30Ygp5ftAeHMRSoJMtoJNagsFRKo/+JyVPDNdxm", - "sZ5fPDdVcxWGOYzuENLGwgiZNK5Q9eoKprIT17gIGNopU4Ovq7R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vhTmZp4e36jMxPVSstxGDHzh1PA3p/Pl7O7u7iz9w7NIBm3jVMr4", + "LxzXfcIw18JRN3/rcxVU0ueR0W+fHqV1YkZ/HROLKQa+iFYZDOVhcVerPKaOCvnRGyeVkOLXh/gT4q0j", + "nilaxhC7vOproq2Q/3+enSjF+N+NzyXRK/sCjwVMPz0nvSIZqGDP7KuyNK6RZu8CV+dvzrc/lTB+Gv8M", + "AAD///73VeLZCwAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/pkg/server/api/v1/handler.go b/pkg/server/api/server/handler.go similarity index 98% rename from pkg/server/api/v1/handler.go rename to pkg/server/api/server/handler.go index 5a72f2f5..4672c98e 100644 --- a/pkg/server/api/v1/handler.go +++ b/pkg/server/api/server/handler.go @@ -1,4 +1,4 @@ -package api +package server import ( "errors" diff --git a/pkg/server/api/server/handler_test.go b/pkg/server/api/server/handler_test.go new file mode 100644 index 00000000..abb4e431 --- /dev/null +++ b/pkg/server/api/server/handler_test.go @@ -0,0 +1 @@ +package server diff --git a/pkg/server/api/v1/api_server.gen.go b/pkg/server/api/server/server.gen.go similarity index 87% rename from pkg/server/api/v1/api_server.gen.go rename to pkg/server/api/server/server.gen.go index 345f01f2..1e54cd9f 100644 --- a/pkg/server/api/v1/api_server.gen.go +++ b/pkg/server/api/server/server.gen.go @@ -1,7 +1,7 @@ -// Package api_server provides primitives to interact with the openapi HTTP API. +// Package server provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT. -package api_server +package server import ( "bytes" @@ -30,33 +30,13 @@ const ( FederationGroupMembershipStatusInactive FederationGroupMembershipStatus = "inactive" ) -// Defines values for FederationRelationshipStatus. -const ( - FederationRelationshipStatusActive FederationRelationshipStatus = "active" - FederationRelationshipStatusInactive FederationRelationshipStatus = "inactive" - FederationRelationshipStatusInvited FederationRelationshipStatus = "invited" -) - // Defines values for SpireServerStatus. const ( - SpireServerStatusActive SpireServerStatus = "active" - SpireServerStatusInactive SpireServerStatus = "inactive" - SpireServerStatusInvited SpireServerStatus = "invited" + Active SpireServerStatus = "active" + Inactive SpireServerStatus = "inactive" + Invited SpireServerStatus = "invited" ) -// Defines values for TrustBundleStatus. -const ( - Active TrustBundleStatus = "active" - Inactive TrustBundleStatus = "inactive" - ToDelete TrustBundleStatus = "to_delete" -) - -// Error defines model for Error. -type Error struct { - Code int32 `json:"code"` - Message string `json:"message"` -} - // FederationGroup defines model for FederationGroup. type FederationGroup struct { Id int64 `json:"id"` @@ -79,20 +59,6 @@ type FederationGroupMembership struct { // FederationGroupMembershipStatus defines model for FederationGroupMembership.Status. type FederationGroupMembershipStatus string -// FederationRelationship defines model for FederationRelationship. -type FederationRelationship struct { - FederationGroupId int64 `json:"federationGroupId"` - Id int64 `json:"id"` - SpireServer1 int64 `json:"spireServer1"` - SpireServer1Consent *string `json:"spireServer1Consent,omitempty"` - SpireServer2 int64 `json:"spireServer2"` - SpireServer2Consent *string `json:"spireServer2Consent,omitempty"` - Status *FederationRelationshipStatus `json:"status,omitempty"` -} - -// FederationRelationshipStatus defines model for FederationRelationship.Status. -type FederationRelationshipStatus string - // Organization defines model for Organization. type Organization struct { Id int64 `json:"id"` @@ -110,17 +76,6 @@ type SpireServer struct { // SpireServerStatus defines model for SpireServer.Status. type SpireServerStatus string -// TrustBundle defines model for TrustBundle. -type TrustBundle struct { - Bundle string `json:"bundle"` - Id int64 `json:"id"` - Status *TrustBundleStatus `json:"status,omitempty"` - TrustDomain *string `json:"trustDomain,omitempty"` -} - -// TrustBundleStatus defines model for TrustBundle.Status. -type TrustBundleStatus string - // GetFederationGroupMembershipsParams defines parameters for GetFederationGroupMemberships. type GetFederationGroupMembershipsParams struct { // filter federation groups memberships by orgId @@ -754,36 +709,35 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xb32/bOBL+VwjeAXcHKHWaFoeF39omD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rbpmtyQ9jINGR1vFJx/f", + "XUI0X6TaXy7teZO3G84Gl8LcGw+OUMDdxYmquuRi/lPIyMIbH91UpJ58sS7TFGMq17voyFKpp1J/PFrJ", + "sQpieM1x84LH6Ty3XXz9paPGLZrjJGLgp14atzjjZolbbtFR4fbaakpWd+tb+1aLzJ8lP7K23QG1+KT7", + "qSrbYjDzV6WX2bo98uCijJW35RYdN82qa13qtvoK3ktTuY3ixgoWaSv/Ju5q07r9ZfvsxV8ukbN3fx1B", + "7OxY6lWt02KO9QEl+g6EJ7k7lUKREScfzdmW9FeFb1koaqF5xEmICPo7b9/C63KLjry2oio7cdvB6xLk", + "n6863GKK9fMdgBQRnRif1x6WmxTh6wqnIsJjvFAqGft+xAMSLbhU43dv347+8PH6fv1fAAAA//9fvMdu", + "hUAAAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/pkg/server/api/v1/api.go b/pkg/server/api/v1/api.go deleted file mode 100644 index 83fc2c26..00000000 --- a/pkg/server/api/v1/api.go +++ /dev/null @@ -1,324 +0,0 @@ -// Package api provides primitives to interact with the openapi HTTP API. -// -// Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT. - -package api - -import ( - "bytes" - "compress/gzip" - "encoding/base64" - "fmt" - "net/http" - "net/url" - "path" - "strings" - "time" - - "github.com/deepmap/oapi-codegen/pkg/runtime" - "github.com/getkin/kin-openapi/openapi3" - "github.com/labstack/echo/v4" -) - -// Defines values for SpireServerStatus. -const ( - SpireServerStatusActive SpireServerStatus = "active" - SpireServerStatusDisabled SpireServerStatus = "disabled" - SpireServerStatusInactive SpireServerStatus = "inactive" - SpireServerStatusInvited SpireServerStatus = "invited" - SpireServerStatusToDelete SpireServerStatus = "to_delete" -) - -// Defines values for TrustBundleStatus. -const ( - TrustBundleStatusActive TrustBundleStatus = "active" - TrustBundleStatusInactive TrustBundleStatus = "inactive" - TrustBundleStatusToDelete TrustBundleStatus = "to_delete" -) - -// Error defines model for Error. -type Error struct { - Code int32 `json:"code"` - Message string `json:"message"` -} - -// SpireServer defines model for SpireServer. -type SpireServer struct { - CreatedAt *time.Time `json:"createdAt,omitempty"` - Id int64 `json:"id"` - Orgid string `json:"orgid"` - Status SpireServerStatus `json:"status"` - TrustDomain *string `json:"trustDomain,omitempty"` -} - -// SpireServerStatus defines model for SpireServer.Status. -type SpireServerStatus string - -// TrustBundle defines model for TrustBundle. -type TrustBundle struct { - Bundle *string `json:"bundle,omitempty"` - CreatedAt *time.Time `json:"createdAt,omitempty"` - Id *int64 `json:"id,omitempty"` - SourceUser *string `json:"sourceUser,omitempty"` - Status *TrustBundleStatus `json:"status,omitempty"` - TrustDomain *string `json:"trustDomain,omitempty"` -} - -// TrustBundleStatus defines model for TrustBundle.Status. -type TrustBundleStatus string - -// GetSpireServersParams defines parameters for GetSpireServers. -type GetSpireServersParams struct { - // filter SpireServers by org - Org *string `form:"org,omitempty" json:"org,omitempty"` - - // filter SpireServers by status - Status *GetSpireServersParamsStatus `form:"status,omitempty" json:"status,omitempty"` -} - -// GetSpireServersParamsStatus defines parameters for GetSpireServers. -type GetSpireServersParamsStatus string - -// CreateSpireServerJSONBody defines parameters for CreateSpireServer. -type CreateSpireServerJSONBody = SpireServer - -// CreateSpireServerJSONRequestBody defines body for CreateSpireServer for application/json ContentType. -type CreateSpireServerJSONRequestBody = CreateSpireServerJSONBody - -// ServerInterface represents all server handlers. -type ServerInterface interface { - - // (GET /spireServers) - GetSpireServers(ctx echo.Context, params GetSpireServersParams) error - - // (POST /spireServers) - CreateSpireServer(ctx echo.Context) error - - // (DELETE /spireServers/{spireServerId}) - DeleteSpireServer(ctx echo.Context, spireServerId int64) error - - // (PUT /spireServers/{spireServerId}) - UpdateSpireServer(ctx echo.Context, spireServerId int64) error - - // (PUT /trustBundles/{trustBundleId}) - UpdateTrustBundle(ctx echo.Context, trustBundleId int64) error -} - -// ServerInterfaceWrapper converts echo contexts to parameters. -type ServerInterfaceWrapper struct { - Handler ServerInterface -} - -// GetSpireServers converts echo context to params. -func (w *ServerInterfaceWrapper) GetSpireServers(ctx echo.Context) error { - var err error - - // Parameter object where we will unmarshal all parameters from the context - var params GetSpireServersParams - // ------------- Optional query parameter "org" ------------- - - err = runtime.BindQueryParameter("form", true, false, "org", ctx.QueryParams(), ¶ms.Org) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter org: %s", err)) - } - - // ------------- Optional query parameter "status" ------------- - - err = runtime.BindQueryParameter("form", true, false, "status", ctx.QueryParams(), ¶ms.Status) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter status: %s", err)) - } - - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.GetSpireServers(ctx, params) - return err -} - -// CreateSpireServer converts echo context to params. -func (w *ServerInterfaceWrapper) CreateSpireServer(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CreateSpireServer(ctx) - return err -} - -// DeleteSpireServer converts echo context to params. -func (w *ServerInterfaceWrapper) DeleteSpireServer(ctx echo.Context) error { - var err error - // ------------- Path parameter "spireServerId" ------------- - var spireServerId int64 - - err = runtime.BindStyledParameterWithLocation("simple", false, "spireServerId", runtime.ParamLocationPath, ctx.Param("spireServerId"), &spireServerId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter spireServerId: %s", err)) - } - - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.DeleteSpireServer(ctx, spireServerId) - return err -} - -// UpdateSpireServer converts echo context to params. -func (w *ServerInterfaceWrapper) UpdateSpireServer(ctx echo.Context) error { - var err error - // ------------- Path parameter "spireServerId" ------------- - var spireServerId int64 - - err = runtime.BindStyledParameterWithLocation("simple", false, "spireServerId", runtime.ParamLocationPath, ctx.Param("spireServerId"), &spireServerId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter spireServerId: %s", err)) - } - - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.UpdateSpireServer(ctx, spireServerId) - return err -} - -// UpdateTrustBundle converts echo context to params. -func (w *ServerInterfaceWrapper) UpdateTrustBundle(ctx echo.Context) error { - var err error - // ------------- Path parameter "trustBundleId" ------------- - var trustBundleId int64 - - err = runtime.BindStyledParameterWithLocation("simple", false, "trustBundleId", runtime.ParamLocationPath, ctx.Param("trustBundleId"), &trustBundleId) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter trustBundleId: %s", err)) - } - - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.UpdateTrustBundle(ctx, trustBundleId) - return err -} - -// This is a simple interface which specifies echo.Route addition functions which -// are present on both echo.Echo and echo.Group, since we want to allow using -// either of them for path registration -type EchoRouter interface { - CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route - TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route -} - -// RegisterHandlers adds each server route to the EchoRouter. -func RegisterHandlers(router EchoRouter, si ServerInterface) { - RegisterHandlersWithBaseURL(router, si, "") -} - -// Registers handlers, and prepends BaseURL to the paths, so that the paths -// can be served under a prefix. -func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) { - - wrapper := ServerInterfaceWrapper{ - Handler: si, - } - - router.GET(baseURL+"/spireServers", wrapper.GetSpireServers) - router.POST(baseURL+"/spireServers", wrapper.CreateSpireServer) - router.DELETE(baseURL+"/spireServers/:spireServerId", wrapper.DeleteSpireServer) - router.PUT(baseURL+"/spireServers/:spireServerId", wrapper.UpdateSpireServer) - router.PUT(baseURL+"/trustBundles/:trustBundleId", wrapper.UpdateTrustBundle) - -} - -// Base64 encoded, gzipped, json marshaled Swagger object -var swaggerSpec = []string{ - - "H4sIAAAAAAAC/9RXUW/bNhD+K8RtwF6Uyk2KYdBbswaD34pmfQqCgRbPNguKZMljUsPQfx9I2pZkqY6L", - "pc36ZIk8Hr/77uMnegu1aazRqMlDtQVfr7Hh6fHGOePig3XGoiOJabg2AuPv0riGE1QgNV1dQgG0sZhf", - "cYUO2gIa9J6vUvRu0pOTegVtW4DDz0E6FFDd5Zxd/P0hmVl8wppirlsrHd6ie8ApTA45oXhLA2CCE16Q", - "bLADt9+/ACmOi/j9zWQRxq1Ox3Y5PXEKCRDq0MTCpH6QhAIK4DXJh4hE6sOjkJ4vVJom849AhdQvvktM", - "Lnh6Zxou9QDJLqJ4gl6Zdog5RM5xgLovb4rxv+OC66CFwjHji8P4AcxiQ+inaPme3fEmuBo/+qyKJ4mZ", - "6tFUZ569HUfsxiGplyYuF+hrJy1Jo6GC2/fzDzfs2kmxQvb2/TxmkxSpHkxBAQ/ofF7z+tXs1Sxp1aLm", - "VkIFV2moAMtpnaotfXeA0sAKabz7B6TgtGdcKUZrZLf9RSm/4zF0LqCCv5CO5i13vEFKO9wd515KRegG", - "Kdliw4xbJe6hgs8B3QYK0LxJZKWZ7EjnHMC2OHPLg/indj1MdhuPT3NPKuPTPJZMex8PpLdG+3x8Lmez", - "7KWaUKc+cGuVrBO55SdvdGfG8UkSNmnhrw6XUMEvZWfb5c6zy75FdpLjzvFNVtyQnBXSgJnfPNtjhBS8", - "5EHRN8E8hS5/TiZwBI1fLNaEgvVirPET+vwzWQnjTONjH/xImzlwGBEtET1dG7F5tqoGnI9ru1HYxHhm", - "liwfX59iGRnGhYC+T5ML2I508vpHQe1Ns+TY0ugXFwTuY9pi6GDltvc2F22WSnLskWjyOOMnBfMuBQ0j", - "TtrZXMSmJpM8auwOx85eogP33KWPetT+c9zu8PGbMJU34+K1YftuvXQPC7Bh4kx/tPEq4BOV2Xwjsae7", - "ldc8S7dCSvWDunWOAX25eHx8vIgJL4JTqOPlWDzbMd9t6p+k4z99r74B4MurslepDkolr6Hu8uvLbe9t", - "5zVfUbIyXDDO+lfnaekOI86UboLB8tX7KekOIP8k0u2TcoZ0v0rHd5PuEcD/oXTjP5z9Hf9uC8EpqGBN", - "ZKuyVKbmam08VVeXl7M/Smjv238DAAD//3/547kAEAAA", -} - -// GetSwagger returns the content of the embedded swagger specification file -// or error if failed to decode -func decodeSpec() ([]byte, error) { - zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, "")) - if err != nil { - return nil, fmt.Errorf("error base64 decoding spec: %s", err) - } - zr, err := gzip.NewReader(bytes.NewReader(zipped)) - if err != nil { - return nil, fmt.Errorf("error decompressing spec: %s", err) - } - var buf bytes.Buffer - _, err = buf.ReadFrom(zr) - if err != nil { - return nil, fmt.Errorf("error decompressing spec: %s", err) - } - - return buf.Bytes(), nil -} - -var rawSpec = decodeSpecCached() - -// a naive cached of a decoded swagger spec -func decodeSpecCached() func() ([]byte, error) { - data, err := decodeSpec() - return func() ([]byte, error) { - return data, err - } -} - -// Constructs a synthetic filesystem for resolving external references when loading openapi specifications. -func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) { - var res = make(map[string]func() ([]byte, error)) - if len(pathToFile) > 0 { - res[pathToFile] = rawSpec - } - - return res -} - -// GetSwagger returns the Swagger specification corresponding to the generated code -// in this file. The external references of Swagger specification are resolved. -// The logic of resolving external references is tightly connected to "import-mapping" feature. -// Externally referenced files must be embedded in the corresponding golang packages. -// Urls can be supported but this task was out of the scope. -func GetSwagger() (swagger *openapi3.T, err error) { - var resolvePath = PathToRawSpec("") - - loader := openapi3.NewLoader() - loader.IsExternalRefsAllowed = true - loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { - var pathToFile = url.String() - pathToFile = path.Clean(pathToFile) - getSpec, ok := resolvePath[pathToFile] - if !ok { - err1 := fmt.Errorf("path not found: %s", pathToFile) - return nil, err1 - } - return getSpec() - } - - var specData []byte - - specData, err = rawSpec() - if err != nil { - return - } - - swagger, err = loader.LoadFromData(specData) - if err != nil { - return - } - - return -} diff --git a/pkg/server/api/v1/api.yaml b/pkg/server/api/v1/api.yaml deleted file mode 100644 index e97a2da3..00000000 --- a/pkg/server/api/v1/api.yaml +++ /dev/null @@ -1,848 +0,0 @@ -openapi: 3.0.0 - -info: - title: SPIRE Bridge - description: SPIRE Bridge API - version: 1.0.0 - -servers: - - url: http://localhost:32208/ - -components: - schemas: - # The goal of SPIRE Bridge is to store and move trust bundles around - # There is no way to update trust bundles, they are only created or deleted - # Deletion is normally automatic (not through API) when the trust bundle contents - # indicate that it has expired - - Organization: - # An organization is the building block to create Federation Groups. It provides multitenancy capabilities. - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - format: string - required: - - id - - name - FederationGroup: - # A Federation Group is a group of SpireServers (representation of the bridge) - type: object - properties: - id: - type: integer - format: int64 - orgid: - type: integer - format: int64 - name: - type: string - format: string - status: - type: string - format: string - enum: - - inactive - - active - required: - - id - - orgid - - name - #SpireServer is a representation of a trust-domain/SpireServer - SpireServer: - type: object - properties: - id: - type: integer - format: int64 - trustDomain: - type: string - format: string - description: - type: string - format: string - status: - type: string - enum: - - invited - - active - - inactive - required: - - id - - trustdomain - - description - - status - - FederationGroupMembership: - # A FederationGroupMembership reperesents a particular SPIRE server's presence in a - # FederationGroup - type: object - properties: - id: - type: integer - format: int64 - spireServerId: - type: integer - format: int64 - federationGroupId: - type: integer - format: int64 - status: - type: string - enum: - - active - - inactive - required: - - spireServerId - - federationGroupId - - status - FederationRelationship: - # It is a representation of two SPIRE server's consent to exchange trust bundles in a particular - # FederationGroup (bridge) - - SpireServer: - type: object - properties: - id: - type: integer - format: int64 - federationGroupId: - type: integer - format: int64 - spireServer1: - type: integer - format: int64 - spireServer2: - type: integer - format: int64 - spireServer1Consent: - type: string - format: string - spireServer2Consent: - type: string - format: string - status: - type: string - enum: - - active - - inactive - - invited - required: - - id - - federationGroupId - - spireServer1 - - spireServer2 - TrustBundle: - # A trustbundle belongs uniquely to the SPIRESERVER, not to the bridge - type: object - properties: - id: - type: integer - format: int64 - trustDomain: - type: string - format: string - bundle: - type: string - format: bytes - status: - type: string - enum: - - active - - inactive - - to_delete - required: - - id - - trustdomain - - bundle - Error: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - required: - - code - - message -paths: - /organizations: - post: - description: Create a new organization - operationId: createOrganization - requestBody: - description: Elements of the organization to add - required: true - content: - application/jason: - schema: - $ref: '#/components/schemas/Organization' - responses: - '201': - description: Organization creation response - content: - application/json: - schema: - $ref: '#/components/schemas/Organization' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - get: - description: Returns all Organizations - operationId: getOrganizations - parameters: - - name: name - in: query - description: filter organizations by name - schema: - type: string - format: int64 - responses: - '200': - description: get organization's response - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Organization' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /organizations/{orgID}: - get: - description: get data for one organization - operationId: getOrgbyID - parameters: - - name: orgID - in: path - description: Id of the organization to be retrieved - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: get organization's response - content: - application/json: - schema: - $ref: '#/components/schemas/Organization' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - put: - description: update an organizaion by ID - operationId: updateOrganizaion - parameters: - - name: orgID - in: path - description: Id of the organization to update - required: true - schema: - type: integer - format: int64 - requestBody: - description: contents of the org to be updated - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/Organization' - responses: - '204': - description: no content - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - delete: - description: delete an organization - operationId: deleteOrganization - parameters: - - name: orgID - in: path - description: Id of the organization to delete - required: true - schema: - type: integer - format: int64 - responses: - '204': - description: no content - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /federationGroups: - post: - description: Create a new federation group - operationId: createFederationGroup - requestBody: - description: Elements of the federation group to add - required: true - content: - application/jason: - schema: - $ref: '#/components/schemas/FederationGroup' - responses: - '201': - description: Federation Group creation response - content: - application/json: - schema: - $ref: '#/components/schemas/FederationGroup' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - get: - description: Returns all federation groups - operationId: getFederationGroups - parameters: - - name: orgId - in: query - description: filter federation groups by orgId - schema: - type: string - format: int64 - - name: orgname - in: query - description: filter federation groups by orgname - schema: - type: string - format: string - - name: name - in: query - description: filter organizations by federation group name - schema: - type: string - format: string - responses: - '200': - description: get FederationGroup's response - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/FederationGroup' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /federationGroups/{federationGroupID}: - get: - description: get data for one FederationGroup - operationId: getFederationGroupbyID - parameters: - - name: federationGroupID - in: path - description: Id of the federationGroup to be retrieved - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: get federationGroup ID's response - content: - application/json: - schema: - $ref: '#/components/schemas/FederationGroup' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - put: - description: update an federationGroup by ID - operationId: updatefederationGroup - parameters: - - name: federationGroupID - in: path - description: Id of the federationGroup to update - required: true - schema: - type: integer - format: int64 - requestBody: - description: contents of the federationGroup to be updated - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/FederationGroup' - responses: - '204': - description: no content - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - delete: - description: delete an federationGroup - operationId: deletefederationGroup - parameters: - - name: federationGroupID - in: path - description: Id of the federationGroup to delete - required: true - schema: - type: integer - format: int64 - responses: - '204': - description: no content - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - - /spireServers: - post: - description: Create a new SpireServer - operationId: createSpireServer - requestBody: - description: Elements of SPIRE server to add - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/SpireServer" - responses: - "201": - description: SpireServer creation response - content: - application/json: - schema: - $ref: "#/components/schemas/SpireServer" - default: - description: unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - tags: - - SPIRE Servers - get: - description: Returns all the SpireServers - operationId: getSpireServers - parameters: - - name: trustDomain - in: query - description: filter SpireServers by trust domain - schema: - type: string - format: string - - name: status - in: query - description: filter SpireServers by status - schema: - type: string - enum: - - invited - - inactive - - active - responses: - "200": - description: get SpireServers's response - content: - application/json: - schema: - type: array - items: - $ref: "#/components/schemas/SpireServer" - default: - description: unexpected Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - tags: - - SPIRE Servers - /spireServers/{spireServerId}: - put: - description: Updates the status of a SpireServer - operationId: updateSpireServer - parameters: - - name: spireServerId - in: path - description: Id of the SPIRE server to update - required: true - schema: - type: integer - format: int64 - requestBody: - description: contents of the SPIRE server to update - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/SpireServer' - responses: - '200': - description: get SpireServers's response - content: - application/json: - schema: - $ref: '#/components/schemas/SpireServer' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - $ref: "#/components/schemas/SpireServer" - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/SpireServer" - default: - description: unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - tags: - - SPIRE Servers - delete: - description: delete a SpireServer - operationId: deleteSpireServer - parameters: - - name: spireServerId - in: path - description: Id of the SPIRE server to delete - required: true - schema: - type: integer - format: int64 - responses: - "204": - description: no content - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /federationGroupMemberships: - post: - description: Associate a SpireServer to a Federation Group - operationId: createFederationGroupMembership - requestBody: - description: Elements of the federation group membership to add - required: true - content: - application/jason: - schema: - $ref: '#/components/schemas/FederationGroupMembership' - responses: - '201': - description: Federation Group membership creation response - content: - application/json: - schema: - $ref: '#/components/schemas/FederationGroupMembership' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - get: - description: Returns all federation groups memberships - operationId: getFederationGroupMemberships - parameters: - - name: orgId - in: query - description: filter federation groups memberships by orgId - schema: - type: string - format: int64 - - name: orgname - in: query - description: filter federation groups memberships by orgname - schema: - type: string - format: string - - name: trustDomain - in: query - description: filter memberships by trust domain (SpireSever) - schema: - type: string - format: string - - name: status - in: query - description: filter memberships by status - schema: - type: string - enum: - - inactive - - active - responses: - '200': - description: get FederationGroup memebership's response - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/FederationGroupMembership' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /federationGroupMemberships/{membershipID}: - get: - description: get data for one FederationGroup - operationId: getFederationGroupMembershipbyID - parameters: - - name: membershipID - in: path - description: Id of the federationGroup to be retrieved - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: get federationGroup ID's response - content: - application/json: - schema: - $ref: '#/components/schemas/FederationGroup' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - put: - description: update an federationGroupMembership by ID - operationId: updatefederationGroupMembership - parameters: - - name: membershipID - in: path - description: Id of the federationGroup membership to update - required: true - schema: - type: integer - format: int64 - requestBody: - description: contents of the federationGroup membership to be updated - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/FederationGroupMembership' - responses: - '204': - description: no content - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - delete: - description: delete an federationGroup membership - operationId: deletefederationGroupMembership - parameters: - - name: membershipID - in: path - description: Id of the federationGroup membership to delete - required: true - schema: - type: integer - format: int64 - responses: - '204': - description: no content - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /federationRelationships: - post: - description: Creates inital request for trustbundle exchange between two SpireServers active in the same federation group - operationId: createFederationRelationship - requestBody: - description: Elements of the federation relationship to add - required: true - content: - application/jason: - schema: - $ref: '#/components/schemas/FederationRelationship' - responses: - '201': - description: Federation relationship creation response - content: - application/json: - schema: - $ref: '#/components/schemas/FederationRelationship' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - get: - description: Returns all federation relationships - operationId: getFederationRelationships - parameters: - - name: orgId - in: query - description: filter federation groups memberships by orgId - schema: - type: string - format: int64 - - name: orgname - in: query - description: filter federation groups memberships by orgname - schema: - type: string - format: string - - name: trustDomain - in: query - description: filter memberships by trust domain (SpireSever) - schema: - type: string - format: string - - name: status - in: query - description: filter memberships by status - schema: - type: string - enum: - - inactive - - active - - invited - responses: - '200': - description: get Federation relationship's response - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/FederationRelationship' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - /federationRelationships/{relationshipID}: - get: - description: get data for one FederationGroup - operationId: getFederationRelationshipbyID - parameters: - - name: relationshipID - in: path - description: Id of the federationGroup to be retrieved - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: get federationGroup ID's response - content: - application/json: - schema: - $ref: '#/components/schemas/FederationRelationship' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - put: - description: update an federationGroupMembership by ID - operationId: updateFederationRelationshipship - parameters: - - name: relationshipID - in: path - description: Id of the federatio relationship to update - required: true - schema: - type: integer - format: int64 - requestBody: - description: contents of the federationGroup membership to be updated - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/FederationRelationship' - responses: - '204': - description: no content - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - - /trustBundles/{trustBundleId}: - put: - description: Upload a TrustBundle - operationId: updateTrustBundle - parameters: - - name: trustBundleId - in: path - description: Id of the trust bundle to update - required: true - schema: - type: integer - format: int64 - requestBody: - description: contents of the trust bundle to update - content: - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/TrustBundle' - responses: - '200': - description: get trust bundle's response - content: - application/json: - schema: - $ref: "#/components/schemas/TrustBundle" - default: - description: unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - tags: - - Trust Bundles diff --git a/pkg/server/api/v1/handler_test.go b/pkg/server/api/v1/handler_test.go deleted file mode 100644 index 778f64ec..00000000 --- a/pkg/server/api/v1/handler_test.go +++ /dev/null @@ -1 +0,0 @@ -package api