Piotr Kula's answer seems to be on the right track but is outdated for Raspberry stretch.
There are updated instructions for uv4l on Raspberry stretch at
# switch to superuser mode
# add the repository key for uv4l
curl http://www.linux-projects.org/listing/uv4l_repo/lpkey.asc | sudo apt-key add
To setup a username and password with motion, you need to edit motion configuration file.
Type sudo nano /etc/motion/motion/conf
Add in a new line stream_auth_method 1
Add in a new line stream_authentication username:password
Ctrl + X
Press Y, Press Enter