Progress.

Authentication, permissions and restrictions should work now.