-
Notifications
You must be signed in to change notification settings - Fork 7
Feature: 支持密码加密选项 #16
Comments
What is a "password encryption option"? |
koishi-plugin-gocqhttp/template.yml Line 12 in 65852b0
|
Oh, it is just an option. Easy-peasy 🤣 But I don't know what exactly it is, or what can it do for the users. Maiko's everyday word: easy-peasy: when you want to say something is very easy and straightforward to do, you can say "easy-peasy". 舞子的每日一詞: 簡單得很:當你想要形容一件事情可以非常容易且直接地完成,你可以說「簡單豌豆的」。 |
It allows the user to encrypt the password and decrypt it when gocqhttp is launched, which can avoid direct password exposure in the config file. The user would input the password through standard input, so a password prompt in the web console should also be implemented. Source code about |
Maji yabaku ne! It is no longer "just an option". 😭 So the |
nah, it requires the user to put the password in the config at first with the Generated by koishi-plugin-github. |
but well, the Generated by koishi-plugin-github. |
Well, in fact I don't know golang much, but I will try to read it. Merci pour la explication. |
I didn't even learn golang once lol, but the mechanism is similar, no matter what the language is. Edit: should use Generated by koishi-plugin-github. |
Well, I have learnt more golang and read So, in my understanding, in order to support this option, we should do a workflow like this:
That is, no offense, freaking complicated! I don't think we could make it done in, like three days or weeks. And from the workflow above, you should make sure the On the other hand, when user enable this, he/she/it/whatever would be required to enter at least THRICE (even we cache the key that used in 4) and 7), still required twice). Overall, I don't think this feature is worth to be implemented by our side. I would quote what @undefined-moe said in the corresponding issue in
As if you could handle all of the operations above, you or a random independent Koishier should also know how to maintain your own Best regard. |
I actually think one of us (probably it's me) doesn't completely understand the source code. Let's take a look at this part. if len(byteKey) == 0 {
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
cancel := make(chan struct{}, 1)
state, _ := term.GetState(int(os.Stdin.Fd()))
go func() {
select {
case <-cancel:
return
case <-time.After(time.Second * 45):
log.Infof("解密key输入超时")
time.Sleep(3 * time.Second)
_ = term.Restore(int(os.Stdin.Fd()), state)
os.Exit(0)
}
}()
byteKey, _ = term.ReadPassword(int(os.Stdin.Fd()))
cancel <- struct{}{}
} else {
log.Infof("密码加密已启用, 使用运行时传递的参数进行解密,按 Ctrl+C 取消.")
}
encrypt, _ := os.ReadFile("password.encrypt")
ph, err := PasswordHashDecrypt(string(encrypt), byteKey)
if err != nil {
log.Fatalf("加密存储的密码损坏,请尝试重新配置密码")
}
copy(base.PasswordHash[:], ph) In my understanding, it would first check if there's an argument that provides the 'password' to decrypt the login password. If so, use it to decrypt the password, else wise, ask the user to input the password in the terminal. This would solve the problem that Masnn mentioned: the 'password' to decrypt the login password is not stored and is memorized by the admin, so only if the user inputs the password in the terminal or provide it through arguments, gocqhttp would be able to decrypt the password. Elsewise, neither gocqhttp nor other software would be able to decrypt it. Also, I'd like to share some situations when we need it:
The workflow can be easily simplified with the password args. We just need to (fake code): pwd_encrypt = ask the user for the password.
if( file "password.encrypt" not exists ){
pwd = ask the user for qq password
write pwd to config.yml and enable encrypt option
start process 'gocqhttp'
pass the password to standard input
wait until it exits
}
remove the password in config.yml, save it.
start process 'gocqhttp' with arg `--pwd=${pwd_encrypt}` Anyway, I think that's a good feature and I'd like to leave the issue here. You contributors take the final determination if implement this feature or not. Sincerely, |
Attention please, I am not saying that shouldn't you use the |
Sorry if I caused a misunderstanding, I'm actually replying to the reply that you referenced of Masnn and explaining why it's not a problem here. I don't mean you said I shouldn't use |
No description provided.
The text was updated successfully, but these errors were encountered: