(ctx *gin.Context)
| 115 | } |
| 116 | |
| 117 | func (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 | |
| 132 | func (a *Auth) userFromBasicAuth(ctx *gin.Context) (*model.User, error) { |
| 133 | if name, pass, ok := ctx.Request.BasicAuth(); ok { |
no outgoing calls
no test coverage detected