Improve Rust code generation and add Upgrade tasks

This commit is contained in:
Nadja von Reitzenstein Čerpnjak 2024-04-22 13:56:50 +02:00
parent 229026db42
commit cae56b0084
9 changed files with 32 additions and 16 deletions

View File

@ -9,6 +9,7 @@ using import "main.capnp".Session;
struct AuthSupported { struct AuthSupported {
mechs @0 :List(Mechanism); mechs @0 :List(Mechanism);
cbtypes @1 :List(Text); cbtypes @1 :List(Text);
upgrades @2 :List(Text);
} }
struct Mechanism { struct Mechanism {
@ -17,7 +18,7 @@ struct Mechanism {
# Additional Info for OpenID / OAUTH2 # Additional Info for OpenID / OAUTH2
} }
struct Response { struct Response(Successful) {
enum Reason { enum Reason {
aborted @0; aborted @0;
# This authentication exchange was aborted by either side. # This authentication exchange was aborted by either side.
@ -91,7 +92,7 @@ struct Response {
# The exchange was successful and a new session has been created for the authzid that # The exchange was successful and a new session has been created for the authzid that
# was established by the SASL exchange. # was established by the SASL exchange.
session @4 :Session; session @4 :Successful;
# The session that was created. It grants access to all capabilities the connecting # The session that was created. It grants access to all capabilities the connecting
# party has permissions for. # party has permissions for.
@ -104,8 +105,9 @@ struct Response {
# The current authentication exchange was successful, but the client needs to perform # The current authentication exchange was successful, but the client needs to perform
# a second round of authentication (e.g. 2FA) to continue. # a second round of authentication (e.g. 2FA) to continue.
nextMechanisms @6 :List(Mechanism); tasks @6 :List(Mechanism);
# List of mechanisms now available to the client. # List of mechanisms now available to the client. Authentication by those MUST NOT
# establish a new security layer or set a new authorization id.
additionalData @7 :Data; additionalData @7 :Data;
# SASL may send additional data with the continue result. This MAY be a NULL-ptr or a # SASL may send additional data with the continue result. This MAY be a NULL-ptr or a
@ -115,8 +117,8 @@ struct Response {
} }
} }
interface Authentication { interface Authentication(Successful) {
step @0 ( data :Data ) -> Response; step @0 ( data :Data ) -> Response(Successful);
# Respond to a challenge with more data. A client MUST NOT call this after having received an # Respond to a challenge with more data. A client MUST NOT call this after having received an
# "successful" response. # "successful" response.
@ -129,6 +131,6 @@ interface Authentication {
# after sending this response. The server MAY after a short grace period terminate the stream # after sending this response. The server MAY after a short grace period terminate the stream
# without sending a response if no call to `step` was received by the client. # without sending a response if no call to `step` was received by the client.
nextAuthenticate @2 ( mechanism :Text, initialData :Data ) -> Response; nextTask @2 ( mechanism :Text, initialData :Data ) -> Response(Successful);
# Call this after a continue was returned # Call this after a continue was returned
} }

View File

@ -35,7 +35,7 @@ interface Bootstrap
mechanisms @3 () -> AuthSupported; mechanisms @3 () -> AuthSupported;
# Get a list of Mechanisms this server allows in this context. # Get a list of Mechanisms this server allows in this context.
createSession @4 ( mechanism :Text ) -> ( authentication :Authentication ); createSession @4 ( mechanism :Text, upgrade :Text ) -> ( authentication :Authentication(Session) );
# Create a new session with the server that you wish to authenticate using `mechanism`. If the # Create a new session with the server that you wish to authenticate using `mechanism`. If the
# mechanism is a client-first mechanism you can then immediately call Authentication::step with # mechanism is a client-first mechanism you can then immediately call Authentication::step with
# initial data in a pipelined fashion. If the mechanism is server-first you must call # initial data in a pipelined fashion. If the mechanism is server-first you must call

View File

@ -1,5 +1,8 @@
@0x80d4a09e28022edb; @0x80d4a09e28022edb;
using Rust = import "../programming_language/rust.capnp";
$Rust.parentModule("schema::traits");
using CSharp = import "../programming_language/csharp.capnp"; using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");

View File

@ -1,5 +1,8 @@
@0xcdb148188bb77a8e; @0xcdb148188bb77a8e;
using Rust = import "../programming_language/rust.capnp";
$Rust.parentModule("schema::traits");
using CSharp = import "../programming_language/csharp.capnp"; using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");

View File

@ -1,5 +1,8 @@
@0xccad643c8c6f6b25; @0xccad643c8c6f6b25;
using Rust = import "../programming_language/rust.capnp";
$Rust.parentModule("schema::traits");
using CSharp = import "../programming_language/csharp.capnp"; using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");

View File

@ -1,5 +1,8 @@
@0x9fa2b43397f34e02; @0x9fa2b43397f34e02;
using Rust = import "../programming_language/rust.capnp";
$Rust.parentModule("schema::traits");
using CSharp = import "../programming_language/csharp.capnp"; using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");

View File

@ -1,5 +1,8 @@
@0x82abdb5c1dcf399d; @0x82abdb5c1dcf399d;
using Rust = import "../programming_language/rust.capnp";
$Rust.parentModule("schema::traits");
using CSharp = import "../programming_language/csharp.capnp"; using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");

View File

@ -1,5 +1,8 @@
@0xbab3de8275be2271; @0xbab3de8275be2271;
using Rust = import "../programming_language/rust.capnp";
$Rust.parentModule("schema::traits");
using CSharp = import "../programming_language/csharp.capnp"; using CSharp = import "../programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema"); $CSharp.namespace("FabAccessAPI.Schema");

View File

@ -56,14 +56,10 @@ struct UUID {
} }
using OID = Data; using OID = Data;
# An OID is encoded as a sequence of varints. In this encoding the lower 7 bits of each octet # An OID is encoded as a sequence of varints, following ITU-T Rec. X.690 Section 8.19.
# contain data bits while the MSB indicates if the *following* octet is still part of this edge. It # Consider that X.208 does *not* limit the size of arc identifiers! However, a
# is the same encoding UTF-8 uses. To decode you simply collect octets until you find an octet <128 # reasonable size limit is 128 bit per arc, which is the size of the UUID nodes
# and then concat the data bits of all the octets you've accumulated, including the current one. # in the `2.25` subtree.
# This gives you the value of one node. Continue until you've exhausted the available data. This is
# a rather efficient encoding since almost all edges of the OID tree are smaller than 128 and thus
# encode into one byte. X.208 does *not* limit the size of nodes! However, a reasonable size limit
# is 128 bit per node, which is the size of the UUID nodes in the `2.25` subtree.
struct Map(Key, Value) { struct Map(Key, Value) {
# Generic Key-Value-Map # Generic Key-Value-Map