Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: escape keycloak password to improve shell compat #857

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fmartingr
Copy link
Contributor

Summary

Use a naive approach to password escaping for keycloak if the tilde character is included in the password.

An improvement for this would be to limit the characters in the field validation.

Ticket Link

https://mattermost.atlassian.net/browse/MM-61278

@fmartingr fmartingr added the 2: Dev Review Requires review by a core committer label Nov 25, 2024
@fmartingr fmartingr self-assigned this Nov 25, 2024
@@ -171,7 +171,7 @@ func (t *Terraform) setupKeycloak(extAgent *ssh.ExtAgent) error {
}

// Authenticate as admin to execute keycloak commands
_, err = sshc.RunCommand(fmt.Sprintf("%s/kcadm.sh config credentials --server http://127.0.0.1:8080 --user %s --password %s --realm master", keycloakBinPath, t.config.ExternalAuthProviderSettings.KeycloakAdminUser, t.config.ExternalAuthProviderSettings.KeycloakAdminPassword))
_, err = sshc.RunCommand(fmt.Sprintf(`%s/kcadm.sh config credentials --server http://127.0.0.1:8080 --user "%s" --password '%s' --realm master`, keycloakBinPath, t.config.ExternalAuthProviderSettings.KeycloakAdminUser, strings.ReplaceAll(t.config.ExternalAuthProviderSettings.KeycloakAdminPassword, "'", "\\'")))
Copy link
Member

@agnivade agnivade Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought %q was meant to solve this scenario? Does that not work? 🤔

Wait nvm. It's the shell interpreting ~.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants