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

Add random password feature #34

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

Conversation

mooncube
Copy link

@mooncube mooncube commented Jun 5, 2022

We need to manage user's channels and other resources using
Terraform without knowledge of user's actual password (due to
privacy issues).

So the following feature is implemented.

If password field in user resource definition is set to "-", the
user is created with a random password and "reset password" email
is sent to the user.

We need to manage user's channels and other resources using
Terraform without knowledge of user's actual password (due to
privacy issues).

So the following feature is implemented.

If password field in user resource definition is set to "-", the
user is created with a random password and "reset password" email
is sent to the user.
@vmignot vmignot requested a review from ndrpnt July 11, 2022 07:28
Copy link
Collaborator

@ndrpnt ndrpnt left a comment

Choose a reason for hiding this comment

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

Hi @mooncube, thanks a lot for your PR. Sorry, for the slow reply, as you can see this repo doesn't see much activity.

I guess the reason for this change is to avoid using a random_password resource that would imply storing the generated password in Terraform state file. I'm not sure that it does much in terms of privacy (we don't guarantee anything to the user and still have ways to know the password), but since you seem to have a use for it I'm willing to merge your PR. Would you mind taking a look at the review? Thanks.

Comment on lines +51 to +53
password.WriteString(
string(passwordChars.Specials[random.Intn(len(passwordChars.Specials))]),
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
password.WriteString(
string(passwordChars.Specials[random.Intn(len(passwordChars.Specials))]),
)
// Using crypto/rand
i, err := rand.Int(rand.Reader, big.NewInt(len(passwordChars.Specials)))
if err != nil {
return "", err
}
password.WriteString(string(passwordChars.Specials[i.Uint64()]))

@@ -2,10 +2,15 @@ package provider

import (
"fmt"
"math/rand"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should use crypto/rand for password generation. See my suggestion below for an example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants