turn BasicAuth into a plugin, add beforeMatch and ForEachMatch hooks