Add some changes to support mongodb as backed for security