Repository: minio/minio (language: go)

Issue:
Helm chart does not support special characters in access/secret key
You can have the Helm chart in this repository create users in Minio by specifying values like this:

```yaml
users:
    - accessKey: xxx
      secretKey: xxx
      policy: consoleAdmin
```

This works fine as long as the `accessKey` and `secretKey` don't contain any special characters. However, when I tried the following values:

```yaml
users:
  - accessKey: "tv:(()KW5$`>@/c:dB6_=.4|{jv?@!"
    secretKey: ".B_ES205}Mjzrh}G{emJi'LEuUE#:R"
    policy: consoleAdmin
```

The `minio-make-user-job` pod failed with the following error:

```
/config/add-user: line 72: syntax error near unexpected token `('
```

## Expected Behavior
I expected the chart to create a user with the specified access key and secret key.

## Current Behavior
The chart fails to create the user.

## Possible Solution
The problem is that the access key and secret key are inserted verbatim into a bash script:

https://github.com/minio/minio/blob/ce667ddae007a13df0020f6879fe5e0f955ba368/helm/minio/templates/_helper_create_user.txt#L78-L88

That means that characters like ` (backtick) and ( (parenthesis) are interpreted as bash syntax rather than a literal value. The script should properly escape these values, for example by encoding them using base64.

## Steps to Reproduce (for bugs)
Deploy the chart with the values mentioned above.

## Context
I'm trying to create a user with a secure password.

## Regression
As far as I can tell this has always been broken.

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used (`minio --version`): N/A
* Server setup and configuration: N/A
* Operating System and version (`uname -a`): N/A



Discussion / hints:

Fix patch:
diff --git a/helm/minio/templates/_helper_create_user.txt b/helm/minio/templates/_helper_create_user.txt
index 77714287a441e..7fd4cde18a237 100644
--- a/helm/minio/templates/_helper_create_user.txt
+++ b/helm/minio/templates/_helper_create_user.txt
@@ -8,6 +8,10 @@ MC="/usr/bin/mc --insecure --config-dir ${MC_CONFIG_DIR}"
 MC="/usr/bin/mc --insecure"
 {{- end }}
 
+# AccessKey and secretkey credentials file are added to prevent shell execution errors caused by special characters.
+# Special characters for example : ',",<,>,{,}
+MINIO_ACCESSKEY_SECRETKEY_TMP="/config/accessKey_and_secretKey_tmp"
+
 # connectToMinio
 # Use a check-sleep-check loop to wait for MinIO service to be available
 connectToMinio() {
@@ -35,28 +39,35 @@ connectToMinio() {
   return 0
 }
 
-# checkUserExists ($username)
+# checkUserExists ()
 # Check if the user exists, by using the exit code of `mc admin user info`
 checkUserExists() {
-  USER=$1
-  CMD=$(${MC} admin user info myminio $USER > /dev/null 2>&1)
+  CMD=$(${MC} admin user info myminio $(head -1 $MINIO_ACCESSKEY_SECRETKEY_TMP) > /dev/null 2>&1)
   return $?
 }
 
-# createUser ($username, $password, $policy)
+# createUser ($policy)
 createUser() {
-  USER=$1
-  PASS=$2
-  POLICY=$3
-
+  POLICY=$1
+  #check accessKey_and_secretKey_tmp file
+  if [[ ! -f $MINIO_ACCESSKEY_SECRETKEY_TMP ]];then
+    echo "credentials file does not exist"
+    return 1
+  fi
+  if [[ $(cat $MINIO_ACCESSKEY_SECRETKEY_TMP|wc -l) -ne 2 ]];then
+    echo "credentials file is invalid"
+    rm -f $MINIO_ACCESSKEY_SECRETKEY_TMP
+    return 1
+  fi
   # Create the user if it does not exist
-  if ! checkUserExists $USER ; then
+  if ! checkUserExists ; then
     echo "Creating user '$USER'"
-    ${MC} admin user add myminio $USER $PASS
+    cat $MINIO_ACCESSKEY_SECRETKEY_TMP | ${MC} admin user add myminio
   else
     echo "User '$USER' already exists."
   fi
-
+  #clean up credentials files.
+  rm -f $MINIO_ACCESSKEY_SECRETKEY_TMP
 
   # set policy for user
   if [ ! -z $POLICY -a $POLICY != " " ] ; then
@@ -79,10 +90,13 @@ connectToMinio $scheme
 {{ $global := . }}
 # Create the users
 {{- range .Values.users }}
+echo {{ tpl .accessKey $global }} > $MINIO_ACCESSKEY_SECRETKEY_TMP
 {{- if .existingSecret }}
-createUser {{ tpl .accessKey $global }} $(cat /config/secrets/{{ tpl .accessKey $global }}) {{ .policy }}
+cat /config/secrets/{{ tpl .secretKey $global }} >> $MINIO_ACCESSKEY_SECRETKEY_TMP
+createUser {{ .policy }}
 {{ else }}
-createUser {{ tpl .accessKey $global }} {{ .secretKey }} {{ .policy }}
+echo {{ .secretKey }} >> $MINIO_ACCESSKEY_SECRETKEY_TMP
+createUser {{ .policy }}
 {{- end }}
 {{- end }}
 {{- end }}


Test patch: