Skip to content

Commit

Permalink
Merge pull request #37 from ultravioletrs/update-proxy
Browse files Browse the repository at this point in the history
NOISSUE - Sync auth with latest changes from magistrala
  • Loading branch information
drasko authored Nov 8, 2024
2 parents f6d6aa9 + 8e26bff commit 9c5cff8
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 387 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Ultraviolet
# SPDX-License-Identifier: Apache-2.0

.git
.github
.gitignore
.golangci.yaml
README.md
hal
ui
23 changes: 11 additions & 12 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (

"github.com/absmach/callhome/pkg/client"
"github.com/absmach/magistrala"
authclient "github.com/absmach/magistrala/auth/api/grpc"
mglog "github.com/absmach/magistrala/logger"
"github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/authn/authsvc"
"github.com/absmach/magistrala/pkg/grpcclient"
"github.com/absmach/magistrala/pkg/jaeger"
"github.com/absmach/magistrala/pkg/prometheus"
Expand Down Expand Up @@ -70,24 +71,22 @@ func main() {
}
}

authCfg := grpcclient.Config{}
if err := env.ParseWithOptions(&authCfg, env.Options{Prefix: envPrefixAuth}); err != nil {
logger.Error(fmt.Sprintf("failed to load %s auth configuration : %s", svcName, err))
grpcCfg := grpcclient.Config{}
if err := env.ParseWithOptions(&grpcCfg, env.Options{Prefix: envPrefixAuth}); err != nil {
logger.Error(fmt.Sprintf("failed to load auth gRPC client configuration : %s", err))
exitCode = 1

return
}

authClient, authHandler, err := grpcclient.SetupAuthClient(ctx, authCfg)
auth, authnClient, err := authsvc.NewAuthentication(ctx, grpcCfg)
if err != nil {
logger.Error(err.Error())
exitCode = 1

return
}
defer authHandler.Close()

logger.Info("Auth service gRPC client successfully connected to auth gRPC server " + authHandler.Secure())
defer authnClient.Close()
logger.Info("AuthN successfully connected to auth gRPC server " + authnClient.Secure())

tp, err := jaeger.NewProvider(ctx, svcName, cfg.JaegerURL, cfg.InstanceID, cfg.TraceRatio)
if err != nil {
Expand All @@ -103,7 +102,7 @@ func main() {
}()
tracer := tp.Tracer(svcName)

svc := newService(authClient, logger, tracer)
svc := newService(auth, logger, tracer)

httpServerConfig := server.Config{Port: defSvcHTTPPort}
if err := env.ParseWithOptions(&httpServerConfig, env.Options{Prefix: envPrefixHTTP}); err != nil {
Expand Down Expand Up @@ -133,8 +132,8 @@ func main() {
}
}

func newService(authClient authclient.AuthServiceClient, logger *slog.Logger, tracer trace.Tracer) proxy.Service {
svc := proxy.NewService(authClient)
func newService(auth authn.Authentication, logger *slog.Logger, tracer trace.Tracer) proxy.Service {
svc := proxy.NewService(auth)
svc = middleware.NewLoggingMiddleware(logger, svc)
svc = middleware.NewTracingMiddleware(tracer, svc)
counter, latency := prometheus.MakeMetrics(svcName, "api")
Expand Down
45 changes: 18 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,53 @@ go 1.23.1

require (
github.com/absmach/callhome v0.14.0
github.com/absmach/magistrala v0.14.1-0.20241007084629-d454db70e8aa
github.com/absmach/magistrala v0.14.1-0.20241104104640-87c390da4c9f
github.com/caarlos0/env/v11 v11.2.2
github.com/go-chi/chi/v5 v5.1.0
github.com/go-kit/kit v0.13.0
github.com/prometheus/client_golang v1.20.4
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0
go.opentelemetry.io/otel/trace v1.30.0
golang.org/x/sync v0.8.0
github.com/prometheus/client_golang v1.20.5
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0
go.opentelemetry.io/otel/trace v1.31.0
golang.org/x/sync v0.9.0
)

require (
github.com/absmach/senml v1.0.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gofrs/uuid/v5 v5.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgtype v1.14.3 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rubenv/sql-migrate v1.7.0 // indirect
github.com/smarty/assertions v1.16.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.30.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/sdk v1.30.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.56.0 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.19.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.67.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
moul.io/http2curl v1.0.0 // indirect
)
Loading

0 comments on commit 9c5cff8

Please sign in to comment.