MCPcopy Create free account
hub / github.com/evcc-io/evcc / apiKeyFromRequest

Function apiKeyFromRequest

server/http_auth.go:72–78  ·  view source on GitHub ↗

apiKeyFromRequest returns the API key from the Authorization: Bearer header, or "" if absent. A non-Bearer Authorization header (e.g. Basic auth injected by a reverse proxy) is ignored.

(r *http.Request)

Source from the content-addressed store, hash-verified

70// apiKeyFromRequest returns the API key from the Authorization: Bearer header, or "" if absent.
71// A non-Bearer Authorization header (e.g. Basic auth injected by a reverse proxy) is ignored.
72func apiKeyFromRequest(r *http.Request) string {
73 token, found := strings.CutPrefix(r.Header.Get("Authorization"), "Bearer ")
74 if !found {
75 return ""
76 }
77 return token
78}
79
80// jwtFromCookie returns the session JWT from the auth cookie, or "" if absent
81func jwtFromCookie(r *http.Request) string {

Callers 3

validateAuthFunction · 0.85
ensureDbAuthFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected