Skip to content
Snippets Groups Projects
Commit ed598904 authored by Alen Zubic's avatar Alen Zubic
Browse files

Merge branch 'DEV-144' into 'main'

fix: add allowed origins variable

See merge request !4
parents 7200a236 ea211919
No related branches found
No related tags found
1 merge request!4fix: add allowed origins variable
Pipeline #127134 passed
FROM golang:1.18 as build FROM golang:1.21 as build
ARG TARGETARCH ARG TARGETARCH
ARG TARGETOS ARG TARGETOS
......
...@@ -47,6 +47,7 @@ develop: ...@@ -47,6 +47,7 @@ develop:
$(eval export LOG_LEVEL := -1) $(eval export LOG_LEVEL := -1)
$(eval export DEV := true) $(eval export DEV := true)
$(eval export USER_MANAGEMENT_SERVICE_RPC := localhost:9000) $(eval export USER_MANAGEMENT_SERVICE_RPC := localhost:9000)
$(eval export ALLOWED_ORIGINS := http://localhost:4200/,http://localhost:4200)
@go run cmd/schema-orchestrator/main.go @go run cmd/schema-orchestrator/main.go
...@@ -65,4 +66,8 @@ log: ...@@ -65,4 +66,8 @@ log:
@kubectl get pods -o wide | grep Running | grep schema-orchestrator | cut -d " " -f1 | xargs kubectl logs -f @kubectl get pods -o wide | grep Running | grep schema-orchestrator | cut -d " " -f1 | xargs kubectl logs -f
login: login:
echo -e "machine git.science.uu.nl\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc echo -e "machine git.science.uu.nl\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
\ No newline at end of file
push:
@go get -u -v all
@go mod tidy --compat=1.17
\ No newline at end of file
module schema-orchestrator module schema-orchestrator
go 1.18 go 1.21
require ( require (
git.science.uu.nl/graphpolaris/broker v0.0.0-20230809123708-7d1c1acf3e91 git.science.uu.nl/graphpolaris/broker v0.0.0-20230809123708-7d1c1acf3e91
git.science.uu.nl/graphpolaris/keyvaluestore v0.0.0-20230829154955-1d33a3308a57 git.science.uu.nl/graphpolaris/keyvaluestore v0.0.0-20230912093203-1b3c86eb558a
git.science.uu.nl/graphpolaris/objectstore v0.0.0-20210913150113-977062fb8a3c github.com/arangodb/go-driver v1.6.0
github.com/arangodb/go-driver v1.2.1
github.com/go-chi/cors v1.2.1 github.com/go-chi/cors v1.2.1
github.com/rs/zerolog v1.29.1 github.com/rs/zerolog v1.30.0
google.golang.org/grpc v1.41.0 google.golang.org/grpc v1.58.0
google.golang.org/protobuf v1.25.0 google.golang.org/protobuf v1.31.0
) )
require ( require (
github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e // indirect github.com/arangodb/go-velocypack v0.0.0-20200318135517-5af53c29c67e // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/go-redis/redis/v8 v8.8.2 // indirect github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/golang/protobuf v1.4.3 // indirect github.com/golang/protobuf v1.5.3 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect github.com/mattn/go-isatty v0.0.19 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/streadway/amqp v1.0.0 // indirect github.com/streadway/amqp v1.1.0 // indirect
github.com/thijsheijden/alice v0.1.21-0.20220206104614-72a8777edcc7 // indirect github.com/thijsheijden/alice v0.1.21-0.20220206104614-72a8777edcc7 // indirect
go.opentelemetry.io/otel v0.19.0 // indirect golang.org/x/net v0.15.0 // indirect
go.opentelemetry.io/otel/metric v0.19.0 // indirect golang.org/x/sys v0.12.0 // indirect
go.opentelemetry.io/otel/trace v0.19.0 // indirect golang.org/x/text v0.13.0 // indirect
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230911183012-2d3300fd4832 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
) )
replace git.science.uu.nl/graphpolaris/broker => ../../dependencies/broker replace git.science.uu.nl/graphpolaris/broker => ../../dependencies/broker
replace git.science.uu.nl/graphpolaris/objectstore => ../../dependencies/objectstore
replace git.science.uu.nl/graphpolaris/keyvaluestore => ../../dependencies/keyvaluestore replace git.science.uu.nl/graphpolaris/keyvaluestore => ../../dependencies/keyvaluestore
This diff is collapsed.
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"net/http" "net/http"
"os" "os"
"schema-orchestrator/internal/usecases/schema" "schema-orchestrator/internal/usecases/schema"
"strings"
"github.com/go-chi/cors" "github.com/go-chi/cors"
) )
...@@ -23,6 +24,7 @@ type Listener struct { ...@@ -23,6 +24,7 @@ type Listener struct {
/* /*
CreateListener creates a web listener CreateListener creates a web listener
schemaService: schema.UseCase, the schema usecase schemaService: schema.UseCase, the schema usecase
Return: *Listener, returns a web listener Return: *Listener, returns a web listener
*/ */
...@@ -48,15 +50,17 @@ func (l *Listener) SetupHandlers() { ...@@ -48,15 +50,17 @@ func (l *Listener) SetupHandlers() {
handler := l.schemaRequestHandler() handler := l.schemaRequestHandler()
if os.Getenv("DEV") == "true" { if os.Getenv("DEV") == "true" {
AllowedOrigins := strings.Split(os.Getenv("ALLOWED_ORIGINS"), ",")
c := cors.New(cors.Options{ c := cors.New(cors.Options{
// AllowedOrigins: []string{"https://foo.com"}, // Use this to allow specific origin hosts // AllowedOrigins: []string{"https://foo.com"}, // Use this to allow specific origin hosts
AllowedOrigins: []string{"http://localhost:4200/", "http://localhost:4200"}, AllowedOrigins: AllowedOrigins,
AllowOriginFunc: func(r *http.Request, origin string) bool { return true }, AllowOriginFunc: func(r *http.Request, origin string) bool { return true },
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token", "Access-Control-Allow-Origin"}, AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token", "Access-Control-Allow-Origin"},
ExposedHeaders: []string{"Link"}, ExposedHeaders: []string{"Link"},
AllowCredentials: true, AllowCredentials: true,
MaxAge: 300, // Maximum value not ignored by any of major browsers MaxAge: 300, // Maximum value not ignored by any of major browsers
// Debug: true, // Debug: true,
}) })
handler = c.Handler(handler) handler = c.Handler(handler)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment