From 08e65722cec207874e7e6facaf51ba58ccfb3844 Mon Sep 17 00:00:00 2001 From: skeris Date: Mon, 2 Dec 2024 01:10:20 +0300 Subject: [PATCH] -- --- .gitea/workflows/deploy.yml | 2 +- Dockerfile | 6 +-- deployments/staging/docker-compose.yaml | 41 +++++++++++++------- internal/server/http/http_server.go | 1 + internal/utils/jwt_adapter/jwt_adapter.go | 3 ++ internal/utils/middleware/http_middleware.go | 1 + 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 10c120e..fa4e871 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -10,7 +10,7 @@ on: jobs: CreateImage: runs-on: [hubstaging] - uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/build-image.yml@v1.1.4 + uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/build-image.yml@v1.1.4-p7 with: runner: hubstaging secrets: diff --git a/Dockerfile b/Dockerfile index 3acf801..65b7383 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,10 @@ FROM gitea.pena/penadevops/container-images/golang:main as builder WORKDIR /app -RUN apk add git COPY . . ENV GOPRIVATE=gitea.pena/PenaSide/linters-golang ENV GOINSECURE=gitea.pena/PenaSide/linters-golang -RUN go env -RUN go mod download -x -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o heruvym +RUN go mod download +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o heruvym cmd/main.go FROM gitea.pena/penadevops/container-images/alpine:main COPY --from=builder /app/heruvym . diff --git a/deployments/staging/docker-compose.yaml b/deployments/staging/docker-compose.yaml index 53bcb37..7b8ff31 100644 --- a/deployments/staging/docker-compose.yaml +++ b/deployments/staging/docker-compose.yaml @@ -3,22 +3,35 @@ services: restart: unless-stopped image: gitea.pena:3000/penaside/heruvym/staging:$GITHUB_RUN_NUMBER ports: - - 10.7.0.6:1487:1488 + - 10.7.0.6:1487:3000 labels: com.pena.upload: true com.pena.allowed_headers: content-type,authorization,response-type tty: true environment: - - BB_PORT=1488 - - BB_IS_PROD=true - - BB_MINIO_AK=5CV77KVDUU9H0II9R24M - - BB_MINIO_EP=s3.timeweb.cloud - - BB_MINIO_SK=0W0m8DyvdAKRJnsAy6mB5zndQ7RouJBLhqhtThcu - - BB_MONGO_URI=$BB_MONGO_URI - - S3_REGION=ru-1 - - JWT_SECRET=$JWT_SECRET - - TELEGRAM_TOKEN=6414077478:AAFk03HezovLT2kO_i9OYswH8Weirsgp9GU - - TELEGRAM_CHAT_ID=1002089014760 - - REDIS_HOST=10.8.0.5:6379 - - REDIS_PASSWORD=Redalert2 - - REDIS_DB=4 + HTTP_PORT: 3000 + HTTP_HOST: 0.0.0.0 + BB_IS_PROD: true + BB_MINIO_AK: 5CV77KVDUU9H0II9R24M + BB_MINIO_EP: s3.timeweb.cloud + BB_MINIO_SK: 0W0m8DyvdAKRJnsAy6mB5zndQ7RouJBLhqhtThcu + MONGO_HOST: mongodb.pena + MONGO_PORT: 27017 + MONGO_USER: support + MONGO_PASSWORD: 54143ffdd9304865586e5cf2 + MONGO_DB: support + MONGO_AUTH: support + BB_MONGO_URI: "mongodb://support:54143ffdd9304865586e5cf2@mongodb.pena/?authSource=support" + S3_REGION: ru-1 + JWT_SECRET: > + -----BEGIN PUBLIC KEY----- + MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCLW1tlHyKC9AG0hGpmkksET2DE + r7ojSPemxFWAgFgcPJWQ7x3uNbsdJ3bIZFoA/FClaWKMCZmjnH9tv0bKZtY/CDhM + ZEyHpMruRSn6IKrxjtQZWy4uv/w6MzUeyBYG0OvNCiYpdvz5SkAGAUHD5ZNFqn2w + KKFD0I2Dr59BFVSGJwIDAQAB + -----END PUBLIC KEY----- + TELEGRAM_TOKEN: "6414077478:AAFk03HezovLT2kO_i9OYswH8Weirsgp9GU" + TELEGRAM_CHAT_ID: 1002089014760 + REDIS_HOST: "10.7.0.6:6379" + REDIS_PASSWORD: Redalert2 + REDIS_DB: 4 diff --git a/internal/server/http/http_server.go b/internal/server/http/http_server.go index b46d6ae..92ab48f 100644 --- a/internal/server/http/http_server.go +++ b/internal/server/http/http_server.go @@ -28,6 +28,7 @@ func NewServer(config ServerConfig) *Server { app.Use(config.MW.MiddlewareLogger) app.Use(config.MW.MiddlewareOriginAccess) app.Use(config.MW.MiddlewareJwt) + app.Use(config.MW.MiddlewareGetJwt) app.Use(config.MW.ExtractHostMiddleware) s := &Server{ diff --git a/internal/utils/jwt_adapter/jwt_adapter.go b/internal/utils/jwt_adapter/jwt_adapter.go index 626605a..1d0d12a 100644 --- a/internal/utils/jwt_adapter/jwt_adapter.go +++ b/internal/utils/jwt_adapter/jwt_adapter.go @@ -27,6 +27,8 @@ type JwtAdapter struct { func init() { aS := os.Getenv("JWT_SECRET") + fmt.Println("JWT_SECRET", aS) + if len(aS) != 0 { accessSecret = aS } @@ -65,6 +67,7 @@ func (receiver *JwtAdapter) Validate() error { } func Decode(tokenString string) (*JwtAdapter, error) { + fmt.Println("JWT_SECRET2", tokenString, accessSecret) token, err := jwt.ParseWithClaims(tokenString, &JwtAdapter{}, func(token *jwt.Token) (interface{}, error) { if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok { return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) diff --git a/internal/utils/middleware/http_middleware.go b/internal/utils/middleware/http_middleware.go index 6859462..aa78a15 100644 --- a/internal/utils/middleware/http_middleware.go +++ b/internal/utils/middleware/http_middleware.go @@ -54,6 +54,7 @@ func (mw *Middleware) MiddlewareOriginAccess(ctx *fiber.Ctx) error { return ctx.SendStatus(fiber.StatusForbidden) } } + fmt.Println("MWLOGGER", ctx.Get("Origin")) return ctx.Next() }