add basic authentication decorator

(+ a bit of refactor)
Merge pull request #3967 from dimagi/basic-auth

add basic authentication and make it the default for secure submissions