mirror of
https://github.com/owncloud/ocis.git
synced 2025-04-18 23:44:07 +03:00
fix: app-auth user not found code
changelog fix changelog title
This commit is contained in:
parent
eb70b76835
commit
fae3d1d80d
6
changelog/unreleased/fix-app-auth-rest-status.md
Normal file
6
changelog/unreleased/fix-app-auth-rest-status.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Bugfix: Fix app-auth, REST status code
|
||||||
|
|
||||||
|
Now app-auth REST returns status code 404 when creating token for non-existent user (Impersonation)
|
||||||
|
|
||||||
|
https://github.com/owncloud/ocis/pull/11190
|
||||||
|
https://github.com/owncloud/ocis/issues/10815
|
@ -26,7 +26,10 @@ import (
|
|||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrBadRequest = errors.New("bad request")
|
var (
|
||||||
|
ErrBadRequest = errors.New("bad request")
|
||||||
|
ErrUserNotFound = errors.New("user not found")
|
||||||
|
)
|
||||||
|
|
||||||
// AuthAppToken represents an app token.
|
// AuthAppToken represents an app token.
|
||||||
type AuthAppToken struct {
|
type AuthAppToken struct {
|
||||||
@ -127,6 +130,10 @@ func (a *AuthAppService) HandleCreate(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if errors.Is(err, ErrUserNotFound) {
|
||||||
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -261,6 +268,10 @@ func (a *AuthAppService) authenticateUser(userID, userName string, gwc gateway.G
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if authRes.GetStatus().GetCode() == rpc.Code_CODE_NOT_FOUND {
|
||||||
|
return nil, ErrUserNotFound
|
||||||
|
}
|
||||||
|
|
||||||
if authRes.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
if authRes.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
||||||
return nil, errors.New("error authenticating user: " + authRes.GetStatus().GetMessage())
|
return nil, errors.New("error authenticating user: " + authRes.GetStatus().GetMessage())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user