mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-24 15:47:57 +01:00
Schema specialization
This commit is contained in:
parent
a4ce1bd28f
commit
73134d2fe9
@ -43,26 +43,6 @@ interface Diflouroborane {
|
|||||||
# TODO Capability transfer system, required for machine takeover, session resumption.
|
# TODO Capability transfer system, required for machine takeover, session resumption.
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Maybe(Value) {
|
|
||||||
# An optional value, i.e. a value which is either explicity present or explicity not present.
|
|
||||||
# Similar to `Maybe` in Haskell and `Option` in OCaml or Rust
|
|
||||||
union {
|
|
||||||
some @0 :Value;
|
|
||||||
none @1 :Void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Either(Left, Right) {
|
|
||||||
# Sum type over two values. A more general type than Rust's `Result` type.
|
|
||||||
# If this type is used to convey the result of a possibly failed computation the `Left` type
|
|
||||||
# shall be used for the error while the `Right` type shall be the value. (Mnemonic: 'right' also
|
|
||||||
# means 'correct')
|
|
||||||
union {
|
|
||||||
left @0 :Left;
|
|
||||||
right @1 :Right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct UUID {
|
struct UUID {
|
||||||
lsg @0 :UInt64; # least significant
|
lsg @0 :UInt64; # least significant
|
||||||
msg @1 :UInt64; # most significant
|
msg @1 :UInt64; # most significant
|
||||||
@ -106,22 +86,36 @@ interface Authentication {
|
|||||||
availableMechanisms @0 () -> ( mechanisms :List(Text) );
|
availableMechanisms @0 () -> ( mechanisms :List(Text) );
|
||||||
|
|
||||||
# Start authentication using the given mechanism and optional initial data
|
# Start authentication using the given mechanism and optional initial data
|
||||||
initializeAuthentication @1 ( mechanism :Text, initialData :Maybe(Data) )
|
initializeAuthentication @1 ( mechanism :Text, initialData :MaybeData )
|
||||||
-> (response :Either (Challenge, Outcome) );
|
-> (response :StepResult );
|
||||||
|
|
||||||
getAuthzid @2 () -> ( authzid :Text );
|
getAuthzid @2 () -> ( authzid :Text );
|
||||||
|
|
||||||
|
struct StepResult {
|
||||||
|
union {
|
||||||
|
challenge @0 :Challenge;
|
||||||
|
outcome @1 :Outcome;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MaybeData {
|
||||||
|
union {
|
||||||
|
some @0 :Data;
|
||||||
|
none @1 :Void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface Challenge {
|
interface Challenge {
|
||||||
# Access the challenge data
|
# Access the challenge data
|
||||||
read @0 () -> ( data :Maybe(Data) );
|
read @0 () -> ( data :MaybeData );
|
||||||
|
|
||||||
respond @1 ( data :Maybe(Data) )
|
respond @1 ( data :MaybeData )
|
||||||
-> ( response :Either (Challenge, Outcome) );
|
-> ( response :StepResult );
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Outcome {
|
interface Outcome {
|
||||||
# Outcomes may contain additional data
|
# Outcomes may contain additional data
|
||||||
read @0 () -> ( data :Maybe(Data) );
|
read @0 () -> ( data :MaybeData );
|
||||||
# The actual outcome.
|
# The actual outcome.
|
||||||
value @1 () -> ( granted :Bool );
|
value @1 () -> ( granted :Bool );
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ impl api::authentication::Server for Authentication {
|
|||||||
let mechanism = pry!(params.get_mechanism());
|
let mechanism = pry!(params.get_mechanism());
|
||||||
match mechanism {
|
match mechanism {
|
||||||
"PLAIN" => {
|
"PLAIN" => {
|
||||||
use api::maybe::Which;
|
use api::authentication::maybe_data::Which;
|
||||||
|
|
||||||
let data = pry!(params.get_initial_data());
|
let data = pry!(params.get_initial_data());
|
||||||
if let Ok(Which::Some(data)) = data.which() {
|
if let Ok(Which::Some(data)) = data.which() {
|
||||||
@ -165,8 +165,8 @@ impl api::authentication::Server for Authentication {
|
|||||||
results
|
results
|
||||||
.get()
|
.get()
|
||||||
.init_response()
|
.init_response()
|
||||||
.set_right(api::authentication::outcome::ToClient::new(outcome)
|
.set_outcome(api::authentication::outcome::ToClient::new(outcome)
|
||||||
.into_client::<::capnp_rpc::Server>()).unwrap();
|
.into_client::<::capnp_rpc::Server>());
|
||||||
}
|
}
|
||||||
::capnp::capability::Promise::ok(())
|
::capnp::capability::Promise::ok(())
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user