Make amount of users in patch configurable.
This PR changes the following: * Create an API config section for API configurables. * Add a setting `UserPatchLimit` that controls how many users can be changed in a PATCH request. * Use this setting in the API to limit the amount of users that can be changed.
This commit is contained in:
committed by
Ralf Haferkamp
parent
883d068b48
commit
49d71ea111
@@ -19,7 +19,6 @@ import (
|
||||
"github.com/go-chi/render"
|
||||
)
|
||||
|
||||
const memberRefsLimit = 20
|
||||
const memberTypeUsers = "users"
|
||||
|
||||
// GetGroups implements the Service interface.
|
||||
@@ -124,13 +123,13 @@ func (g Graph) PatchGroup(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if memberRefs, ok := changes.GetMembersodataBindOk(); ok {
|
||||
// The spec defines a limit of 20 members maxium per Request
|
||||
if len(memberRefs) > memberRefsLimit {
|
||||
if len(memberRefs) > g.config.API.UserPatchLimit {
|
||||
logger.Debug().
|
||||
Int("number", len(memberRefs)).
|
||||
Int("limit", memberRefsLimit).
|
||||
Int("limit", g.config.API.UserPatchLimit).
|
||||
Msg("could not create group, exceeded members limit")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
|
||||
fmt.Sprintf("Request is limited to %d members", memberRefsLimit))
|
||||
fmt.Sprintf("Request is limited to %d members", g.config.API.UserPatchLimit))
|
||||
return
|
||||
}
|
||||
memberIDs := make([]string, 0, len(memberRefs))
|
||||
|
||||
Reference in New Issue
Block a user