github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/model/permission/errors.go (about) 1 package permission 2 3 import ( 4 "net/http" 5 6 "github.com/labstack/echo/v4" 7 ) 8 9 var ( 10 // ErrInvalidToken is used when the token is invalid (the signature is not 11 // correct, the domain is not the good one, etc.) 12 ErrInvalidToken = echo.NewHTTPError(http.StatusBadRequest, 13 "Invalid JWT token") 14 15 // ErrInvalidAudience is used when the audience is not expected 16 ErrInvalidAudience = echo.NewHTTPError(http.StatusBadRequest, 17 "Invalid audience for JWT token") 18 19 // ErrExpiredToken is used when the token has expired and the client should 20 // refresh it 21 ErrExpiredToken = echo.NewHTTPError(http.StatusBadRequest, 22 "Expired token") 23 24 // ErrBadScope is used when the given scope is malformed 25 ErrBadScope = echo.NewHTTPError(http.StatusBadRequest, 26 "Permission scope is empty or malformed") 27 28 // ErrNotSubset is returned on requests attempting to create a Set of 29 // permissions which is not a subset of the request's own token. 30 ErrNotSubset = echo.NewHTTPError(http.StatusForbidden, 31 "Attempt to create a larger permission set") 32 33 // ErrOnlyAppCanCreateSubSet is returned if a non-app attempts to create 34 // sharing permissions. 35 ErrOnlyAppCanCreateSubSet = echo.NewHTTPError(http.StatusForbidden, 36 "Only apps can create sharing permissions") 37 38 // ErrNotParent is used when the permissions should have a specific parent. 39 ErrNotParent = echo.NewHTTPError(http.StatusForbidden, 40 "Permissions can be updated only by its parent") 41 )