#include "usuals.h" #include "httpauthd.h" #include "basic.h" int basic_parse(const char* header, ha_buffer_t* buf, basic_header_t* rec) { char* t; memset(rec, 0, sizeof(*rec)); /* Trim the white space */ while(*header && isspace(*header)) header++; /* * Authorization header is in this format: * * "Basic " B64(user ":" password) */ ha_bufdec64(buf, header, 0); header = ha_bufdata(buf); if(!header) return HA_ERROR; /* We have a cache key at this point so hash it */ md5_string(rec->key, header); /* Parse the user. We need it in any case */ t = strchr(header, ':'); if(t != NULL) { /* Break the string in half */ *t = 0; rec->user = header; rec->password = t + 1; } return HA_OK; }