Implement permissions system

Add control over who can query what, and who is immune from query.