mirror of
https://github.com/minio/minio.git
synced 2025-11-21 18:26:04 -05:00
Set the policy mapping for a user or group (#8036)
Add API to set policy mapping for a user or group Contains a breaking Admin APIs change. - Also enforce all applicable policies - Removes the previous /set-user-policy API Bump up peerRESTVersion Add get user info API to show groups of a user
This commit is contained in:
committed by
kannappanr
parent
bc79b435a2
commit
bf9b619d86
@@ -105,3 +105,32 @@ func (adm *AdminClient) AddCannedPolicy(policyName, policy string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetPolicy - sets the policy for a user or a group.
|
||||
func (adm *AdminClient) SetPolicy(policyName, entityName string, isGroup bool) error {
|
||||
queryValues := url.Values{}
|
||||
queryValues.Set("policyName", policyName)
|
||||
queryValues.Set("userOrGroup", entityName)
|
||||
groupStr := "false"
|
||||
if isGroup {
|
||||
groupStr = "true"
|
||||
}
|
||||
queryValues.Set("isGroup", groupStr)
|
||||
|
||||
reqData := requestData{
|
||||
relPath: "/v1/set-user-or-group-policy",
|
||||
queryValues: queryValues,
|
||||
}
|
||||
|
||||
// Execute PUT on /minio/admin/v1/set-user-or-group-policy to set policy.
|
||||
resp, err := adm.executeMethod("PUT", reqData)
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return httpRespToErrorResponse(resp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user