fix: checkperms (#689)

* fix: read user grants as grant owner

* fix: read user grants as grant owner
This commit is contained in:
Fabi 2020-09-02 16:25:32 +02:00 committed by GitHub
parent 779879f6ae
commit c92042ba47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 5026 additions and 4211 deletions

View File

@ -35,6 +35,8 @@ func translateError(ctx context.Context, err error, translator *i18n.Translator)
caosErr := new(caos_errs.CaosError)
if errors.As(err, &caosErr) {
caosErr.SetMessage(translator.LocalizeFromCtx(ctx, caosErr.GetMessage(), nil))
} else {
return err
}
return caosErr
}

View File

@ -131,7 +131,7 @@ func (repo *UserGrantRepo) SearchUserGrants(ctx context.Context, request *grant_
result = &grant_model.UserGrantSearchResponse{
Offset: request.Offset,
Limit: request.Limit,
TotalResult: uint64(count),
TotalResult: count,
Result: model.UserGrantsToModel(grants),
}
if sequenceErr == nil {
@ -153,6 +153,7 @@ func handleSearchUserGrantPermissions(ctx context.Context, request *grant_model.
if result != nil {
return result
}
return nil
}
if _, query := request.GetSearchQuery(grant_model.UserGrantSearchKeyProjectID); query != nil {
result := checkContainsPermID(ids, query, request, sequence)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1148,10 +1148,10 @@ func (m *CreateMachineRequest) Validate() error {
}
}
if l := utf8.RuneCountInString(m.GetDescription()); l < 1 || l > 500 {
if utf8.RuneCountInString(m.GetDescription()) > 500 {
return CreateMachineRequestValidationError{
field: "Description",
reason: "value length must be between 1 and 500 runes, inclusive",
reason: "value length must be at most 500 runes",
}
}

View File

@ -797,7 +797,7 @@
"200": {
"description": "A successful response.",
"schema": {
"type": "object"
"$ref": "#/definitions/protobufStruct"
}
}
},
@ -854,6 +854,19 @@
}
},
"definitions": {
"protobufListValue": {
"type": "object",
"properties": {
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufValue"
},
"description": "Repeated field of dynamically typed values."
}
},
"description": "`ListValue` is a wrapper around a repeated field of values.\n\nThe JSON representation for `ListValue` is JSON array."
},
"protobufNullValue": {
"type": "string",
"enum": [
@ -862,6 +875,51 @@
"default": "NULL_VALUE",
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
},
"protobufStruct": {
"type": "object",
"properties": {
"fields": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/protobufValue"
},
"description": "Unordered map of dynamically typed values."
}
},
"description": "`Struct` represents a structured data value, consisting of fields\nwhich map to dynamically typed values. In some languages, `Struct`\nmight be supported by a native representation. For example, in\nscripting languages like JS a struct is represented as an\nobject. The details of that representation are described together\nwith the proto support for the language.\n\nThe JSON representation for `Struct` is JSON object."
},
"protobufValue": {
"type": "object",
"properties": {
"null_value": {
"$ref": "#/definitions/protobufNullValue",
"description": "Represents a null value."
},
"number_value": {
"type": "number",
"format": "double",
"description": "Represents a double value."
},
"string_value": {
"type": "string",
"description": "Represents a string value."
},
"bool_value": {
"type": "boolean",
"format": "boolean",
"description": "Represents a boolean value."
},
"struct_value": {
"$ref": "#/definitions/protobufStruct",
"description": "Represents a structured value."
},
"list_value": {
"$ref": "#/definitions/protobufListValue",
"description": "Represents a repeated `Value`."
}
},
"description": "`Value` represents a dynamically typed value which can be either\nnull, a number, a string, a boolean, a recursive struct value, or a\nlist of values. A producer of value is expected to set one of that\nvariants, absence of any variant indicates an error.\n\nThe JSON representation for `Value` is JSON value."
},
"v1AddIamMemberRequest": {
"type": "object",
"properties": {

View File

@ -481,7 +481,7 @@ message CreateHumanRequest {
message CreateMachineRequest {
string name = 1 [(validate.rules).string = {min_len: 1, max_len: 200}];
string description = 2 [(validate.rules).string = {min_len: 1, max_len: 500}];
string description = 2 [(validate.rules).string = {max_len: 500}];
}
message UserResponse {