MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / basicAuth

Function basicAuth

src/authentication.go:75–100  ·  view source on GitHub ↗
(r *http.Request, level string)

Source from the content-addressed store, hash-verified

73}
74
75func basicAuth(r *http.Request, level string) (username string, err error) {
76
77 err = errors.New("User authentication failed")
78
79 auth := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
80
81 if len(auth) != 2 || auth[0] != "Basic" {
82 return
83 }
84
85 payload, _ := base64.StdEncoding.DecodeString(auth[1])
86 pair := strings.SplitN(string(payload), ":", 2)
87
88 username = pair[0]
89 var password = pair[1]
90
91 token, err := authentication.UserAuthentication(username, password)
92
93 if err != nil {
94 return
95 }
96
97 err = checkAuthorizationLevel(token, level)
98
99 return
100}
101
102func urlAuth(r *http.Request, requestType string) (err error) {
103 var level, token string

Callers 1

IndexFunction · 0.85

Calls 2

UserAuthenticationFunction · 0.92
checkAuthorizationLevelFunction · 0.85

Tested by

no test coverage detected