Gauge fields and extrapotentials in constrained quantum systems