That would work, but I think this in a snippet (or plugin) might be a more generic solution:
$ctx = $modx->context->get('key')
if (! $modx->user->hasSessionContext( array($ctx));
$modx->sendUnauthorizedPage();
I’m not confident on this until OpenGeek settles how it should work, but I’m fairly sure that I’ve tested it and found it to toss the user out if he or she is not logged in in the current context.