OpenTDF Enhancements POC
Development
Prerequisites
Air
With go 1.18 or higher:
go install github.com/cosmtrek/air@v1.49.0
Buf
brew install buf
Run
-
docker-compose -f opentdf-compose.yaml up
-
cp example-opentdf.yaml opentdf.yaml
and update the values
-
air
This should bring up a grpc server on port 9000 and http server on port 8080 (see example-opentdf.yaml). Air will watch for changes and restart the server.
Test
[!WARNING]
GRPC and reflection is disabled by default. Please see the opentdf.yaml
for more details (see example-opentdf.yaml)
grpcurl -plaintext localhost:9000 list
attributes.AttributesService
grpc.reflection.v1.ServerReflection
grpc.reflection.v1alpha.ServerReflection
kasregistry.KeyAccessServerRegistryService
namespaces.NamespaceService
resourcemapping.ResourceMappingService
subjectmapping.SubjectMappingService
grpcurl -plaintext localhost:9000 list attributes.AttributesService
attributes.AttributesService.CreateAttribute
attributes.AttributesService.CreateAttributeValue
attributes.AttributesService.DeleteAttribute
attributes.AttributesService.DeleteAttributeValue
attributes.AttributesService.GetAttribute
attributes.AttributesService.GetAttributeValue
attributes.AttributesService.ListAttributeValues
attributes.AttributesService.ListAttributes
attributes.AttributesService.UpdateAttribute
attributes.AttributesService.UpdateAttributeValue
Create Attribute
grpcurl -plaintext -d @ localhost:9000 attributes.v1.AttributesService/CreateAttribute <<EOM
{
"definition": {
"name": "relto",
"rule":"ATTRIBUTE_RULE_TYPE_ANY_OF",
"values": [
{
"value": "test1"
},
{
"value": "test2"
}
],
"descriptor": {
"labels": [
{
"key": "test2",
"value": "test2"
},
{
"key": "test3",
"value": "test3"
}
],
"description": "this is a test attribute",
"namespace": "virtru.com",
"name": "attribute1",
"type":"POLICY_RESOURCE_TYPE_ATTRIBUTE_DEFINITION"
}
}
}
EOM
List Attributes
grpcurl -plaintext localhost:9000 attributes.v1.AttributesService/ListAttributes
Generation
Our native gRPC service functions are generated from proto
definitions using Buf.
The Makefile
provides command scripts to invoke Buf
with the buf.gen.yaml
config, including OpenAPI docs, grpc docs, and the
generated code.
For convenience, the make pre-build
script checks if you have the necessary dependencies for proto -> gRPC
generation.