From f2783c7f6e8bfcc8c4b158865f2663324b6afce3 Mon Sep 17 00:00:00 2001 From: TheJoKlLa Date: Mon, 1 Feb 2021 23:23:12 +0100 Subject: [PATCH] New Structur --- api.capnp | 168 ------------------ auth.capnp => authenticationsystem.capnp | 34 +--- connection.capnp | 56 +++--- federationsystem.capnp | 12 ++ general.capnp | 28 +++ interactionsystem.capnp | 12 ++ machine.capnp | 96 ++++++++++ machinesystem.capnp | 18 ++ permissionsystem.capnp | 12 ++ .../csharp.capnp | 0 rust.capnp => programming_language/rust.capnp | 0 space.capnp | 16 ++ user.capnp | 43 +++++ usersystem.capnp | 12 ++ 14 files changed, 276 insertions(+), 231 deletions(-) delete mode 100644 api.capnp rename auth.capnp => authenticationsystem.capnp (78%) create mode 100644 federationsystem.capnp create mode 100644 general.capnp create mode 100644 interactionsystem.capnp create mode 100644 machine.capnp create mode 100644 machinesystem.capnp create mode 100644 permissionsystem.capnp rename csharp.capnp => programming_language/csharp.capnp (100%) rename rust.capnp => programming_language/rust.capnp (100%) create mode 100644 space.capnp create mode 100644 user.capnp create mode 100644 usersystem.capnp diff --git a/api.capnp b/api.capnp deleted file mode 100644 index 5d0c0ff..0000000 --- a/api.capnp +++ /dev/null @@ -1,168 +0,0 @@ -# Copyright © 2020 Gregor Reitzenstein -# Licensed under the MIT License: -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -@0xfd92ce9be2369b8e; - -using Rust = import "rust.capnp"; -$Rust.parentModule("schema"); - -using CSharp = import "csharp.capnp"; -$CSharp.namespace("FabAccessAPI.Schema"); - -interface Machines { - # The interface to the machines subsystem - - listMachines @0 () -> ( machines :List(Machine) ); - # List all machines that BFFH knows about the user has been granted at least read access on - - getMachine @1 ( uid :Text ) -> ( machine :Machine, dummy :UInt8 = 0 ); - # Access a particular machine by known UUID. This may fail for two reasons: The user - # has not been granted access to know the machine exists or the machine does in fact - # not exist. In both cases the `machine` result will be a NULL-pointer -} - -interface Permissions { -} - -struct UUID { - # UUID type used to identify machines. - # Since the exact value has no meaning the encoding rules are not too relevant, but it is - # paramount that you are consistent when encoding and decoding this type. - # - # Consider using this algorithm for assembling the 128-bit integer: - # (assuming ISO9899:2018 shifting & casting rules) - # uint128_t num = (uuid1 << 64) + uuid0; - # And then respectively this code for deconstructing it: - # uint64_t uuid0 = (uint64_t) num; - # uint64_t uuid1 = (uint64_t) (num >> 64); - - uuid0 @0 :UInt64; - uuid1 @1 :UInt64; -} - -enum State { - free @0; - inUse @1; - toCheck @2; - blocked @3; - disabled @4; - reserved @5; -} - -struct Machine { - # A machine struct. This represents a machine as BFFH thinks about it which may mean - # several machines or just part of a machine in the real world. - # By itself this struct is completely useless since it contains only the information - # that the machine exists the user is allowed to know about that fact. For all further - # information the user has to call the contained capabilities which depending on the - # access level may not be set. For example an admin will have every capability here - # set but a simple user may only have `read` and `write` set while some users may not - # even have `read` set and are unable to even see if the machine is currently in use. - struct MInfo { - state @0 :State; - name @1 :Text; - description @2 :Text; - - responsible @3 :User; # This field may be NULL if nobody is using the machine - } - - struct PropertyMap { - properties @0 :List(Property); - struct Property { - key @0 :Text; - value @1 :Text; - } - } - - read @0 :Read; - interface Read $CSharp.name("ReadInterface") { - info @0 () -> ( minfo :MInfo, dummy :UInt8 = 0 ); - # Check the state of a machine. - - getProperties @1 () -> (properties :PropertyMap, dummy :UInt8 = 0 ); - # Read Machine Properties - } - - write @1 :Write; - interface Write $CSharp.name("WriteInterface") { - use @0 () -> ( ret :GiveBack ); - # Try to use a machine. Returns a NULL-ptr if the user does not have the required - # permissions to use this machine - interface GiveBack { - # If you are using a machine you have the capablity to give it back - - ret @0 () -> (); - # Calling this function will return the machine and set its state as appropiate - } - - reserve @1 () -> ( ret :GiveBack ); - # Try to reserve a machine. returns a NULL-ptr if the user does not have the required - # permissions to reserve this machine - - setProperties @2 (properties :PropertyMap) -> (); - # Write all Machine Properties - - setProperty @3 (property :PropertyMap.Property) -> (); - # Write ONE Machine Property identified by it's key - - sendRawData @4 (data :Data) -> (); - # send a blob of arbitrary data to the machine - } - - - manage @2 :Manage; - # After a machine has been used by an user with low enough permissions it's - # in the 'toCheck' state. This call then allows more priviledged users to - # "check" the machine and move it to the `free` state. - interface Manage $CSharp.name("ManageInterface") { - ok @0 () -> (); # The machine was clean & ok. -> free - notOk @1 () -> (); - # The machine was left in an unacceptable state. - # Most likely marks the machine as `blocked` and somehow informs the previous user. - } - - admin @3 :Admin; - # Administrative overrides. This is only not-NULL if you have the required permissions - # to use it. - interface Admin $CSharp.name("AdminInterface") { - forceSetState @0 ( state :State ) -> (); # Forcefully set a machine state - forceSetUser @1 ( user :Text ) -> (); # Set the given user as current responsible - } -} - -struct User { - struct UserInformation { - id @0 :Text; - name @1 :Text; - originatingWorkshop @2 :Text; - } - - read @0 :Read; - interface Read $CSharp.name("ReadInterface") { - info @0 () -> ( uinfo :UserInformation ); - } - - write @1 :Write; - interface Write $CSharp.name("WriteInterface") { - setName @0 ( name :Text ) -> (); - } -} diff --git a/auth.capnp b/authenticationsystem.capnp similarity index 78% rename from auth.capnp rename to authenticationsystem.capnp index bc65d54..5aa111a 100644 --- a/auth.capnp +++ b/authenticationsystem.capnp @@ -1,36 +1,14 @@ -# Copyright © 2020 Gregor Reitzenstein -# Licensed under the MIT License: -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +@0xb9cffd29ac983e9f; - -@0x81ac94a588025602; - -using Rust = import "rust.capnp"; +using Rust = import "programming_language/rust.capnp"; $Rust.parentModule("schema"); -using CSharp = import "csharp.capnp"; +using CSharp = import "programming_language/csharp.capnp"; $CSharp.namespace("FabAccessAPI.Schema"); -using Api = import "api.capnp"; +using User = import "user.capnp".User; -interface Authentication { +interface AuthenticationSystem { mechanisms @0 () -> ( mechs :List(Text) ); # Get the list of mechanisms supported by the server @@ -53,7 +31,7 @@ interface Authentication { # A server receiving an abort after sending an outcome but before # receiving any other message MUST respect the abort. - whoami @4 () -> ( you :Api.User, dummy :UInt8 = 0 ); + whoami @4 () -> ( you :User, dummy :UInt8 = 0 ); # Returns NULL if not authenticated and an User object if authenticated. } diff --git a/connection.capnp b/connection.capnp index 6e90078..84bc94c 100644 --- a/connection.capnp +++ b/connection.capnp @@ -1,43 +1,29 @@ -# Copyright © 2020 Gregor Reitzenstein -# Licensed under the MIT License: -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +@0xbf017710be5a54ff; - -@0x9e1c146a27dcc635; - -using Rust = import "rust.capnp"; +using Rust = import "programming_language/rust.capnp"; $Rust.parentModule("schema"); -using CSharp = import "csharp.capnp"; +using CSharp = import "programming_language/csharp.capnp"; $CSharp.namespace("FabAccessAPI.Schema"); -using Auth = import "auth.capnp"; -using Api = import "api.capnp"; +using AuthenticationSystem = import "authenticationsystem.capnp".AuthenticationSystem; +using MachineSystem = import "machinesystem.capnp".MachineSystem; +using UserSystem = import "usersystem.capnp".UserSystem; +using PermissionSystem = import "permissionsystem.capnp".PermissionSystem; +using InteractionSystem = import "interactionsystem.capnp".InteractionSystem; +using FederationSystem = import "federationsystem.capnp".FederationSystem; -interface Bootstrap { - auth @0 () -> ( auth :Auth.Authentication ); +interface Bootstrap +{ + authenticationSystem @0 () -> ( authenticationSystem : AuthenticationSystem ); - permissions @1 () -> ( permissions :Api.Permissions ); - # Permission subsystem to manage permissions and systems underlying the authorization process + machineSystem @1 () -> ( machineSystem : MachineSystem ); + + userSystem @2 () -> ( userSystem : UserSystem ); - machines @2 () -> ( machines :Api.Machines ); - # Diflouroborane stores machine¹ information in an opaque internal database. This interface is - # the only stable process of modifying that information -} + permissionSystem @3 () -> ( permissionSystem : PermissionSystem ); + + interactionSystem @4 () -> ( interactionSystem : InteractionSystem ); + + federationSystem @5 () -> ( federationSystem : FederationSystem ); +} \ No newline at end of file diff --git a/federationsystem.capnp b/federationsystem.capnp new file mode 100644 index 0000000..e587816 --- /dev/null +++ b/federationsystem.capnp @@ -0,0 +1,12 @@ +@0xb3359bdbf762b7ab; + +using Rust = import "programming_language/rust.capnp"; +$Rust.parentModule("schema"); + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +interface FederationSystem +{ + +} \ No newline at end of file diff --git a/general.capnp b/general.capnp new file mode 100644 index 0000000..8a0d470 --- /dev/null +++ b/general.capnp @@ -0,0 +1,28 @@ +@0xff5b4a767d98592a; + +using Rust = import "programming_language/rust.capnp"; +$Rust.parentModule("schema"); + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +struct UUID { + # UUID type used to identify machines. + # Since the exact value has no meaning the encoding rules are not too relevant, but it is + # paramount that you are consistent when encoding and decoding this type. + # + # Consider using this algorithm for assembling the 128-bit integer: + # (assuming ISO9899:2018 shifting & casting rules) + # uint128_t num = (uuid1 << 64) + uuid0; + # And then respectively this code for deconstructing it: + # uint64_t uuid0 = (uint64_t) num; + # uint64_t uuid1 = (uint64_t) (num >> 64); + + uuid0 @0 :UInt64; + uuid1 @1 :UInt64; +} + +struct KeyValuePair { + key @0 :Text; + value @1 :Text; +} \ No newline at end of file diff --git a/interactionsystem.capnp b/interactionsystem.capnp new file mode 100644 index 0000000..140327b --- /dev/null +++ b/interactionsystem.capnp @@ -0,0 +1,12 @@ +@0xf997d4fafd488ee6; + +using Rust = import "programming_language/rust.capnp"; +$Rust.parentModule("schema"); + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +interface InteractionSystem +{ + +} \ No newline at end of file diff --git a/machine.capnp b/machine.capnp new file mode 100644 index 0000000..b9b5b39 --- /dev/null +++ b/machine.capnp @@ -0,0 +1,96 @@ +@0x8c2f829df1930cd5; + +using Rust = import "programming_language/rust.capnp"; +$Rust.parentModule("schema"); + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +using General = import "general.capnp"; +using User = import "user.capnp".User; +using Space = import "space.capnp".Space; + +struct Machine { + enum MachineState { + free @0; + inUse @1; + toCheck @2; + blocked @3; + disabled @4; + reserved @5; + } + + struct MachineInfo { + id @0 :General.UUID; + space @1 :Space; + name @2 :Text; + info @3 :Text; + + state @4 :MachineState; + + user @5 :User; + transferuser @6 :User; + + manager @7:User; + } + + struct Reservation { + user @0 :User; + start @1: UInt64; + end @2: UInt64; + } + + info @0 :Info; + interface Info $CSharp.name("InfoInterface") { + getMachineInfo @0 () -> ( machineInfo :MachineInfo); + + getPropertyList @1 () -> (propertyList :List(General.KeyValuePair)); + + getReservationList @2 () -> (reservationList :List(Reservation)); + } + + use @1 :Use; + interface Use $CSharp.name("UseInterface") { + use @0 () -> (); + + reserve @1 () -> (); + reserveto @2 (start :UInt64, end :UInt64); + } + + inuse @2 :InUse; + interface InUse $CSharp.name("InUseInterface") { + giveBack @0 (); + + transfer @1 (user: User); + + sendRawData @2 (data :Data); + } + + transfer @3 :Transfer; + interface Transfer $CSharp.name("TransferInterface") { + accept @0 (); + reject @1 (); + } + + check @4 :Check; + interface Check $CSharp.name("CheckInterface") { + check @0 (); + reject @1 (); + } + + manage @5 :Manage; + interface Manage $CSharp.name("ManageInterface") { + setProperty @0 (property :General.KeyValuePair); + removeProperty @1(property :General.KeyValuePair); + } + + admin @6 :Admin; + interface Admin $CSharp.name("AdminInterface") { + forceSetState @0 ( state :MachineState ); + forceSetUser @1 ( user :User ); + + getAdminPropertyList @2 () -> (propertyList :List(General.KeyValuePair)); + setAdminProperty @3 (property :General.KeyValuePair); + removeAdminProperty @4(property :General.KeyValuePair); + } +} \ No newline at end of file diff --git a/machinesystem.capnp b/machinesystem.capnp new file mode 100644 index 0000000..66b4afb --- /dev/null +++ b/machinesystem.capnp @@ -0,0 +1,18 @@ +@0xe89d197dcef9c49b; + +using Rust = import "programming_language/rust.capnp"; +$Rust.parentModule("schema"); + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +using General = import "general.capnp"; +using Machine = import "machine.capnp".Machine; +using Space = import "space.capnp".Space; + +interface MachineSystem +{ + listMachines @0 () -> ( machines :List(Machine) ); + + getMachine @1 ( uuid :General.UUID ) -> ( machine :Machine); +} \ No newline at end of file diff --git a/permissionsystem.capnp b/permissionsystem.capnp new file mode 100644 index 0000000..97ea7a6 --- /dev/null +++ b/permissionsystem.capnp @@ -0,0 +1,12 @@ +@0xd0568a21cf11488e; + +using Rust = import "programming_language/rust.capnp"; +$Rust.parentModule("schema"); + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +interface PermissionSystem +{ + +} \ No newline at end of file diff --git a/csharp.capnp b/programming_language/csharp.capnp similarity index 100% rename from csharp.capnp rename to programming_language/csharp.capnp diff --git a/rust.capnp b/programming_language/rust.capnp similarity index 100% rename from rust.capnp rename to programming_language/rust.capnp diff --git a/space.capnp b/space.capnp new file mode 100644 index 0000000..6dd0aab --- /dev/null +++ b/space.capnp @@ -0,0 +1,16 @@ +@0xbacaff4190ac7d80; + +using Rust = import "programming_language/rust.capnp"; +$Rust.parentModule("schema"); + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +using General = import "general.capnp"; + +struct Space +{ + id @0 :General.UUID; + name @1 :Text; + info @2 :Text; +} \ No newline at end of file diff --git a/user.capnp b/user.capnp new file mode 100644 index 0000000..fed3d25 --- /dev/null +++ b/user.capnp @@ -0,0 +1,43 @@ +@0xc7941adf5db6bbf0; + +using Rust = import "programming_language/rust.capnp"; +$Rust.parentModule("schema"); + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +using General = import "general.capnp"; +using Space = import "space.capnp".Space; + +struct User +{ + struct UserInfo + { + id @0 :General.UUID; + username @1 :Text; + space @2 :Space; + } + + struct UserInfoExtended + { + id @0 :General.UUID; + firstname @1 :Text; + lastname @2 :Text; + address @3 :Address; + + struct Address + { # TODO POST*CODE + text @0 :Text; + } + } + + info @0 :Info; + interface Info $CSharp.name("InfoInterface") { + getUserInfo @0 () -> ( userInfo :UserInfo ); + } + + manage @1 :Manage; + interface Manage $CSharp.name("ManageInterface") { + getUserInfoExtended @0 () -> ( userInfoExtended :UserInfoExtended ); + } +} \ No newline at end of file diff --git a/usersystem.capnp b/usersystem.capnp new file mode 100644 index 0000000..3516a21 --- /dev/null +++ b/usersystem.capnp @@ -0,0 +1,12 @@ +@0x9a05e95f65f2edda; + +using Rust = import "programming_language/rust.capnp"; +$Rust.parentModule("schema"); + +using CSharp = import "programming_language/csharp.capnp"; +$CSharp.namespace("FabAccessAPI.Schema"); + +interface UserSystem +{ + +} \ No newline at end of file