/// Checks whether the given principal has access to the given method.
Checks whether the given principal has access to the given method.
Checks whether the given principal has access to the given method .
pub fn is_authorized(method_name: &str, principal_id: PrincipalId) -> bool {
    let authz = AUTHZ_MAP.read().unwrap();
    match authz.get(method_name) {
        // Test whether the (string representation) of the principal is registered
        // as having access to this method.
        Some(method_authz) => {
            let authorized = method_authz.principal_ids.contains(&principal_id.to_vec());
            if !authorized {
                println!(
                    "Principal: {} not authorized to access method: {}",
                    principal_id, method_name
                );
            }
            authorized
        }
        // If a method is not in access control, then by default it is authorized
        None => true,
    }
}
pub fn is_authorized ( method_name : & str , principal_id : PrincipalId ) -> bool { let authz = AUTHZ_MAP . read ( ) . unwrap ( ) ; match authz . get ( method_name ) { // Test whether the (string representation) of the principal is registered // as having access to this method. Some ( method_authz ) => { let authorized = method_authz . principal_ids . contains ( & principal_id . to_vec ( ) ) ; if ! authorized { println ! ( " " principal_id method_name ) ; } authorized } // If a method is not in access control, then by default it is authorized None => true , } }
Checks whether the given principal has access to the given method.
Checks whether the given principal has access to the given method .
method_name
&str
principal_id
PrincipalId