Add field for new private key password when rotating user
This commit is contained in:
parent
40226c7393
commit
05d8eb5e5a
|
@ -192,6 +192,7 @@ new Vue({
|
|||
newUserPrivateKeyPassword: '',
|
||||
newUserCreateError: '',
|
||||
newPassword: '',
|
||||
newPrivateKeyPassword: '',
|
||||
passwordChangeStatus: '',
|
||||
passwordChangeMessage: '',
|
||||
rotateUserMessage: '',
|
||||
|
@ -465,18 +466,20 @@ new Vue({
|
|||
var data = new URLSearchParams();
|
||||
data.append('username', user);
|
||||
data.append('password', _this.u.newPassword);
|
||||
data.append('private-key-password', _this.u.newPrivateKeyPassword);
|
||||
|
||||
axios.request(axios_cfg('api/user/rotate', data, 'form'))
|
||||
.then(function(response) {
|
||||
_this.u.roatateUserStatus = 200;
|
||||
_this.u.newPassword = '';
|
||||
_this.u.newPrivateKeyPassword = '';
|
||||
_this.getUserData();
|
||||
_this.u.modalRotateUserVisible = false;
|
||||
_this.$notify({title: 'Certificates for user ' + _this.username + ' rotated!', type: 'success'})
|
||||
})
|
||||
.catch(function(error) {
|
||||
_this.u.roatateUserStatus = error.response.status;
|
||||
_this.u.rotateUserMessage = error.response.data.message;
|
||||
_this.u.rotateUserMessage = error.response.data;
|
||||
_this.$notify({title: 'Rotate certificates for user ' + _this.username + ' failed!', type: 'error'})
|
||||
})
|
||||
},
|
||||
|
|
|
@ -196,6 +196,10 @@
|
|||
<h4>Enter new password:</h4>
|
||||
<input type="password" class="form-control el-square modal-el-margin" minlength="6" autocomplete="off" placeholder="Password [_a-zA-Z0-9\.-]" v-model="u.newPassword">
|
||||
</div>
|
||||
<div class="modal-body" v-if="modulesEnabled.includes('privateKeyPasswdAuth')">
|
||||
<h4>Enter new private key password:</h4>
|
||||
<input type="password" class="form-control el-square modal-el-margin" minlength="6" autocomplete="off" placeholder="Private key password [_a-zA-Z0-9\.-]" v-model="u.newPrivateKeyPassword">
|
||||
</div>
|
||||
|
||||
<div class="modal-footer justify-content-center" v-if="u.rotateUserMessage.length > 0">
|
||||
<div class="alert" v-bind:class="userRotateStatusCssClass" role="alert" >
|
||||
|
|
10
main.go
10
main.go
|
@ -286,7 +286,8 @@ func (oAdmin *OvpnAdmin) userRotateHandler(w http.ResponseWriter, r *http.Reques
|
|||
return
|
||||
}
|
||||
_ = r.ParseForm()
|
||||
err, msg := oAdmin.userRotate(r.FormValue("username"), r.FormValue("password"))
|
||||
err, msg := oAdmin.userRotate(
|
||||
r.FormValue("username"), r.FormValue("password"), r.FormValue("private-key-password"))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
} else {
|
||||
|
@ -1152,7 +1153,7 @@ func (oAdmin *OvpnAdmin) userUnrevoke(username string) (error, string) {
|
|||
return errors.New(fmt.Sprintf("user \"%s\" not found", username)), fmt.Sprintf("{\"msg\":\"User \"%s\" not found\"}", username)
|
||||
}
|
||||
|
||||
func (oAdmin *OvpnAdmin) userRotate(username, newPassword string) (error, string) {
|
||||
func (oAdmin *OvpnAdmin) userRotate(username string, newPassword string, newPrivateKeyPassword string) (error, string) {
|
||||
if checkUserExist(username) {
|
||||
if *storageBackend == "kubernetes.secrets" {
|
||||
err := app.easyrsaRotate(username, newPassword)
|
||||
|
@ -1185,8 +1186,7 @@ func (oAdmin *OvpnAdmin) userRotate(username, newPassword string) (error, string
|
|||
log.Debug(o)
|
||||
}
|
||||
|
||||
// TODO: FIX
|
||||
userCreated, userCreateMessage := oAdmin.userCreate(username, newPassword, "")
|
||||
userCreated, userCreateMessage := oAdmin.userCreate(username, newPassword, newPrivateKeyPassword)
|
||||
if !userCreated {
|
||||
usersFromIndexTxt = indexTxtParser(fRead(*indexTxtPath))
|
||||
for i := range usersFromIndexTxt {
|
||||
|
@ -1199,7 +1199,7 @@ func (oAdmin *OvpnAdmin) userRotate(username, newPassword string) (error, string
|
|||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
return errors.New(fmt.Sprintf("error rotaing user due: %s", userCreateMessage)), userCreateMessage
|
||||
return errors.New(fmt.Sprintf("Error rotating user: %s", userCreateMessage)), userCreateMessage
|
||||
}
|
||||
|
||||
usersFromIndexTxt = indexTxtParser(fRead(*indexTxtPath))
|
||||
|
|
Loading…
Reference in New Issue