fix: adjust default policies for system resources

This commit is contained in:
Qiu Jian
2019-08-05 18:56:05 +08:00
parent 3177771aae
commit c938da9edd
3 changed files with 46 additions and 2 deletions
-2
View File
@@ -20,7 +20,6 @@ import (
"fmt"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/sqlchemy"
@@ -243,7 +242,6 @@ func FetchUserInfo(ctx context.Context, data jsonutils.JSONObject) (mcclient.IId
}
func FetchProjectInfo(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) {
log.Debugf("FetchProjectInfo %s", data)
tenantId, key := jsonutils.GetAnyString2(data, []string{"project", "project_id", "tenant", "tenant_id"})
if len(tenantId) > 0 {
data.(*jsonutils.JSONDict).Remove(key)
+42
View File
@@ -114,6 +114,18 @@ var (
Action: PolicyActionGet,
Result: rbacutils.Allow,
},
{
Service: "compute",
Resource: "cloudproviders",
Action: PolicyActionList,
Result: rbacutils.Allow,
},
{
Service: "compute",
Resource: "cloudproviders",
Action: PolicyActionGet,
Result: rbacutils.Allow,
},
{
Service: "compute",
Resource: "cachedimages",
@@ -174,6 +186,36 @@ var (
Auth: true,
Scope: rbacutils.ScopeUser,
Rules: []rbacutils.SRbacRule{
{
Service: "compute",
Resource: "keypairs",
Action: PolicyActionGet,
Result: rbacutils.Allow,
},
{
Service: "compute",
Resource: "keypairs",
Action: PolicyActionList,
Result: rbacutils.Allow,
},
{
Service: "compute",
Resource: "keypairs",
Action: PolicyActionCreate,
Result: rbacutils.Allow,
},
{
Service: "compute",
Resource: "keypairs",
Action: PolicyActionUpdate,
Result: rbacutils.Allow,
},
{
Service: "compute",
Resource: "keypairs",
Action: PolicyActionDelete,
Result: rbacutils.Allow,
},
{
Service: "yunionconf",
Resource: "parameters",
+4
View File
@@ -16,6 +16,7 @@ package httperrors
import (
"net/http"
"runtime/debug"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
@@ -50,6 +51,9 @@ func HTTPError(w http.ResponseWriter, msg string, statusCode int, class string,
body.Add(err, "data")
w.Write([]byte(body.String()))
log.Errorf("Send error %s", err)
if statusCode >= 500 {
debug.PrintStack()
}
}
func JsonClientError(w http.ResponseWriter, e *httputils.JSONClientError) {