(w http.ResponseWriter, req *http.Request, next http.HandlerFunc)
| 45 | } |
| 46 | |
| 47 | func (a *AuthHandler) RequireTokenAuthentication(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) { |
| 48 | // if auth is disabled - do not check token |
| 49 | if !a.Enabled { |
| 50 | next(w, req) |
| 51 | return |
| 52 | } |
| 53 | |
| 54 | if authorizationValue := req.Header.Get("Authorization"); authorizationValue != "" { |
| 55 | // Should be a bearer token |
| 56 | if len(authorizationValue) > 6 && strings.ToUpper(authorizationValue[0:7]) == "BEARER " { |
| 57 | if authentication.IsJwtTokenValid(authorizationValue[7:], a.AB, a.SecretKey, a.JWTExpirationDelta) { |
| 58 | next(w, req) |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | WriteErrorResponse(w, "", http.StatusUnauthorized) |
| 64 | } |
| 65 | |
| 66 | type AllUsersResponse struct { |
| 67 | Users []backends.User `json:"users"` |
nothing calls this directly
no test coverage detected