Skip to content

Commit

Permalink
chore: update dependencies & set cors allowed origins
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsOveTen committed Dec 10, 2024
1 parent 5d07e8b commit 688f44e
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 246 deletions.
9 changes: 8 additions & 1 deletion config/env/env.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package env

import "os"
import (
"os"
"strings"
)

func getEnv(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
Expand All @@ -9,6 +12,10 @@ func getEnv(key, fallback string) string {
return fallback
}

func CorsOriginPatterns() []string {
return strings.Split(getEnv("CORS_ORIGIN_PATTERNS", "*"), ",")
}

func MongoHost() string {
return getEnv("MONGO_HOST", "localhost:27017")
}
Expand Down
13 changes: 12 additions & 1 deletion config/setupRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package config
import (
"github.com/Informasjonsforvaltning/catalog-history-service/config/security"
"github.com/Informasjonsforvaltning/catalog-history-service/logging"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"time"

"github.com/Informasjonsforvaltning/catalog-history-service/config/env"
"github.com/Informasjonsforvaltning/catalog-history-service/handlers"
Expand All @@ -24,7 +26,16 @@ func InitializeRoutes(e *gin.Engine) {
func SetupRouter() *gin.Engine {
router := gin.New()
router.Use(gin.Recovery())

router.Use(cors.New(cors.Config{
AllowOrigins: env.CorsOriginPatterns(),
AllowMethods: []string{"OPTIONS", "GET", "POST"},
AllowHeaders: []string{"*"},
AllowWildcard: true,
AllowAllOrigins: false,
AllowCredentials: false,
AllowFiles: false,
MaxAge: 1 * time.Hour,
}))
InitializeRoutes(router)
return router
}
2 changes: 2 additions & 0 deletions deploy/demo/env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ spec:
secretKeyRef:
name: commonurl-demo
key: SSO_AUTH_URI
- name: CORS_ORIGIN_PATTERNS
value: https://*.demo.fellesdatakatalog.digdir.no
volumes:
- name: error-reporting-sa
secret:
Expand Down
2 changes: 2 additions & 0 deletions deploy/prod/env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ spec:
secretKeyRef:
name: commonurl-prod
key: SSO_AUTH_URI
- name: CORS_ORIGIN_PATTERNS
value: https://*.fellesdatakatalog.digdir.no
volumes:
- name: error-reporting-sa
secret:
Expand Down
2 changes: 2 additions & 0 deletions deploy/staging/env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ spec:
secretKeyRef:
name: commonurl-staging
key: SSO_AUTH_URI
- name: CORS_ORIGIN_PATTERNS
value: https://*.staging.fellesdatakatalog.digdir.no,http://localhost:*
volumes:
- name: error-reporting-sa
secret:
Expand Down
109 changes: 56 additions & 53 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,83 @@ go 1.23
require (
cloud.google.com/go/errorreporting v0.3.1
github.com/Nerzal/gocloak/v13 v13.9.0
github.com/gin-contrib/cors v1.7.2
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.6.0
github.com/lestrrat-go/jwx v1.2.25
github.com/ory/dockertest/v3 v3.9.1
github.com/stretchr/testify v1.9.0
github.com/lestrrat-go/jwx v1.2.29
github.com/ory/dockertest/v3 v3.11.0
github.com/stretchr/testify v1.10.0
)

require (
cloud.google.com/go/auth v0.9.3 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
cloud.google.com/go/auth v0.12.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.6 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/bytedance/sonic/loader v0.2.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-resty/resty/v2 v2.14.0 // indirect
github.com/go-resty/resty/v2 v2.16.2 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/iter v1.0.1 // indirect
github.com/lestrrat-go/option v1.0.0 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
golang.org/x/time v0.6.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.57.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
golang.org/x/time v0.8.0 // indirect
)

require (
cloud.google.com/go/compute/metadata v0.5.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
cloud.google.com/go/compute/metadata v0.5.2 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/bytedance/sonic v1.12.2 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/bytedance/sonic v1.12.5 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/containerd/continuity v0.4.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v20.10.14+incompatible // indirect
github.com/docker/docker v20.10.7+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/docker/cli v26.1.4+incompatible // indirect
github.com/docker/docker v27.1.1+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.10.0
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/go-playground/validator/v10 v10.23.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.3 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runc v1.1.2 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runc v1.1.13 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -88,24 +91,24 @@ require (
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.mongodb.org/mongo-driver v1.16.1
go.mongodb.org/mongo-driver v1.17.1
go.opencensus.io v0.24.0 // indirect
golang.org/x/arch v0.9.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/api v0.196.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.66.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/arch v0.12.0 // indirect
golang.org/x/crypto v0.30.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/api v0.210.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241206012308-a4fef0638583 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583 // indirect
google.golang.org/grpc v1.68.1 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 688f44e

Please sign in to comment.