Added rest auth and fixed security bugs