-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: main
Are you sure you want to change the base?
Conversation
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.
There was a problem hiding this 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.
password.WriteString( | ||
string(passwordChars.Specials[random.Intn(len(passwordChars.Specials))]), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
There was a problem hiding this comment.
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
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.