@@ -681,6 +681,58 @@ impl AuthorizedResource for Inventory {
681681 }
682682}
683683
684+ /// Synthetic resource for to model accessing trust quorum configurations for a
685+ /// given rack
686+ #[ derive( Clone , Debug , Eq , PartialEq ) ]
687+ pub struct TrustQuorumConfig ( Rack ) ;
688+
689+ impl TrustQuorumConfig {
690+ pub fn new ( rack : Rack ) -> TrustQuorumConfig {
691+ TrustQuorumConfig ( rack)
692+ }
693+
694+ pub fn rack ( & self ) -> & Rack {
695+ & self . 0
696+ }
697+ }
698+
699+ impl oso:: PolarClass for TrustQuorumConfig {
700+ fn get_polar_class_builder ( ) -> oso:: ClassBuilder < Self > {
701+ oso:: Class :: builder ( )
702+ . with_equality_check ( )
703+ . add_attribute_getter ( "rack" , |config : & TrustQuorumConfig | {
704+ config. 0 . clone ( )
705+ } )
706+ }
707+ }
708+
709+ impl AuthorizedResource for TrustQuorumConfig {
710+ fn load_roles < ' fut > (
711+ & ' fut self ,
712+ opctx : & ' fut OpContext ,
713+ authn : & ' fut authn:: Context ,
714+ roleset : & ' fut mut RoleSet ,
715+ ) -> futures:: future:: BoxFuture < ' fut , Result < ( ) , Error > > {
716+ // There are no roles on this resource, but we still need to load the
717+ // Rack-related roles.
718+ self . rack ( ) . load_roles ( opctx, authn, roleset)
719+ }
720+
721+ fn on_unauthorized (
722+ & self ,
723+ _: & Authz ,
724+ error : Error ,
725+ _: AnyActor ,
726+ _: Action ,
727+ ) -> Error {
728+ error
729+ }
730+
731+ fn polar_class ( & self ) -> oso:: Class {
732+ Self :: get_polar_class ( )
733+ }
734+ }
735+
684736/// Synthetic resource describing the list of Certificates associated with a
685737/// Silo
686738#[ derive( Clone , Debug , Eq , PartialEq ) ]
0 commit comments