From d4e6d048e3a2b94ebbd1212a6ebadffb52ac71db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nadja=20von=20Reitzenstein=20=C4=8Cerpnjak?= Date: Mon, 6 May 2024 14:26:32 +0200 Subject: [PATCH] Terminal stuff --- auth.capnp | 4 +++- claim.capnp | 4 ++++ projects.capnp | 16 ++++++++++++++++ resources.capnp | 7 ++++++- terminalMain.capnp | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 terminalMain.capnp diff --git a/auth.capnp b/auth.capnp index ebdecb5..a31e8fa 100644 --- a/auth.capnp +++ b/auth.capnp @@ -4,7 +4,6 @@ using CSharp = import "programming_language/csharp.capnp"; $CSharp.namespace("FabAccessAPI.Schema"); using import "utils.capnp".L10NString; -using import "main.capnp".Session; struct AuthSupported { mechs @0 :List(Mechanism); @@ -118,6 +117,9 @@ struct Response(Successful) { } interface Authentication(Successful) { + mechanisms @3 () -> ( mechanisms :List(Mechanism) ); + # Return the list of available mechanisms + step @0 ( data :Data ) -> Response(Successful); # Respond to a challenge with more data. A client MUST NOT call this after having received an # "successful" response. diff --git a/claim.capnp b/claim.capnp index 00d3622..0ee66b4 100644 --- a/claim.capnp +++ b/claim.capnp @@ -13,12 +13,16 @@ using import "utils.capnp".Map; using import "utils.capnp".SturdyRef; using import "projects.capnp".Project; using import "traits.capnp".Hint; +using import "auth.capnp".Authentication; interface Claimable { claim @0 ( project :Project ) -> Fallible(Claim, ClaimError); # Returns NULL if the resource is *currently* not claimable. # Disown the returned claim capability to unclaim it. + claimSubstituteUser @1 ( project :Project ) -> Fallible(Authentication(Claim), ClaimError); + # If the client calling this call is not allowed to make a SU claim the returned authentication is a nullptr + struct ClaimError { locked @0 :Text; } diff --git a/projects.capnp b/projects.capnp index 702b41b..d9f4f3c 100644 --- a/projects.capnp +++ b/projects.capnp @@ -3,6 +3,22 @@ using CSharp = import "programming_language/csharp.capnp"; $CSharp.namespace("FabAccessAPI.Schema"); +using import "auth.capnp".Authentication; +using import "utils.capnp".Fallible; +using import "claim.capnp".Claim; + interface Project { } + +interface TerminalProjects { + getUserProjects @0 () -> ( authentication :Authentication(List(Project)) ); + + addClaimToProject @1 ( claim :Claim, project :Project ) -> Fallible(AddOk, AddError); + struct AddOk { + + } + struct AddError { + + } +} diff --git a/resources.capnp b/resources.capnp index 02245e4..cb6e9e1 100644 --- a/resources.capnp +++ b/resources.capnp @@ -8,6 +8,8 @@ using import "resource.capnp".RestoredResource; using import "claim.capnp".Claim; using import "utils.capnp".SturdyRef; using import "utils.capnp".Fallible; +using import "projects.capnp".Project; +using import "auth.capnp".Authentication; interface Resources { restore @0 () -> ( resources :List(RestoredResource) ); @@ -25,7 +27,10 @@ interface Resources { getByUrl @4 ( url :Text ) -> ( resource :Resource ); # Returns a NULL capability if the resource doesn't exist or a user doesn't have read permission for that resource. - acceptToken @5 ( token :SturdyRef ) -> Fallible(Claim, AcceptTokenError); + acceptToken @5 ( token :SturdyRef, project :Project ) -> Fallible(Claim, AcceptTokenError); + + acceptTokenSubstituteUser @7 ( token :SturdyRef, project :Project ) + -> Fallible(Authentication(Claim), AcceptTokenError); setAlias @6 ( original_resource_id :Text ) -> ( alias_id :Text ); # Replace any set alias for the given resource id with a newly generated diff --git a/terminalMain.capnp b/terminalMain.capnp new file mode 100644 index 0000000..f01d1cd --- /dev/null +++ b/terminalMain.capnp @@ -0,0 +1,38 @@ +@0xc71ee8fdf17f8372; + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +using import "auth.capnp".Authentication; +using import "resources.capnp".Resources; +using import "projects.capnp".TerminalProjects; + +interface TerminalBootstrap +{ + getAPIVersion @0 () -> Version; + # Returns the API version implemented by the server. As a client, you can compare this version with the local currentVersion. + + getServerRelease @1 () -> ( name :Text, release :Text ); + # Returns the server implementation name and version/build number Designed only for human-facing + # debugging output so should be informative over machine-readable. + # Example: ("bffhd", "0.3.1-f397e1e [rustc 1.57.0 (f1edd0429 2021-11-29)]") + + getServerInfo @2 () -> ( spacename :Text, instanceurl :Text ); + # Returns information about the server, which can be used to resolve MDNS to DNS and display the server name to the user. + + mechanisms @3 () -> AuthSupported; + # Get a list of Mechanisms this server allows in this context. + + createSession @4 ( mechanism :Text, upgrade :Text ) -> ( authentication :Authentication(TerminalSession) ); +} + +struct TerminalSession +{ + resources @0 :Resources; + projects @1 :TerminalProjects; + users @2 :TerminalUsers; +} + +interface TerminalUsers { + +}