Skip to content

Commit

Permalink
chore: revert "feat: Added Contextual Tuples to Assertions API (#1610)…
Browse files Browse the repository at this point in the history
…" (#1646)
  • Loading branch information
jon-whit authored May 29, 2024
1 parent 89736da commit 8812d3e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 126 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ require (
github.com/karlseguin/ccache/v3 v3.0.5
github.com/natefinch/wrap v0.2.0
github.com/oklog/ulid/v2 v2.1.0
github.com/openfga/api/proto v0.0.0-20240528152008-016839b7eea9
github.com/openfga/language/pkg/go v0.0.0-20240508080213-a861f06327b6
github.com/openfga/api/proto v0.0.0-20240528160929-03aaac2ff923
github.com/openfga/language/pkg/go v0.0.0-20240409225820-a53ea2892d6d
github.com/pressly/goose/v3 v3.20.0
github.com/prometheus/client_golang v1.19.0
github.com/rs/cors v1.10.1
Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,10 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
github.com/openfga/api/proto v0.0.0-20240509182947-591c8fa7765c h1:9eVNx4MTB7XmjzZkEs/QL5wcogIUoG5wZWsx9MtdSQE=
github.com/openfga/api/proto v0.0.0-20240509182947-591c8fa7765c/go.mod h1:3geSv9HPiWV54uUX8FprWCQejCDGFKKhh5JMpcgTblg=
github.com/openfga/api/proto v0.0.0-20240528152008-016839b7eea9 h1:A9eXAYl6tlXM0i8QCJuju1JbJZN9g7gHMvdKch88MQg=
github.com/openfga/api/proto v0.0.0-20240528152008-016839b7eea9/go.mod h1:3geSv9HPiWV54uUX8FprWCQejCDGFKKhh5JMpcgTblg=
github.com/openfga/language/pkg/go v0.0.0-20240508080213-a861f06327b6 h1:iyNcZojsdGW065vyug95/ojj+Iwt/SEl+DgCNEFYIoA=
github.com/openfga/language/pkg/go v0.0.0-20240508080213-a861f06327b6/go.mod h1:mCwEY2IQvyNgfEwbfH0C0ERUwtL8z6UjSAF8zgn5Xbg=
github.com/openfga/api/proto v0.0.0-20240528160929-03aaac2ff923 h1:wdByA6I4EdW+7baYAT6ccbJ7A22+mk9bolk1LLK+ZxQ=
github.com/openfga/api/proto v0.0.0-20240528160929-03aaac2ff923/go.mod h1:3geSv9HPiWV54uUX8FprWCQejCDGFKKhh5JMpcgTblg=
github.com/openfga/language/pkg/go v0.0.0-20240409225820-a53ea2892d6d h1:n44DfITs+CLCYJIgsryJkG2ElwOZJ3huekPZKydPi7U=
github.com/openfga/language/pkg/go v0.0.0-20240409225820-a53ea2892d6d/go.mod h1:wkI4GcY3yNNuFMU2ncHPWqBaF7XylQTkJYfBi2pIpK8=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
Expand Down
7 changes: 0 additions & 7 deletions pkg/server/commands/write_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ func (w *WriteAssertionsCommand) Execute(ctx context.Context, req *openfgav1.Wri
if err := validation.ValidateUserObjectRelation(typesys, tupleUtils.ConvertAssertionTupleKeyToTupleKey(assertion.GetTupleKey())); err != nil {
return nil, serverErrors.ValidationError(err)
}

for _, ct := range assertion.GetContextualTuples().GetTupleKeys() {
if err = validation.ValidateUserObjectRelation(typesys,
tupleUtils.NewTupleKey(ct.GetObject(), ct.GetRelation(), ct.GetUser())); err != nil {
return nil, serverErrors.ValidationError(err)
}
}
}

err = w.datastore.WriteAssertions(ctx, store, modelID, assertions)
Expand Down
111 changes: 0 additions & 111 deletions pkg/server/test/write_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,51 +97,6 @@ type repo
_name: "writing_empty_assertions_succeeds",
assertions: []*openfgav1.Assertion{},
},
{
_name: "writing_multiple_contextual_tuples_assertions_succeeds",

assertions: []*openfgav1.Assertion{
{
TupleKey: tuple.NewAssertionTupleKey("repo:test", "reader", "user:elbuo"),
ContextualTuples: &openfgav1.ContextualTupleKeys{
TupleKeys: []*openfgav1.TupleKey{
{
User: "user:smeadows",
Object: "repo:test",
Relation: "can_read",
},
},
},
Expectation: false,
},
{
TupleKey: tuple.NewAssertionTupleKey("repo:test", "reader", "user:elbuo"),
ContextualTuples: &openfgav1.ContextualTupleKeys{
TupleKeys: []*openfgav1.TupleKey{
{
User: "user:maria",
Object: "repo:test",
Relation: "can_read",
},
},
},
Expectation: false,
},
{
TupleKey: tuple.NewAssertionTupleKey("repo:test", "reader", "user:elbuo"),
ContextualTuples: &openfgav1.ContextualTupleKeys{
TupleKeys: []*openfgav1.TupleKey{
{
User: "user:jon",
Object: "repo:test",
Relation: "can_read",
},
},
},
Expectation: true,
},
},
},
}

ctx := context.Background()
Expand Down Expand Up @@ -237,72 +192,6 @@ type repo
"not_valid_id",
),
},
{
_name: "write_conceptual_tuple_assertion_with_invalid_relation_fails",
assertions: []*openfgav1.Assertion{
{
TupleKey: tuple.NewAssertionTupleKey("repo:test", "reader", "user:elbuo"),
ContextualTuples: &openfgav1.ContextualTupleKeys{
TupleKeys: []*openfgav1.TupleKey{
{
User: "user:jon",
Object: "repo:test",
Relation: "invalidrelation",
},
},
},
Expectation: false,
},
},
modelID: modelID.GetAuthorizationModelId(),
err: serverErrors.ValidationError(
fmt.Errorf("relation 'repo#invalidrelation' not found"),
),
},
{
_name: "write_conceptual_tuple_assertion_with_invalid_object_fails",
assertions: []*openfgav1.Assertion{
{
TupleKey: tuple.NewAssertionTupleKey("repo:test", "reader", "user:elbuo"),
ContextualTuples: &openfgav1.ContextualTupleKeys{
TupleKeys: []*openfgav1.TupleKey{
{
User: "user:jon",
Object: "invalidobject",
Relation: "can_read",
},
},
},
Expectation: false,
},
},
modelID: modelID.GetAuthorizationModelId(),
err: serverErrors.ValidationError(
fmt.Errorf("invalid 'object' field format"),
),
},
{
_name: "write_conceptual_tuple_assertion_with_invalid_user_fails",
assertions: []*openfgav1.Assertion{
{
TupleKey: tuple.NewAssertionTupleKey("repo:test", "reader", "user:elbuo"),
ContextualTuples: &openfgav1.ContextualTupleKeys{
TupleKeys: []*openfgav1.TupleKey{
{
User: "invaliduser",
Object: "repo:test",
Relation: "can_read",
},
},
},
Expectation: false,
},
},
modelID: modelID.GetAuthorizationModelId(),
err: serverErrors.ValidationError(
fmt.Errorf("the 'user' field must be an object (e.g. document:1) or an 'object#relation' or a typed wildcard (e.g. group:*)"),
),
},
}

for _, test := range tests {
Expand Down

0 comments on commit 8812d3e

Please sign in to comment.