MCPcopy Create free account
hub / github.com/apache/devlake / SetupAuthentication

Method SetupAuthentication

backend/plugins/taiga/models/connection.go:49–62  ·  view source on GitHub ↗

SetupAuthentication sets up the HTTP request with authentication. If Token is set directly, use it. Otherwise exchange Username+Password for a token.

(req *http.Request)

Source from the content-addressed store, hash-verified

47// SetupAuthentication sets up the HTTP request with authentication.
48// If Token is set directly, use it. Otherwise exchange Username+Password for a token.
49func (tc *TaigaConn) SetupAuthentication(req *http.Request) errors.Error {
50 if tc.Token != "" {
51 req.Header.Set("Authorization", "Bearer "+tc.Token)
52 return nil
53 }
54 if tc.Username != "" && tc.Password != "" {
55 token, err := tc.fetchToken()
56 if err != nil {
57 return err
58 }
59 req.Header.Set("Authorization", "Bearer "+token)
60 }
61 return nil
62}
63
64// fetchToken exchanges username+password for a Taiga auth token via POST /auth
65func (tc *TaigaConn) fetchToken() (string, errors.Error) {

Callers

nothing calls this directly

Calls 1

fetchTokenMethod · 0.95

Tested by

no test coverage detected