{
    "mode": "ri",
    "parameter": "ActionController::HttpAuthentication::Digest",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/ri/ActionController%3A%3AHttpAuthentication%3A%3ADigest/json",
    "generated": "2026-07-28T15:25:07Z",
    "sections": {
        "ActionController::HttpAuthentication::Digest": {
            "content": "(from /home/chedong/.local/share/rdoc)\n------------------------------------------------------------------------\nMakes it dead easy to do HTTP Digest authentication.\n\n=== Simple Digest example\n\nrequire \"digest/md5\"\nclass PostsController < ApplicationController\nREALM = \"SuperSecret\"\nUSERS = {\"dhh\" => \"secret\", #plain text password\n\"dap\" => Digest::MD5.hexdigest([\"dap\",REALM,\"secret\"].join(\":\"))}  #ha1 digest password\n\nbeforeaction :authenticate, except: [:index]\n\ndef index\nrender plain: \"Everyone can see me!\"\nend\n\ndef edit\nrender plain: \"I'm only accessible if you know the password\"\nend\n\nprivate\ndef authenticate\nauthenticateorrequestwithhttpdigest(REALM) do |username|\nUSERS[username]\nend\nend\nend\n\n=== Notes\n\nThe authenticateorrequestwithhttpdigest block must return the\nuser's password or the ha1 digest hash so the framework can\nappropriately hash to check the user's credentials. Returning nil will\ncause authentication to fail.\n\nStoring the ha1 hash: MD5(username:realm:password), is better than\nstoring a plain password. If the password file or database is\ncompromised, the attacker would be able to use the ha1 hash to\nauthenticate as the user at this realm, but would not have the user's\npassword to try using at other sites.\n\nIn rare instances, web servers or front proxies strip authorization\nheaders before they reach your application. You can debug this situation\nby logging all environment variables, and check for HTTPAUTHORIZATION,\namongst others.\n------------------------------------------------------------------------",
            "subsections": []
        },
        "Instance methods:": {
            "content": "authenticate\nauthenticationheader\nauthenticationrequest\ndecodecredentials\ndecodecredentialsheader\nencodecredentials\nexpectedresponse\nha1\nnonce\nopaque\nsecrettoken\nvalidatedigestresponse\nvalidatenonce\n",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}