Dynamic UI components (#1162)

Hide/Show UI components based on the IAM policy of the current user

- Buckets lists: hide/show manage button
- Bucket admin page: left menu items enable/disable
- Bucket admin page: bucket configuration buttons are enabled/disabled
- Bucket admin page: hide/show create buttons
- Bucket admin page: enable/disable requests to backend service
- Object browser: hide/show bucket buttons for upload, delete, etc
- Object browser: hide/show bucket configuration button
- Object details: hide/show object buttons, ie: delete
- Object details: hide/show object attributes, ie: legal hold,
  retention, tags, etc

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>

Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Lenin Alevski
2021-11-02 17:34:39 -07:00
committed by GitHub
parent e1a3164cd9
commit 184f864873
32 changed files with 1905 additions and 709 deletions

View File

@@ -18,6 +18,7 @@ package restapi
import (
"context"
"encoding/json"
"net/http"
"net/url"
"time"
@@ -84,6 +85,17 @@ func getSessionResponse(session *models.Principal) (*models.SessionResponse, *mo
return nil, prepareError(err, errorGenericInvalidSession)
}
userAdminClient := AdminClient{Client: mAdminClient}
// Policy used by the current user
accountInfo, err := userAdminClient.AccountInfo(ctx)
if err != nil {
return nil, prepareError(err)
}
var sessionPolicy *models.IamPolicy
err = json.Unmarshal(accountInfo.Policy, &sessionPolicy)
if err != nil {
return nil, prepareError(err)
}
// Obtain the current policy assigned to this user
// necessary for generating the list of allowed endpoints
policy, err := getAccountPolicy(ctx, userAdminClient)
@@ -105,6 +117,7 @@ func getSessionResponse(session *models.Principal) (*models.SessionResponse, *mo
Status: models.SessionResponseStatusOk,
Operator: false,
DistributedMode: isErasureMode(),
Policy: sessionPolicy,
}
return sessionResp, nil
}