| 30 | type authPairs []authPair |
| 31 | |
| 32 | func (a authPairs) searchCredential(authValue string) (string, bool) { |
| 33 | if authValue == "" { |
| 34 | return "", false |
| 35 | } |
| 36 | for _, pair := range a { |
| 37 | if subtle.ConstantTimeCompare(bytesconv.StringToBytes(pair.value), bytesconv.StringToBytes(authValue)) == 1 { |
| 38 | return pair.user, true |
| 39 | } |
| 40 | } |
| 41 | return "", false |
| 42 | } |
| 43 | |
| 44 | // BasicAuthForRealm returns a Basic HTTP Authorization middleware. It takes as arguments a map[string]string where |
| 45 | // the key is the user name and the value is the password, as well as the name of the Realm. |