Remove last use of v4 jwtauth

This commit is contained in:
Jamie Curnow
2023-06-01 11:37:25 +10:00
parent d5a75bb708
commit b437119535
4 changed files with 10 additions and 10 deletions

View File

@ -48,9 +48,9 @@ func getSchema() []byte {
return nil
}
provider := provider.NewIoFS(apiDocsSub, "")
prov := provider.NewIoFS(apiDocsSub, "")
resolver := jsref.New()
err := resolver.AddProvider(provider)
err := resolver.AddProvider(prov)
if err != nil {
logger.Error("SchemaProviderError", err)
}

View File

@ -6,7 +6,7 @@ import (
h "npm/internal/api/http"
"npm/internal/entity/user"
"github.com/go-chi/jwtauth"
"github.com/go-chi/jwtauth/v5"
)
// SSEAuth will validate that the jwt token provided to get this far is a SSE token
@ -33,7 +33,13 @@ func SSEAuth(next http.Handler) http.Handler {
userID := uint(claims["uid"].(float64))
_, enabled := user.IsEnabled(userID)
if token == nil || !token.Valid || !enabled || !claims.VerifyIssuer("sse", true) {
if token == nil || !enabled {
h.ResultErrorJSON(w, r, http.StatusUnauthorized, "Unauthorised", nil)
return
}
iss, _ := token.Get("iss")
if iss != "sse" {
h.ResultErrorJSON(w, r, http.StatusUnauthorized, "Unauthorised", nil)
return
}