Why? #
The existing tranquil-scopes handles parsing scopes effectively, but it doesn't support serialization. This makes it difficult to reliably compare scope strings, or to create strong types for them. Adding a serializer will allow us to parse and compare scopes reliably.
Goals #
- Unification: Right now we're using
format!("repo:{}?action={}", ...)in a couple of places, and we haveStringtyped scopes all across the OAuth system. The serializer would unify the implementation so we only have to manage scopes in one crate. - Determinism:
actionsis aHashSetso it can emit actions in a fixed order to prevent thescopevalue on a JWT from changing between checks. With a serializer, we can pin down a canonical ordering and format that guarantees this is never an issue.
If we do it right, this eliminates the typed representation of scopes is cheaper than Strings, and there are no footguns caused by stronger typing.