MCPcopy
hub / github.com/gotify/server / tokenFromAuthorizationHeader

Method tokenFromAuthorizationHeader

auth/authentication.go:117–130  ·  view source on GitHub ↗
(ctx *gin.Context)

Source from the content-addressed store, hash-verified

115}
116
117func (a *Auth) tokenFromAuthorizationHeader(ctx *gin.Context) string {
118 const prefix = "Bearer "
119
120 authHeader := ctx.Request.Header.Get("Authorization")
121 if authHeader == "" {
122 return ""
123 }
124
125 if len(authHeader) < len(prefix) || !strings.EqualFold(prefix, authHeader[:len(prefix)]) {
126 return ""
127 }
128
129 return authHeader[len(prefix):]
130}
131
132func (a *Auth) userFromBasicAuth(ctx *gin.Context) (*model.User, error) {
133 if name, pass, ok := ctx.Request.BasicAuth(); ok {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected