3 releases

0.0.2 Apr 6, 2023
0.0.1 Jul 13, 2021
0.0.0 Apr 14, 2021

#427 in Rust patterns

Download history 37076/week @ 2024-01-03 39075/week @ 2024-01-10 45749/week @ 2024-01-17 43086/week @ 2024-01-24 45494/week @ 2024-01-31 41172/week @ 2024-02-07 42194/week @ 2024-02-14 51974/week @ 2024-02-21 50689/week @ 2024-02-28 50979/week @ 2024-03-06 42395/week @ 2024-03-13 54401/week @ 2024-03-20 48884/week @ 2024-03-27 48115/week @ 2024-04-03 42769/week @ 2024-04-10 42626/week @ 2024-04-17

192,276 downloads per month
Used in 204 crates (4 directly)

Apache-2.0…

15KB

ambient-authority

Ambient Authority

Github Actions CI Status crates.io page docs.rs docs

In capability-based security contexts, ambient authority means anything a program can do that interacts with the outside world that isn't represented by a handle.

This crate defines an empty function, ambient_authority, which returns a value of type AmbientAuthority. This is an empty type used in function signatures to declare that they use ambient authority. When an API uses AmbientAuthority in all functions that use ambient authority, one can quickly locate all the calls to such functions by scanning for calls to ambient_authority.

To use the AmbientAuthroity type in an API:

  • Add an AmbientAuthority argument at the end of the argument list of any function that uses ambient authroity, and add a # Ambient Authority section in the documentation comments for such functions explaining their use of ambient authority.

  • Re-export the ambient_authority function and AmbientAuthority type from this crate, so that users can easily use the same version.

  • Ensure that all other pub functions avoid using ambient authority, including mutable static state such as static Atomic, Cell, RefCell, Mutex, RwLock, or similar state, including once_cell or lazy_static state with initialization that uses ambient authority.

For example, see the cap-std crate's API, which follows these guidelines.

One of the cool things about capability-oriented APIs is that programs don't need to be pure to take advantage of them. That said, for programs which do which to aim for purity, this repository has a clippy configuration which can help. To use it:

  • Manually ensure that all immediate dependencies follow the above convention.

  • Copy the clippy.toml file into the top level source directory, add #![deny(clippy::disallowed_methods)] to the root module (main.rs or lib.rs), and run cargo clippy or equivalent.

No runtime deps