Monday, November 08, 2010 at 12:07 AM.
system.verbs.builtins.webserver.util.parseAuth
<<Script: system.verbs.builtins.webserver.util.parseAuth; Version 1; Date: Wed, 13 May 1998 23:41:51 GMT; ID: RAB
on parseAuth (adrParamTable) {
<<March 13, 1998 at 4:37:36 PM by WMF
<<This script is adapted from the CGi framework
<<It looks for an Authorization header and if one is present, parses it and
<<puts the username in adrParams^.username and the password in (surprise) adrParams^.password
<<Returns true if there was a parseable Authorization header, false otherwise
local (s, upList);
on decodePassword (s) {
local (val, usr, pass);
val = string (base64.decode (s));
usr = string.nthField (val, ":", 1);
pass = string.nthField (val, ":", 2);
return ({usr, pass})};
if defined (adrParamTable^.requestHeaders.Authorization) {
s = adrParamTable^.requestHeaders.Authorization;
local (basicStart = string.patternMatch ("Basic", s));
if basicStart {
s = string.mid (s, basicStart + 6, infinity);
upList = decodePassword (s);
adrParamTable^.username = upList[1];
adrParamTable^.password = upList[2];
return (true)}
else {
return (false)}}
else {
return (false)}}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.