harmos_runtime/operations/authorization.rs
1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12/* === Re-Exports === */
13
14pub use harmos_domain::inventory::contracts::Required;
15
16/* === Imports === */
17
18// Standard Library Imports
19
20// Third Party Imports
21
22// Local Imports
23use super::{CallContext, Contract, Definition, OperationGeneration};
24use crate::{Identifier, Result};
25
26/* === Constants === */
27
28/* === Macros === */
29
30/* === Type Aliases === */
31
32/* === Structs === */
33
34// Borrow Original Live Provider Metadata; This Is Not Another Catalog.
35pub struct Provider<'a> {
36 pub owner: &'a Identifier,
37 pub plugin: bool,
38 pub generation: OperationGeneration,
39 pub definition: &'a Definition,
40 pub contract: &'a Contract,
41}
42
43/* === Enums === */
44
45#[derive(Clone, Debug)]
46pub enum Authorization {
47 Full(Contract),
48 Restricted(Required),
49}
50
51/* === Traits === */
52
53// Synchronous, Bounded And Nonblocking. No Request Probing Or Role Inference.
54// None Denies Access; Both Selections Must Match The Original Contract.
55pub trait Authorizer: Send + Sync + 'static {
56 fn authorize(&self, context: &CallContext, provider: Provider<'_>) -> Result<Option<Authorization>>;
57}
58
59/* === Implementations === */
60
61/* === Public Functions === */
62
63/* === Private Functions === */
64
65/* === Tests === */