1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
15 func BasicAuth(r *http.Request) (username, password string, ok bool) {
16 tokens := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
17 if len(tokens) != 2 || tokens[0] != "Basic" {
21 decoded, err := base64.StdEncoding.DecodeString(tokens[1])
26 userAndPass := strings.SplitN(string(decoded), ":", 2)
27 if len(userAndPass) != 2 {
31 return userAndPass[0], userAndPass[1], true