2411: Remove golang<1.4 shim.
[arvados.git] / sdk / go / auth / auth.go
index 41cfb993726d9179fffbb187cad3ec96e8b8f952..730989b3a371ebcb2874784bbd76f668c22a6db2 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
 package auth
 
 import (
@@ -41,7 +45,7 @@ func (a *Credentials) LoadTokensFromHTTPRequest(r *http.Request) {
 
        // Load base64-encoded token from "Authorization: Basic ..."
        // header (typically used by git via credential helper)
-       if _, password, ok := BasicAuth(r); ok {
+       if _, password, ok := r.BasicAuth(); ok {
                a.Tokens = append(a.Tokens, password)
        }
 
@@ -67,13 +71,8 @@ func (a *Credentials) LoadTokensFromHTTPRequest(r *http.Request) {
        // secret is known)
 }
 
-// TODO: LoadTokensFromHttpRequestBody(). We can't assume in
-// LoadTokensFromHttpRequest() that [or how] we should read and parse
-// the request body. This has to be requested explicitly by the
-// application.
-
 func (a *Credentials) loadTokenFromCookie(r *http.Request) {
-       cookie, err := r.Cookie("api_token")
+       cookie, err := r.Cookie("arvados_api_token")
        if err != nil || len(cookie.Value) == 0 {
                return
        }
@@ -83,3 +82,8 @@ func (a *Credentials) loadTokenFromCookie(r *http.Request) {
        }
        a.Tokens = append(a.Tokens, string(token))
 }
+
+// TODO: LoadTokensFromHttpRequestBody(). We can't assume in
+// LoadTokensFromHttpRequest() that [or how] we should read and parse
+// the request body. This has to be requested explicitly by the
+// application.