lsegal/yard — pull request #675 by oldfartdeveloper (2013-05-13 06:50:19+00:00)
Title: Added basic authentication

This pull request adds `Rack::Basic::Auth` authentication to **YARD** if you pass either of the following command line arguments:

--username
--password

If neither of the above are specified, then the server is launched without requiring authentication.

I realize that `Rack::Basic::Auth` is not the most sophisticated authentication system out there, in that it does no maintenance of the user's browser session. Hence, after closing my browser after authenticating, my next browse bypasses the login page and goes directly to the doc serving. Also, when I close the server and restart it, my existing browser entry is able to continue accessing the documents without having to go through the login page.

For me, and I think most people who want authentication, this is adequate. I just want to keep strangers from looking at the docs (and the source code).

I did add another optional command line argument:

--realm

so that the login dialog could show a custom name for the Yard document server; some larger organizations might find this useful. If not specified, then the server is identified as whatever's in `YARD::CLI::Server::DEFAULT_REALM` (presently 'Yard Documentation Server').

You will see that the only code file modified is `lib/yard/cli/server.rb` and its associated spec file.

I've tried to think of everything:

1. `README.md` is updated, both in the introduction and the detailed section below.
1. Added command line parameters are documented when `--help` is invoked
1. Added `rspecs` for my code. The remaining tests run without error.

I am using this code without "hiccups" in our continuous integration server running Jenkins.

So, that being said, I think it's time for me to submit this; please give me feedback on anything you'd like corrected or changed. If it's good enough as-is, then please merge it.

Thanks in advance.