rc
This commit is contained in:
1 parent
e39ad275b5
commit
3d7e3a88f2
14 files changed
+710
-234
No files matched your search
+1
-59
@@ -129,6 +129,7 @@ func (m Model) runExport(usernames []string) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
u.PublicKey = res.PublicKeyLine
|
||||
u.Fingerprint = res.Fingerprint
|
||||
u.ForwardsHash = model.HashForwards(forwards)
|
||||
results = append(results, *res)
|
||||
m.logAudit(username, "admin", "key issued/rotated, fingerprint="+res.Fingerprint)
|
||||
}
|
||||
@@ -149,65 +150,6 @@ func (m Model) runExport(usernames []string) (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// runConfigUpdate is the lightweight alternative to a full export: when only
|
||||
// a user's group membership changed, their access is already updated
|
||||
// server-side immediately (authorized_keys permitopen=) — this just hands
|
||||
// them a fresh client config reflecting that, without touching their key at
|
||||
// all. See keymgr.BuildConfigOnlyArchive.
|
||||
func (m Model) runConfigUpdate(username string) (tea.Model, tea.Cmd) {
|
||||
st := m.loadState()
|
||||
u := st.FindUser(username)
|
||||
if u == nil {
|
||||
m.err = fmt.Sprintf("пользователь %q не найден", username)
|
||||
return m, nil
|
||||
}
|
||||
if u.PublicKey == "" {
|
||||
m.err = fmt.Sprintf("у пользователя %q ещё нет ключа — используйте «Экспорт архивов»", username)
|
||||
return m, nil
|
||||
}
|
||||
password, err := keymgr.GenerateBatchPassword(20)
|
||||
if err != nil {
|
||||
m.err = err.Error()
|
||||
return m, nil
|
||||
}
|
||||
forwards := st.AllowedForwards(u)
|
||||
res, err := keymgr.BuildConfigOnlyArchive(m.cfg.ScratchDir, m.cfg.ExportDir, m.cfg.JumpHost, m.cfg.JumpPort, username, password, forwards)
|
||||
if err != nil {
|
||||
m.err = err.Error()
|
||||
return m, nil
|
||||
}
|
||||
m.logAudit(username, "admin", "config-only update issued (key unchanged)")
|
||||
m.configUpdateUser = username
|
||||
m.configUpdateArchive = res.ArchivePath
|
||||
m.configUpdatePass = password
|
||||
m.err = ""
|
||||
m.screen = scrConfigUpdateResult
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m Model) updateConfigUpdateResult(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
if key, ok := msg.(tea.KeyMsg); ok {
|
||||
if key.String() == "esc" || key.String() == "enter" {
|
||||
m.screen = scrUsers
|
||||
m.err, m.status = "", ""
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m Model) viewConfigUpdateResult() string {
|
||||
body := fmt.Sprintf("Конфиг для %s обновлён — ключ НЕ менялся.\n\n", m.configUpdateUser)
|
||||
body += "Пароль архива (покажется только сейчас):\n\n"
|
||||
body += titleStyle.Render(m.configUpdatePass) + "\n\n"
|
||||
body += warnStyle.Render("Сообщите пароль отдельным от архива каналом.") + "\n\n"
|
||||
body += fmt.Sprintf("Архив: %s\n\n", m.configUpdateArchive)
|
||||
body += "Пользователю нужно только заменить файл config тем, что внутри — ключ и\n"
|
||||
body += "остальные файлы трогать не нужно.\n"
|
||||
body += "\n[enter/esc] в меню"
|
||||
return borderStyle.Render(body)
|
||||
}
|
||||
|
||||
func (m Model) viewExportSelect() string {
|
||||
st := m.loadState()
|
||||
body := "Экспорт архивов — выберите пользователей (общий пароль архива на всю партию)\n\n"
|
||||
|
||||
Reference in new issue
Block a user