Skip to content

Commit

Permalink
fix authorize (networkservicemesh#1637)
Browse files Browse the repository at this point in the history
* fix authorize

Signed-off-by: NikitaSkrynnik <[email protected]>

* rework condition

Signed-off-by: NikitaSkrynnik <[email protected]>

* fix test

Signed-off-by: NikitaSkrynnik <[email protected]>

* add check for nil

Signed-off-by: NikitaSkrynnik <[email protected]>

---------

Signed-off-by: NikitaSkrynnik <[email protected]>
  • Loading branch information
NikitaSkrynnik authored May 30, 2024
1 parent c01f9e1 commit 50c0908
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/networkservice/common/authorize/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ func (a *authorizeServer) Close(ctx context.Context, conn *networkservice.Connec
a.spiffeIDConnectionMap.Store(spiffeID, ids)
}
}
if _, ok := peer.FromContext(ctx); ok {

if p, ok := peer.FromContext(ctx); ok && p != nil && *p != (peer.Peer{}) {
if err := a.policies.check(ctx, leftSide); err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/networkservice/common/authorize/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"crypto/tls"
"crypto/x509"
"math/big"
"net"
"net/url"
"os"
"path"
Expand Down Expand Up @@ -181,7 +182,7 @@ func TestAuthzEndpoint(t *testing.T) {
require.Equal(t, s.Code(), codes.PermissionDenied, "wrong error status code")
}

ctx := peer.NewContext(context.Background(), &peer.Peer{})
ctx := peer.NewContext(context.Background(), &peer.Peer{Addr: &net.IPAddr{}})

_, err := srv.Request(ctx, s.request)
checkResult(err)
Expand Down

0 comments on commit 50c0908

Please sign in to comment.