| 74 | } |
| 75 | |
| 76 | func processAccounts(accounts Accounts) authPairs { |
| 77 | length := len(accounts) |
| 78 | assert1(length > 0, "Empty list of authorized credentials") |
| 79 | pairs := make(authPairs, 0, length) |
| 80 | for user, password := range accounts { |
| 81 | assert1(user != "", "User can not be empty") |
| 82 | value := authorizationHeader(user, password) |
| 83 | pairs = append(pairs, authPair{ |
| 84 | value: value, |
| 85 | user: user, |
| 86 | }) |
| 87 | } |
| 88 | return pairs |
| 89 | } |
| 90 | |
| 91 | func authorizationHeader(user, password string) string { |
| 92 | base := user + ":" + password |