Skip to content

Commit

Permalink
remove private repos
Browse files Browse the repository at this point in the history
change iso dependency
fix readme
remove cors
  • Loading branch information
surzm committed Aug 27, 2024
1 parent d8b1a70 commit 7df95b0
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 40 deletions.
9 changes: 2 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ FROM golang:1.22.2-alpine3.19 AS builder
WORKDIR /app
ARG GITHUB_TOKEN
RUN cat /etc/resolv.conf && apk add --no-cache git && \
go env -w GOPRIVATE=github.com/galactica-corp/*,github.com/Galactica-corp/* && \
git config --add --global url."git@github.com:".insteadOf https://github.com && \
git config \
--global \
url."https://${GITHUB_TOKEN}@github.com/".insteadOf \
"https://github.com/"
git config --add --global url."git@github.com:".insteadOf https://github.com

# Prepare dependencies
COPY go.mod go.sum ./
COPY go.mod ./
RUN go mod download
# Build the binary
COPY ./cmd ./cmd
Expand Down
6 changes: 2 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ type Config struct {
}

type APIConf struct {
Port string `yaml:"Port" default:"8081"`
Host string `yaml:"Host" default:"0.0.0.0"`
CORSEnabled bool `yaml:"CORSEnabled"`
CORSOrigin string `yaml:"CORSOrigin"`
Port string `yaml:"Port" default:"8081"`
Host string `yaml:"Host" default:"0.0.0.0"`
}

type MerkleProofService struct {
Expand Down
2 changes: 0 additions & 2 deletions config/dev.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
APIConf:
Host: "0.0.0.0"
Port: 8080
CORSEnabled: true
CORSOrigin: http://localhost,http://127.0.0.1:8080

Node: https://evm-rpc-http-andromeda.galactica.com

Expand Down
2 changes: 0 additions & 2 deletions config/prod.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
APIConf:
Host: "0.0.0.0"
Port: 8080
CORSEnabled: true
CORSOrigin: 127.0.0.1

Node: https://evm-rpc-http-reticulum.galactica.com

Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ module github.com/swissborg/galactica-kyc-guardian
go 1.22.5

require (
github.com/DarkJian/iso3166 v0.0.0-20230214154550-37d41898ef74
github.com/Galactica-corp/merkle-proof-service v0.2.7
github.com/biter777/countries v1.7.5
github.com/dgraph-io/badger/v4 v4.2.0
github.com/ethereum/go-ethereum v1.14.8
github.com/galactica-corp/guardians-sdk v1.5.0
github.com/go-playground/validator/v10 v10.19.0
github.com/iden3/go-iden3-crypto v0.0.16
github.com/joho/godotenv v1.5.1
github.com/labstack/echo/v4 v4.12.0
github.com/sirupsen/logrus v1.9.3
github.com/stasundr/decimal v0.1.9
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand All @@ -34,7 +36,6 @@ require (
github.com/go-ole/go-ole v1.3.0 // indirect
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.19.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/glog v1.2.0 // indirect
Expand Down
11 changes: 2 additions & 9 deletions internal/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"time"

iso "github.com/DarkJian/iso3166"
"github.com/biter777/countries"
"github.com/dgraph-io/badger/v4"
"github.com/galactica-corp/guardians-sdk/pkg/zkcertificate"
"github.com/labstack/echo/v4"
Expand Down Expand Up @@ -87,14 +87,7 @@ func (h *Handlers) GenerateCert(c echo.Context) error {
})
}

code, err := iso.I3166().ALPHA2().GetAlpha3(req.Profile.Nationality)
if err != nil {
log.WithError(err).Error(ErrParsNationality)
return c.JSON(http.StatusBadRequest, ErrorResp{
Error: fmt.Sprintf("%v: %v", err, ErrParsNationality),
})
}

code := countries.ByName(req.Profile.Nationality).Alpha3()
inputs := zkcertificate.KYCInputs{
Surname: req.Profile.Firstname,
Forename: req.Profile.Lastname,
Expand Down
13 changes: 1 addition & 12 deletions internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package api
import (
"context"
"fmt"
"strings"
"time"

"github.com/dgraph-io/badger/v4"
Expand Down Expand Up @@ -53,19 +52,9 @@ func (s *Server) Stop() error {

func (s *Server) makeEcho(cfg config.APIConf) *echo.Echo {
e := echo.New()

e.Validator = &CustomValidator{validator: validator.New()}

e.Use(middleware.Recover())

if cfg.CORSEnabled {
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowCredentials: true,
AllowOrigins: strings.Split(cfg.CORSOrigin, ","),
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept, echo.HeaderAccessControlAllowCredentials, echo.HeaderXRequestedWith},
}))
}
e.Validator = &CustomValidator{validator: validator.New()}

handlers := NewHandlers(s.generator, s.mem)

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# swissborg-kyc-provider
# Galactica KYC Guardian

Backend service that generates encrypted zk KYC certificates for the Galactica blockchain based on Swissborg KYC data.

Expand Down Expand Up @@ -102,7 +102,7 @@ Response:
This endpoint get the status of the certificate and its value when computed.

```
POST /cert/get>
POST /cert/get
```

Request body:
Expand Down

0 comments on commit 7df95b0

Please sign in to comment.