Skip to content

Commit e6ec127

Browse files
eddyashtonMahatiCmikeharder
authored
Managed CCF governance API (#23627)
* Rebase with current mCCF gov TypeSpec * Update config, initial build * Managed CCF governance API * Update with current state from CCF repo (Renaming CADL to TypeSpec) * Move files around, and create a minimal `readme.md` * Prettier * Update from CCF main, initial errors, and formatting * Remove prev version * Update autorest README * Spell check and small linters * Drop to supported types for spec validation * Add JWTs to custom-words * Move file, use output-file arg * Correct README name, remove unused package * Pull in latest changes * Latest changes and re-generate * Clearer operation names * Pull latest changes * Rename for consistency, and pull latest changes * Regenerate OpenAPI at correct path * Initial auto-generated examples * Correct visibility * Working towards canonical examples * Improve examples * Rename fles * Ah, build puts these in second location * Improve proposal examples * Pull latest: Mark more optionals, correct discriminator use, fix example-errors * More tweaks to exmaples * Latest * Combine readmes * Format and custom-words * Add missing field * Latest: Verb'd operation IDs * Latest: Remove readOnlys * Rename to restore actions * Rename in source too * Latest, update examples * Fix warnings and rebuild with latest version * Add ManagedCcf to CI pipeline * Suppress doc-required for Versions, remove local package.json * Build with 0.45.0 again * Add specification/confidentialledger to PR trigger * tsp format --------- Co-authored-by: Mahati Chamarthy <mahati.chamarthy@gmail.com> Co-authored-by: Mike Harder <mharder@microsoft.com>
1 parent 16e2be4 commit e6ec127

File tree

59 files changed

+4113
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4113
-1
lines changed

custom-words.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2825,6 +2825,9 @@ Metadatas
28252825
Gtid
28262826
GTID
28272827
gtid
2828+
Acks
2829+
safeuint
2830+
JWTs
28282831
Wifi
28292832
Nwfs
28302833
Hnsw
@@ -2844,4 +2847,4 @@ manytomany
28442847
stransparent
28452848
forceencryption
28462849
tlsciphers
2847-
tlsprotocols
2850+
tlsprotocols

eng/pipelines/typespec-ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pr:
1616
- eng/pipelines/templates/steps/typespec-ci.yml
1717
- specification/contosowidgetmanager
1818
- specification/cognitiveservices
19+
- specification/confidentialledger
1920
- specification/containerservice
2021
- specification/servicenetworking
2122
- specification/translation
@@ -69,6 +70,11 @@ jobs:
6970
Folder: specification/cognitiveservices/OpenAI.Inference
7071
DisplayName: OpenAI.Inference
7172

73+
- template: templates/steps/typespec-ci.yml
74+
parameters:
75+
Folder: specification/confidentialledger/Microsoft.ManagedCcf
76+
DisplayName: ManagedCcf
77+
7278
- template: templates/steps/typespec-ci.yml
7379
parameters:
7480
Folder: specification/containerservice/Fleet.Management
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import "@typespec/rest";
2+
import "@typespec/versioning";
3+
import "@azure-tools/typespec-azure-core";
4+
5+
import "./common.tsp";
6+
import "./cose.tsp";
7+
8+
@TypeSpec.Http.route("/gov/members")
9+
namespace Microsoft.ManagedCcf.Acks;
10+
11+
@doc("A compact summary of the service's state up to a certain point in time, updated and signed by members to indicate their participation in and approval of the service.")
12+
@TypeSpec.Rest.resource("state-digests")
13+
model StateDigest {
14+
@doc("Identifier for member this stateDigest applies to.")
15+
@visibility("query")
16+
@key
17+
memberId: memberId;
18+
19+
@doc("Hex-encoding of SHA-256 hash of the root of the service's merkle tree. This should be signed by a new member and submitted as an ACK to mark that member as Active.")
20+
@pattern("^[a-f0-9]{64}$")
21+
digest: string;
22+
}
23+
24+
interface StateDigests {
25+
@doc("Request that this member's stateDigest is updated to a fresher value. Only this member may update their own stateDigest. Returns the refreshed value.")
26+
@TypeSpec.Rest.action("update")
27+
update is Azure.Core.StandardResourceOperations.ResourceAction<
28+
StateDigest,
29+
CoseSigned,
30+
StateDigest,
31+
TxIdWriteHeader
32+
>;
33+
34+
@doc("Submit a signed acknowledgement of a recent digest of the service status, to transition the member to Active.")
35+
@TypeSpec.Rest.action("ack")
36+
acknowledge is Azure.Core.StandardResourceOperations.ResourceAction<
37+
StateDigest,
38+
CoseSigned<StateDigest>,
39+
TypeSpec.Http.NoContentResponse,
40+
TxIdWriteHeader
41+
>;
42+
43+
@doc("Get the stateDigest assigned to the given member, which that member must sign to become active.")
44+
get is Azure.Core.StandardResourceOperations.ResourceRead<
45+
StateDigest,
46+
TxIdReadHeader
47+
>;
48+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import "@typespec/http";
2+
import "@azure-tools/typespec-azure-core";
3+
4+
namespace Microsoft.ManagedCcf;
5+
6+
alias transactionIdHeaderField = "x-ms-ccf-transaction-id";
7+
8+
@doc("Uniquely identifies an atomic transaction within a CCF service. Composed of a term number and sequence number. Sequence numbers increase monotonically, apart from during elections where the service may reuse an existing sequence number. Each election will result in a new, higher term number being used for the conflicting and future sequence numbers.")
9+
@pattern("^[0-9]+\\.[0-9]+$")
10+
scalar transactionId extends string;
11+
12+
alias TxIdWriteHdr = {
13+
@doc("Identifier for transaction where this request produced a write on the service. This uniquely identifies the submitted request, and can be used to confirm that the request becomes committed.")
14+
@TypeSpec.Http.header(transactionIdHeaderField)
15+
transactionId: transactionId;
16+
};
17+
18+
alias TxIdWriteHeader = Azure.Core.Traits.ResponseHeadersTrait<TxIdWriteHdr>;
19+
20+
alias TxIdReadHdr = {
21+
@doc("Identifier for transaction this response was read from. The service state may be altered by other write requests. Reads at the same transactionId describe a consistent single point in the service history.")
22+
@TypeSpec.Http.header(transactionIdHeaderField)
23+
transactionId: transactionId;
24+
};
25+
26+
alias TxIdReadHeader = Azure.Core.Traits.ResponseHeadersTrait<TxIdReadHdr>;
27+
28+
alias JavaScriptSource = {
29+
@doc("This contains raw JavaScript source code, not escaped into a JSON object.")
30+
@TypeSpec.Http.header("content-type")
31+
contentType: "text/javascript";
32+
};
33+
34+
@doc("Hex encoding of SHA-256 of a node's public key.")
35+
@pattern("^[a-f0-9]{64}$")
36+
scalar nodeId extends string;
37+
38+
@doc("Hex encoding of SHA-256 of a member certificate's fingerprint.")
39+
@pattern("^[a-f0-9]{64}$")
40+
scalar memberId extends string;
41+
42+
@doc("Hex encoding of SHA-256 of user certificate's fingerprint.")
43+
@pattern("^[a-f0-9]{64}$")
44+
scalar userId extends string;
45+
46+
@doc("Hex encoding of SHA-256 of proposed actions and merkle root of store at proposal creation. Unlike other IDs, this is generated on the service and will not be known in advance.")
47+
@pattern("^[a-f0-9]{64}$")
48+
scalar proposalId extends string;
49+
50+
@doc("A non-negative JSON-safe integer (ie max is 2^53 - 1)")
51+
@minValue(0)
52+
scalar safeuint extends safeint;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import "@typespec/http";
2+
3+
@doc("HTTP request containing a COSE signature")
4+
model CoseSignature {
5+
@doc("The MIME content type for all auditable member actions is application/cose, containing a CoseSign1 signature.")
6+
@TypeSpec.Http.header("content-type")
7+
contentType: "application/cose";
8+
9+
@doc("A raw CoseSign1 signature. See CCF docs for required headers and body schema: https://microsoft.github.io/CCF/main/use_apps/issue_commands.html#cose-schemas")
10+
@TypeSpec.Http.body
11+
body: bytes;
12+
}
13+
14+
model CoseSigned<T = {}> extends CoseSignature {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"title": "Ballots_Get",
3+
"operationId": "Ballots_Get",
4+
"parameters": {
5+
"api-version": "2023-06-01-preview",
6+
"proposalId": "1c04c5bb4bdc207dbf35bc4b32dbf92cbc23eabb34a6e8b163b2de2c7833e87b",
7+
"memberId": "f8ac7c60c164f7f13c04ba41645b18eabcc55a8f799c83a90d001f4e89907970"
8+
},
9+
"responses": {
10+
"200": {
11+
"body": {
12+
"script": "export function vote (rawProposal, proposerId) { return true }"
13+
}
14+
}
15+
}
16+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"title": "Ballots_Submit",
3+
"operationId": "Ballots_Submit",
4+
"parameters": {
5+
"api-version": "2023-06-01-preview",
6+
"proposalId": "1c04c5bb4bdc207dbf35bc4b32dbf92cbc23eabb34a6e8b163b2de2c7833e87b",
7+
"memberId": "f8ac7c60c164f7f13c04ba41645b18eabcc55a8f799c83a90d001f4e89907970",
8+
"body": "{binary COSE Sign1}"
9+
},
10+
"responses": {
11+
"200": {
12+
"body": {
13+
"proposalId": "1c04c5bb4bdc207dbf35bc4b32dbf92cbc23eabb34a6e8b163b2de2c7833e87b",
14+
"proposerId": "f8ac7c60c164f7f13c04ba41645b18eabcc55a8f799c83a90d001f4e89907970",
15+
"proposalState": "Open",
16+
"ballotCount": 2,
17+
"finalVotes": {
18+
"f8ac7c60c164f7f13c04ba41645b18eabcc55a8f799c83a90d001f4e89907970": true,
19+
"b9626e3856b3ef3b433e612d59fbb9edd71cfa2efc772bcfbb50aaa9b6e033f7": false
20+
}
21+
}
22+
}
23+
}
24+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"title": "EncryptedShares_Get",
3+
"operationId": "EncryptedShares_Get",
4+
"parameters": {
5+
"api-version": "2023-06-01-preview",
6+
"memberId": "f8ac7c60c164f7f13c04ba41645b18eabcc55a8f799c83a90d001f4e89907970"
7+
},
8+
"responses": {
9+
"200": {
10+
"body": {
11+
"encryptedShare": "ZW5jcnlwdGVkU2hhcmUx"
12+
}
13+
}
14+
}
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"title": "Proposals_Create",
3+
"operationId": "Proposals_Create",
4+
"parameters": {
5+
"api-version": "2023-06-01-preview",
6+
"body": "{binary COSE Sign1}"
7+
},
8+
"responses": {
9+
"200": {
10+
"body": {
11+
"proposalId": "1c04c5bb4bdc207dbf35bc4b32dbf92cbc23eabb34a6e8b163b2de2c7833e87b",
12+
"proposerId": "f8ac7c60c164f7f13c04ba41645b18eabcc55a8f799c83a90d001f4e89907970",
13+
"proposalState": "Open",
14+
"ballotCount": 0,
15+
"finalVotes": {}
16+
}
17+
}
18+
}
19+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"title": "Proposals_Get",
3+
"operationId": "Proposals_Get",
4+
"parameters": {
5+
"api-version": "2023-06-01-preview",
6+
"proposalId": "1c04c5bb4bdc207dbf35bc4b32dbf92cbc23eabb34a6e8b163b2de2c7833e87b"
7+
},
8+
"responses": {
9+
"200": {
10+
"body": {
11+
"proposalId": "1c04c5bb4bdc207dbf35bc4b32dbf92cbc23eabb34a6e8b163b2de2c7833e87b",
12+
"proposerId": "f8ac7c60c164f7f13c04ba41645b18eabcc55a8f799c83a90d001f4e89907970",
13+
"proposalState": "Open",
14+
"ballotCount": 2,
15+
"finalVotes": {
16+
"f8ac7c60c164f7f13c04ba41645b18eabcc55a8f799c83a90d001f4e89907970": true,
17+
"b9626e3856b3ef3b433e612d59fbb9edd71cfa2efc772bcfbb50aaa9b6e033f7": false
18+
}
19+
}
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)