Public | Automated Build

Last pushed: 3 years ago
Short Description
Short description is empty for this repo.
Full Description

Simple basic authentication service

This service as-is should not be used in production and is made available as a reference to building an authentication proxy to secure a private docker registry.

NodeJS makes creating a Basic authentication service a breeze. All we need to do is to create a file containing our credentials using the htpasswd utility:

ubuntu@trusty-64:/basic-auth# apt-get install apache2-utils
ubuntu@trusty-64:/basic-auth# htpasswd -b -c super_secrets testuser testpassword

The code required to make this app work is tiny thanks to the http-auth module and can be found in

Now run and test the app:

ubuntu@trusty-64:/basic-auth# npm install http-auth
ubuntu@trusty-64:/basic-auth# node server.js &
ubuntu@trusty-64:/basic-auth# curl localhost:8000
401 Unauthorized
ubuntu@trusty-64:/basic-auth# curl -u testuser:testpassword localhost:8000
User authenticated successfully

Running the docker container:

ubuntu@trusty-64:/basic-auth# docker build -t simple-auth .
ubuntu@trusty-64:/basic-auth# docker run -p simple-auth
Docker Pull Command
Source Repository