Skip to content

Commit

Permalink
To allow spaces in policy
Browse files Browse the repository at this point in the history
  • Loading branch information
cniackz committed Dec 3, 2024
1 parent 6afd0b1 commit cacf53c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
3 changes: 0 additions & 3 deletions api/admin_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,6 @@ func getAddPolicyResponse(session *models.Principal, params policyApi.AddPolicyP
if params.Body == nil {
return nil, ErrorWithContext(ctx, ErrPolicyBodyNotInRequest)
}
if strings.Contains(*params.Body.Name, " ") {
return nil, ErrorWithContext(ctx, ErrPolicyNameContainsSpace)
}
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
Expand Down
5 changes: 0 additions & 5 deletions api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ var (
ErrGroupNameNotInRequest = errors.New("error group name not in request")
ErrPolicyNameNotInRequest = errors.New("error policy name not in request")
ErrPolicyBodyNotInRequest = errors.New("error policy body not in request")
ErrPolicyNameContainsSpace = errors.New("error policy name cannot contain spaces")
ErrInvalidEncryptionAlgorithm = errors.New("error invalid encryption algorithm")
ErrSSENotConfigured = errors.New("error server side encryption configuration not found")
ErrBucketLifeCycleNotConfigured = errors.New("error bucket life cycle configuration not found")
Expand Down Expand Up @@ -161,10 +160,6 @@ func ErrorWithContext(ctx context.Context, err ...interface{}) *CodedAPIError {
errorCode = 400
errorMessage = ErrPolicyBodyNotInRequest.Error()
}
if errors.Is(err1, ErrPolicyNameContainsSpace) {
errorCode = 400
errorMessage = ErrPolicyNameContainsSpace.Error()
}
// console invalid session errors
if errors.Is(err1, ErrInvalidSession) {
errorCode = 401
Expand Down
5 changes: 2 additions & 3 deletions web-app/src/screens/Console/Policies/AddPolicyScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,13 @@ const AddPolicyScreen = () => {
};

const validatePolicyname = (policyName: string) => {
if (policyName.indexOf(" ") !== -1) {
return "Policy name cannot contain spaces";
if (policyName.trim() === "") {
return "Policy name cannot be empty";
} else return "";
};

const validSave =
policyName.trim() !== "" &&
policyName.indexOf(" ") === -1 &&
policyDefinition.trim() !== "";

useEffect(() => {
Expand Down

0 comments on commit cacf53c

Please sign in to comment.