Skip to content

Commit

Permalink
chore(kas): remove unused code (#1019)
Browse files Browse the repository at this point in the history
Just some basic house keeping trying to clean up more left overs from
backend-go.
  • Loading branch information
strantalis authored Jun 21, 2024
1 parent 239d9fa commit d52cc06
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 177 deletions.
19 changes: 0 additions & 19 deletions service/kas/access/accessPdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ func canAccess(ctx context.Context, token *authorization.Token, policy Policy, s
return true, nil
}

func checkDissems(dissems []string, ent *authorization.Entity) (bool, error) {
if ent.GetEmailAddress() == "" {
return false, ErrPolicyDissemInvalid
}
if len(dissems) == 0 || contains(dissems, ent.GetEmailAddress()) {
return true, nil
}
return false, nil
}

func checkAttributes(ctx context.Context, dataAttrs []Attribute, ent *authorization.Token, sdk *otdf.SDK, logger logger.Logger) (bool, error) {
ras := []*authorization.ResourceAttribute{{
AttributeValueFqns: make([]string, 0),
Expand Down Expand Up @@ -74,12 +64,3 @@ func checkAttributes(ctx context.Context, dataAttrs []Attribute, ent *authorizat
}
return false, nil
}

func contains(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}
59 changes: 0 additions & 59 deletions service/kas/access/accessPdp_test.go

This file was deleted.

15 changes: 0 additions & 15 deletions service/kas/access/claimsObject.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tdf3
package access

type KeyAccess struct {
EncryptedMetadata string `json:"encryptedMetadata,omitempty"`
Expand Down
15 changes: 7 additions & 8 deletions service/kas/access/rewrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/opentdf/platform/service/internal/logger"
"github.com/opentdf/platform/service/internal/logger/audit"
"github.com/opentdf/platform/service/internal/security"
"github.com/opentdf/platform/service/kas/tdf3"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
Expand All @@ -42,13 +41,13 @@ type SignedRequestBody struct {
}

type RequestBody struct {
AuthToken string `json:"authToken"`
KeyAccess tdf3.KeyAccess `json:"keyAccess"`
Policy string `json:"policy,omitempty"`
Algorithm string `json:"algorithm,omitempty"`
ClientPublicKey string `json:"clientPublicKey"`
PublicKey interface{} `json:"-"`
SchemaVersion string `json:"schemaVersion,omitempty"`
AuthToken string `json:"authToken"`
KeyAccess KeyAccess `json:"keyAccess"`
Policy string `json:"policy,omitempty"`
Algorithm string `json:"algorithm,omitempty"`
ClientPublicKey string `json:"clientPublicKey"`
PublicKey interface{} `json:"-"`
SchemaVersion string `json:"schemaVersion,omitempty"`
}

type entityInfo struct {
Expand Down
11 changes: 6 additions & 5 deletions service/kas/access/rewrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/lestrrat-go/jwx/v2/jws"
"github.com/lestrrat-go/jwx/v2/jwt"
"github.com/opentdf/platform/lib/ocrypto"
"github.com/opentdf/platform/service/internal/auth"
"github.com/opentdf/platform/service/internal/logger"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/google/uuid"
kaspb "github.com/opentdf/platform/protocol/go/kas"
"github.com/opentdf/platform/service/kas/tdf3"
"google.golang.org/grpc/metadata"
)

Expand Down Expand Up @@ -203,10 +203,11 @@ func createTestLogger(t *testing.T) logger.Logger {
return *l
}

func keyAccessWrappedRaw(t *testing.T) tdf3.KeyAccess {
func keyAccessWrappedRaw(t *testing.T) KeyAccess {
policyBytes := fauxPolicyBytes(t)

wrappedKey, err := tdf3.EncryptWithPublicKey([]byte(plainKey), entityPublicKey(t))
asym, err := ocrypto.NewAsymEncryption(rsaPublicAlt)
require.NoError(t, err, "rewrap: NewAsymEncryption failed")
wrappedKey, err := asym.Encrypt([]byte(plainKey))
require.NoError(t, err, "rewrap: encryptWithPublicKey failed")

logger := createTestLogger(t)
Expand All @@ -219,7 +220,7 @@ func keyAccessWrappedRaw(t *testing.T) tdf3.KeyAccess {
policyBinding := base64.StdEncoding.EncodeToString(dst)
slog.Debug("Generated binding", "binding", bindingBytes, "encodedBinding", policyBinding)

return tdf3.KeyAccess{
return KeyAccess{
Type: "wrapped",
URL: "http://127.0.0.1:4000",
Protocol: "kas",
Expand Down
12 changes: 0 additions & 12 deletions service/kas/access/version.gof

This file was deleted.

29 changes: 0 additions & 29 deletions service/kas/tdf3/encrypter.go

This file was deleted.

29 changes: 0 additions & 29 deletions service/kas/tdf3/encrypter_test.go

This file was deleted.

0 comments on commit d52cc06

Please sign in to comment.