Skip to content

Commit d52cd21

Browse files
authored
feat(core): exposes new well-known configuration endpoint (#299)
* feat(core): exposes new wellknown configuration endpoint - allows services to register public information they need exposed * fix some linting buf lint errors * remove gen files * add gen code back * maybe fix case-insensitive * fix * fix case collision * temporarily rename to fix case sensitivity * Correct casing of wellknownconfiguration * fix import statement * temp remove java sdk * add java sdk back
1 parent b410a60 commit d52cd21

21 files changed

+3143
-51
lines changed

docs/grpc/index.html

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,37 @@ <h2>Table of Contents</h2>
777777
</ul>
778778
</li>
779779

780+
781+
<li>
782+
<a href="#wellknownconfiguration%2fwellknown_configuration.proto">wellknownconfiguration/wellknown_configuration.proto</a>
783+
<ul>
784+
785+
<li>
786+
<a href="#wellknownconfiguration.GetWellKnownConfigurationRequest"><span class="badge">M</span>GetWellKnownConfigurationRequest</a>
787+
</li>
788+
789+
<li>
790+
<a href="#wellknownconfiguration.GetWellKnownConfigurationResponse"><span class="badge">M</span>GetWellKnownConfigurationResponse</a>
791+
</li>
792+
793+
<li>
794+
<a href="#wellknownconfiguration.WellKnownConfig"><span class="badge">M</span>WellKnownConfig</a>
795+
</li>
796+
797+
<li>
798+
<a href="#wellknownconfiguration.WellKnownConfig.ConfigurationEntry"><span class="badge">M</span>WellKnownConfig.ConfigurationEntry</a>
799+
</li>
800+
801+
802+
803+
804+
<li>
805+
<a href="#wellknownconfiguration.WellKnownService"><span class="badge">S</span>WellKnownService</a>
806+
</li>
807+
808+
</ul>
809+
</li>
810+
780811
<li><a href="#scalar-value-types">Scalar Value Types</a></li>
781812
</ul>
782813
</div>
@@ -5827,6 +5858,153 @@ <h4>Methods with HTTP bindings</h4>
58275858

58285859

58295860

5861+
5862+
<div class="file-heading">
5863+
<h2 id="wellknownconfiguration/wellknown_configuration.proto">wellknownconfiguration/wellknown_configuration.proto</h2><a href="#title">Top</a>
5864+
</div>
5865+
<p></p>
5866+
5867+
5868+
<h3 id="wellknownconfiguration.GetWellKnownConfigurationRequest">GetWellKnownConfigurationRequest</h3>
5869+
<p></p>
5870+
5871+
5872+
5873+
5874+
5875+
<h3 id="wellknownconfiguration.GetWellKnownConfigurationResponse">GetWellKnownConfigurationResponse</h3>
5876+
<p></p>
5877+
5878+
5879+
<table class="field-table">
5880+
<thead>
5881+
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
5882+
</thead>
5883+
<tbody>
5884+
5885+
<tr>
5886+
<td>configuration</td>
5887+
<td><a href="#google.protobuf.Struct">google.protobuf.Struct</a></td>
5888+
<td></td>
5889+
<td><p> </p></td>
5890+
</tr>
5891+
5892+
</tbody>
5893+
</table>
5894+
5895+
5896+
5897+
5898+
5899+
<h3 id="wellknownconfiguration.WellKnownConfig">WellKnownConfig</h3>
5900+
<p></p>
5901+
5902+
5903+
<table class="field-table">
5904+
<thead>
5905+
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
5906+
</thead>
5907+
<tbody>
5908+
5909+
<tr>
5910+
<td>configuration</td>
5911+
<td><a href="#wellknownconfiguration.WellKnownConfig.ConfigurationEntry">WellKnownConfig.ConfigurationEntry</a></td>
5912+
<td>repeated</td>
5913+
<td><p> </p></td>
5914+
</tr>
5915+
5916+
</tbody>
5917+
</table>
5918+
5919+
5920+
5921+
5922+
5923+
<h3 id="wellknownconfiguration.WellKnownConfig.ConfigurationEntry">WellKnownConfig.ConfigurationEntry</h3>
5924+
<p></p>
5925+
5926+
5927+
<table class="field-table">
5928+
<thead>
5929+
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
5930+
</thead>
5931+
<tbody>
5932+
5933+
<tr>
5934+
<td>key</td>
5935+
<td><a href="#string">string</a></td>
5936+
<td></td>
5937+
<td><p> </p></td>
5938+
</tr>
5939+
5940+
<tr>
5941+
<td>value</td>
5942+
<td><a href="#google.protobuf.Struct">google.protobuf.Struct</a></td>
5943+
<td></td>
5944+
<td><p> </p></td>
5945+
</tr>
5946+
5947+
</tbody>
5948+
</table>
5949+
5950+
5951+
5952+
5953+
5954+
5955+
5956+
5957+
5958+
5959+
5960+
<h3 id="wellknownconfiguration.WellKnownService">WellKnownService</h3>
5961+
<p></p>
5962+
<table class="enum-table">
5963+
<thead>
5964+
<tr><td>Method Name</td><td>Request Type</td><td>Response Type</td><td>Description</td></tr>
5965+
</thead>
5966+
<tbody>
5967+
5968+
<tr>
5969+
<td>GetWellKnownConfiguration</td>
5970+
<td><a href="#wellknownconfiguration.GetWellKnownConfigurationRequest">GetWellKnownConfigurationRequest</a></td>
5971+
<td><a href="#wellknownconfiguration.GetWellKnownConfigurationResponse">GetWellKnownConfigurationResponse</a></td>
5972+
<td><p></p></td>
5973+
</tr>
5974+
5975+
</tbody>
5976+
</table>
5977+
5978+
5979+
5980+
5981+
<h4>Methods with HTTP bindings</h4>
5982+
<table>
5983+
<thead>
5984+
<tr>
5985+
<td>Method Name</td>
5986+
<td>Method</td>
5987+
<td>Pattern</td>
5988+
<td>Body</td>
5989+
</tr>
5990+
</thead>
5991+
<tbody>
5992+
5993+
5994+
5995+
<tr>
5996+
<td>GetWellKnownConfiguration</td>
5997+
<td>GET</td>
5998+
<td>/.well-known/opentdf-configuration</td>
5999+
<td></td>
6000+
</tr>
6001+
6002+
6003+
</tbody>
6004+
</table>
6005+
6006+
6007+
58306008

58316009
<h2 id="scalar-value-types">Scalar Value Types</h2>
58326010
<table class="scalar-value-types-table">
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "wellknownconfiguration/wellknown_configuration.proto",
5+
"version": "version not set"
6+
},
7+
"tags": [
8+
{
9+
"name": "WellKnownService"
10+
}
11+
],
12+
"consumes": [
13+
"application/json"
14+
],
15+
"produces": [
16+
"application/json"
17+
],
18+
"paths": {
19+
"/.well-known/opentdf-configuration": {
20+
"get": {
21+
"operationId": "WellKnownService_GetWellKnownConfiguration",
22+
"responses": {
23+
"200": {
24+
"description": "A successful response.",
25+
"schema": {
26+
"$ref": "#/definitions/wellknownconfigurationGetWellKnownConfigurationResponse"
27+
}
28+
},
29+
"default": {
30+
"description": "An unexpected error response.",
31+
"schema": {
32+
"$ref": "#/definitions/rpcStatus"
33+
}
34+
}
35+
},
36+
"tags": [
37+
"WellKnownService"
38+
]
39+
}
40+
}
41+
},
42+
"definitions": {
43+
"protobufAny": {
44+
"type": "object",
45+
"properties": {
46+
"@type": {
47+
"type": "string",
48+
"description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
49+
}
50+
},
51+
"additionalProperties": {},
52+
"description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }"
53+
},
54+
"protobufNullValue": {
55+
"type": "string",
56+
"enum": [
57+
"NULL_VALUE"
58+
],
59+
"default": "NULL_VALUE",
60+
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\nThe JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
61+
},
62+
"rpcStatus": {
63+
"type": "object",
64+
"properties": {
65+
"code": {
66+
"type": "integer",
67+
"format": "int32"
68+
},
69+
"message": {
70+
"type": "string"
71+
},
72+
"details": {
73+
"type": "array",
74+
"items": {
75+
"type": "object",
76+
"$ref": "#/definitions/protobufAny"
77+
}
78+
}
79+
}
80+
},
81+
"wellknownconfigurationGetWellKnownConfigurationResponse": {
82+
"type": "object",
83+
"properties": {
84+
"configuration": {
85+
"type": "object"
86+
}
87+
}
88+
}
89+
}
90+
}

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Config struct {
2525
OPA opa.Config `yaml:"opa"`
2626
Server server.Config `yaml:"server"`
2727
Logger logger.Config `yaml:"logger"`
28-
Services map[string]ServiceConfig `yaml:"services" default:"{\"policy\": {\"enabled\": true}, \"health\": {\"enabled\": true}}"`
28+
Services map[string]ServiceConfig `yaml:"services" default:"{\"policy\": {\"enabled\": true}, \"health\": {\"enabled\": true}, \"wellknown\": {\"enabled\": true}}"`
2929
}
3030

3131
type Error string

pkg/server/services.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/opentdf/platform/services/policy/namespaces"
99
"github.com/opentdf/platform/services/policy/resourcemapping"
1010
"github.com/opentdf/platform/services/policy/subjectmapping"
11+
wellknown "github.com/opentdf/platform/services/wellknownconfiguration"
1112
)
1213

1314
func registerServices() error {
@@ -19,6 +20,7 @@ func registerServices() error {
1920
attributes.NewRegistration(),
2021
kasregistry.NewRegistration(),
2122
health.NewRegistration(),
23+
wellknown.NewRegistration(),
2224
} {
2325
if err := serviceregistry.RegisterService(s); err != nil {
2426
return err //nolint:wrapcheck // We are all friends here

pkg/server/start.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/opentdf/platform/internal/opa"
1515
"github.com/opentdf/platform/internal/server"
1616
"github.com/opentdf/platform/pkg/serviceregistry"
17+
wellknown "github.com/opentdf/platform/services/wellknownconfiguration"
1718
)
1819

1920
type StartOptions func(StartConfig) StartConfig
@@ -143,10 +144,11 @@ func startServices(cfg config.Config, otdf *server.OpenTDFServer, dbClient *db.C
143144
for _, r := range registers {
144145
// Create the service
145146
impl, handler := r.RegisterFunc(serviceregistry.RegistrationParams{
146-
Config: cfg.Services[ns],
147-
OTDF: otdf,
148-
DBClient: dbClient,
149-
Engine: eng,
147+
Config: cfg.Services[ns],
148+
OTDF: otdf,
149+
DBClient: dbClient,
150+
Engine: eng,
151+
WellKnownConfig: wellknown.RegisterConfiguration,
150152
})
151153

152154
// Register the service with the gRPC server

pkg/serviceregistry/serviceregistry.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import (
1414
)
1515

1616
type RegistrationParams struct {
17-
Config config.ServiceConfig
18-
OTDF *server.OpenTDFServer
19-
DBClient *db.Client
20-
Engine *opa.Engine
17+
Config config.ServiceConfig
18+
OTDF *server.OpenTDFServer
19+
DBClient *db.Client
20+
Engine *opa.Engine
21+
WellKnownConfig func(namespace string, config any) error
2122
}
2223
type HandlerServer func(ctx context.Context, mux *runtime.ServeMux, server any) error
2324
type RegisterFunc func(RegistrationParams) (Impl any, HandlerServer HandlerServer)

0 commit comments

Comments
 (0)