Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
Signed-off-by: SammyOina <[email protected]>
  • Loading branch information
SammyOina committed Oct 17, 2023
1 parent d80e29d commit be2a7a2
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 227 deletions.
3 changes: 1 addition & 2 deletions cmd/coap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func main() {
Port: targetPort,
}

tc, tcHandler, err := thingsclient.Setup()
if err != nil {
logger.Error(err.Error())
exitCode = 1
Expand Down Expand Up @@ -152,7 +151,7 @@ func main() {
g.Go(func() error {
return cs.Start()
})
return proxyCoAP(ctx, coapServerConfig, logger, coap.NewHandler(nps, logger, tc))
return proxyCoAP(ctx, coapServerConfig, logger, coap.NewHandler(nps, logger, auth))
})
g.Go(func() error {
return server.StopSignalHandler(ctx, cancel, logger, svcName, hs, cs)
Expand Down
22 changes: 12 additions & 10 deletions coap/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"strings"
"time"

"github.com/mainflux/mainflux"
"github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/pkg/errors"
"github.com/mainflux/mainflux/pkg/messaging"
"github.com/mainflux/mainflux/things/policies"
"github.com/mainflux/mproxy/pkg/session"
)

Expand Down Expand Up @@ -56,12 +56,12 @@ var channelRegExp = regexp.MustCompile(`^\/?channels\/([\w\-]+)\/messages(\/[^?]
// Event implements events.Event interface.
type handler struct {
pubsub messaging.PubSub
auth policies.AuthServiceClient
auth mainflux.AuthzServiceClient
logger logger.Logger
}

// NewHandler creates new Handler entity.
func NewHandler(pubsub messaging.PubSub, logger logger.Logger, auth policies.AuthServiceClient) session.Handler {
func NewHandler(pubsub messaging.PubSub, logger logger.Logger, auth mainflux.AuthzServiceClient) session.Handler {
return &handler{
logger: logger,
pubsub: pubsub,
Expand All @@ -86,7 +86,7 @@ func (h *handler) AuthPublish(ctx context.Context, topic *string, payload *[]byt
return ErrClientNotInitialized
}

return h.authAccess(ctx, string(s.Password), *topic, policies.WriteAction)
return h.authAccess(ctx, string(s.Password), *topic, "publish")
}

// AuthSubscribe is called on device publish,
Expand All @@ -101,7 +101,7 @@ func (h *handler) AuthSubscribe(ctx context.Context, topics *[]string) error {
}

for _, v := range *topics {
if err := h.authAccess(ctx, string(s.Password), v, policies.ReadAction); err != nil {
if err := h.authAccess(ctx, string(s.Password), v, "subscribe"); err != nil {
return err
}
}
Expand Down Expand Up @@ -190,11 +190,13 @@ func (h *handler) authAccess(ctx context.Context, password, topic, action string

chanID := channelParts[1]

ar := &policies.AuthorizeReq{
Subject: password,
Object: chanID,
Action: action,
EntityType: policies.ThingEntityType,
ar := &mainflux.AuthorizeReq{
Namespace: "",
SubjectType: "thing",
Permission: action,
Subject: password,
Object: chanID,
ObjectType: "group",
}
res, err := h.auth.Authorize(ctx, ar)
if err != nil {
Expand Down
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require (
github.com/oklog/ulid/v2 v2.1.0
github.com/ory/dockertest/v3 v3.10.0
github.com/pelletier/go-toml v1.9.5
github.com/plgd-dev/go-coap/v2 v2.6.0
github.com/plgd-dev/go-coap/v3 v3.1.5
github.com/prometheus/client_golang v1.17.0
github.com/rabbitmq/amqp091-go v1.9.0
github.com/rubenv/sql-migrate v1.5.2
Expand Down Expand Up @@ -172,12 +172,10 @@ require (
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runc v1.1.9 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pion/dtls/v2 v2.2.7 // indirect
github.com/pion/dtls/v2 v2.2.8-0.20230905141523-2b584af66577 // indirect
github.com/pion/logging v0.2.2 // indirect
github.com/pion/transport/v2 v2.2.4 // indirect
github.com/pion/transport/v3 v3.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/plgd-dev/go-coap/v3 v3.1.5 // indirect
github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
Expand Down
36 changes: 4 additions & 32 deletions go.sum

Large diffs are not rendered by default.

170 changes: 0 additions & 170 deletions vendor/github.com/pion/transport/v2/udp/batchconn.go

This file was deleted.

1 change: 1 addition & 0 deletions vendor/github.com/pion/transport/v3/AUTHORS.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions vendor/github.com/pion/transport/v3/netctx/conn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ github.com/pion/dtls/v2/pkg/protocol/recordlayer
# github.com/pion/logging v0.2.2
## explicit; go 1.12
github.com/pion/logging
# github.com/pion/transport/v2 v2.2.4
# github.com/pion/transport/v3 v3.0.1
## explicit; go 1.12
github.com/pion/transport/v3/deadline
github.com/pion/transport/v3/netctx
Expand Down Expand Up @@ -744,9 +744,6 @@ github.com/plgd-dev/go-coap/v3/udp
github.com/plgd-dev/go-coap/v3/udp/client
github.com/plgd-dev/go-coap/v3/udp/coder
github.com/plgd-dev/go-coap/v3/udp/server
# github.com/plgd-dev/kit/v2 v2.0.0-20211006190727-057b33161b90
## explicit; go 1.13
github.com/plgd-dev/kit/v2/sync
# github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
## explicit
github.com/pmezard/go-difflib/difflib
Expand Down

0 comments on commit be2a7a2

Please sign in to comment.