Authenticator (from /home/chedong/.local/share/rdoc)
| Use Case | Command | Description |
|---|---|---|
| 🔐 Create a BasicAuth instance | WEBrick::HTTPAuth::BasicAuth.new config | Create a new basic authenticator with a configuration hash |
| 🔑 Set user password | htpasswd.set_passwd realm, username, password | Set or update a password for a user in the given realm |
| 💾 Write password file | htpasswd.flush | Write the password database to disk |
| 👤 Authenticate request | basic_auth.authenticate request, response | Authenticate a request (returns user or fails) |
| ⚠️ Send challenge | basic_auth.challenge request, response | Send a 401 Unauthorized challenge to the client |
| 📄 Get logger | basic_auth.logger | Return the logger object (attr_reader) |
| 🌐 Get realm | basic_auth.realm | Return the authentication realm (attr_reader) |
| 🗄️ Get user database | basic_auth.userdb | Return the user database object (attr_reader) |
Basic Authentication for WEBrick. Use this class to add basic authentication to a WEBrick servlet.
Here is an example of how to set up a BasicAuth:
config = { :Realm => 'BasicAuth example realm' }
htpasswd = WEBrick::HTTPAuth::Htpasswd.new 'my_password_file', password_hash: :bcrypt
htpasswd.set_passwd config[:Realm], 'username', 'password'
htpasswd.flush
config[:UserDB] = htpasswd
basic_auth = WEBrick::HTTPAuth::BasicAuth.new config
make_passwdnewauthenticatechallengeloggerrealmuserdblogger (attr_reader)realm (attr_reader)userdb (attr_reader)Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-31 08:23 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format