opentdf-v2-poc

command module
v0.0.0-...-112638b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2024 License: BSD-3-Clause-Clear Imports: 1 Imported by: 0

README

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
  1. docker-compose -f opentdf-compose.yaml up

  2. cp example-opentdf.yaml opentdf.yaml and update the values

  3. 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.

Documentation

Overview

Copyright © 2023 OpenTDF opentdf@virtru.com

Directories

Path Synopsis
'Copyright 2023 Virtru Corporation'
'Copyright 2023 Virtru Corporation'
internal
db
opa
sdk module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL