Commit d64932a0 authored by ls1947's avatar ls1947
Browse files

update ssh key management page

parent 031207eb
......@@ -145,10 +145,10 @@ public class UserSshKeyManagementBean implements Serializable {
}
} catch (UnsupportedKeyTypeException e) {
logger.warn("An error occured whilst deploying key: " + e.getMessage());
messageGenerator.addResolvedErrorMessage("error_msg", e.toString(), false);
messageGenerator.addResolvedErrorMessage("sshKeyMessage", "error_msg", e.toString(), false);
} catch (SshPubKeyBlacklistedException e) {
logger.warn("User {} tried to deploy blacklisted key", user.getId());
messageGenerator.addResolvedErrorMessage("error", "key_blacklisted", false);
messageGenerator.addResolvedErrorMessage("sshKeyMessage", "error", "key_blacklisted", false);
}
}
......
package edu.kit.scc.webreg.validator;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import javax.inject.Inject;
import edu.kit.scc.webreg.entity.SshPubKeyEntity;
import edu.kit.scc.webreg.service.ssh.SshPubKeyService;
import edu.kit.scc.webreg.ssh.OpenSshKeyDecoder;
import edu.kit.scc.webreg.ssh.OpenSshPublicKey;
import edu.kit.scc.webreg.ssh.UnsupportedKeyTypeException;
@FacesValidator("edu.kit.SshKeyValidator")
public class SshKeyValidator implements Validator {
@Inject
private SshPubKeyService sshPubKeyService;
@Inject
private OpenSshKeyDecoder keyDecoder;
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
OpenSshPublicKey key = new OpenSshPublicKey();
SshPubKeyEntity sshPubKeyEntity = sshPubKeyService.createNew();
key.setPubKeyEntity(sshPubKeyEntity);
try {
if (value != null) {
sshPubKeyEntity.setEncodedKey(value.toString());
keyDecoder.decode(key);
}
} catch (UnsupportedKeyTypeException e) {
FacesMessage msg =
new FacesMessage("SSH Key validation failed.",
"Invalid format: " + e.getMessage());
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(msg);
}
}
}
......@@ -24,10 +24,13 @@ unknown=Unbekannt
twofa_list=Liste zweiter Faktor
accept_tou=Ich habe die Nutzungsbedingungen gelesen und bin einverstanden.
set_ssh_pub_key=SSH Key setzen
key_blacklisted=Dieser SSH Key wurde bereits im System verwendet. Er kann nicht wieder verwendet werden.
add_ssh_pub_key=SSH Key hochladen
ssh_key_type=Schl\u00FCssel Typ
ssh_pub_key_command=SSH Key f\u00FCr benannte Kommandos
ssh_pub_key_interactiv=SSH Key f\u00FCr eine interaktive Shell
ssh_pub_key_list=List der SSH Keys
add_ssh_pub_key_desc=<div>Hier k\u00F6nnen Sie einen SSH Pub Key erstellen. Dies ist der \u00F6ffentliche Teil Ihres SSH Schl\u00FCssels. Der private Teil des Schl\u00FCssels sollte nur Ihnen bekannt sein.<div>\n\n<ul style\="color\:red">\n<li>Geben Sie nie Ihren private Schl\u00FCssel preis</li>\n<li>Sch\u00FCtzen Sie Ihren privaten Schl\u00FCssel mit einem sicheren Passwort</li>\n</ul>\n\n<div>Das Format des SSH Keys ist das selbe wie eine Zeile aus der Datei .ssh/authorized_keys.</div>
set_ssh_pub_key_for=SSH Key freischalten\:
ssh_pub_key_selected=Ausgew\u00E4hlter SSH Key
ssh_pub_key_usage_type=Benutzungsart
......
......@@ -4,7 +4,7 @@ twofa_active=Active
twofa_tokentype_totp_hardware=Hardware TOTP
twofa_tokentype_yubikey=Yubikey
twofa_tokentype_totp=Samrtphone app
twofa_create_new_token=Here you can create a new token.
twofa_create_new_token=Create a new token here.
twofa_create_new_totp=New smartphone token
twofa_create_new_yubico=New yubikey token
twofa_create_totp_token=Create new smartphone token
......@@ -24,6 +24,9 @@ unknown=Unknown
twofa_list=List of second factors
aa_entities=Attribute authorities
set_ssh_pub_key=Set SSH Key
key_blacklisted=This SSH key was already used in the system. It cannot be used again.
ssh_pub_key_list=List of ssh keys
add_ssh_pub_key_desc=<div>You can create an SSH Pub Key here. This is the public part of your SSH key. The private part of the key should only be known to you.</div>\n\n<ul style\="color\:red">\n<li>Never give away your private key</li>\n<li>Protect your private key with a secure password</li>\n</ul>\n\n<div>The format of the SSH Key field ist the same as a single line from your .ssh/authorized_keys file.</div>
add_ssh_pub_key=Add SSH Key
ssh_key_type=Key type
accept_tou=I have read and accepted the terms of use.
......
......@@ -24,61 +24,85 @@
<ui:define name="content">
<h:form id="form">
<div><p:messages showDetail="true" /></div>
<p:dataGrid var="key" value="#{userSshKeyManagementBean.keyList.toArray()}" columns="1"
layout="grid" style="margin-bottom: 16px;">
<f:facet name="header">#{messages.my_ssh_keys}</f:facet>
<p:panel styleClass="grayback" style="margin-bottom: 0px;">
<f:facet name="header">
<i class="fa fa-fw fa-key"></i>
<b><h:outputText value="#{key.pubKeyEntity.name}"/></b>
</f:facet>
<h:panelGrid columns="2">
<p:outputLabel for="@next" value="#{messages.ssh_key_type}:"/>
<h:outputText value="#{key.pubKeyEntity.keyType}"/>
<p:outputLabel for="@next" value="#{messages.fingerprint} (SHA256):"/>
<h:panelGroup>
<h:outputText value="#{key.fingerprint}" rendered="#{not empty key.fingerprint}"/>
<h:outputText value="#{messages.unknown}" rendered="#{empty key.fingerprint}"/>
</h:panelGroup>
<h:outputText value="#{messages.expires}:"/>
<h:outputText value="#{of:formatDate(key.pubKeyEntity.expiresAt, 'dd.MM.yyyy HH:mm')}"/>
<h:outputText value="#{messages.services}:"/>
<p:repeat var="reg" value="#{key.pubKeyEntity.sshPubKeyRegistries}">
<div>
<h:outputText value="#{reg.registry.service.name}"/>
<h:panelGroup id="interactiveId" rendered="#{reg.usageType == 'INTERACTIVE'}"><i class="fa fa-fw fa-user"></i></h:panelGroup>
<p:tooltip for="interactiveId" value="#{messages.ssh_pub_key_interactiv}" position="top"/>
<h:panelGroup id="commandId" rendered="#{reg.usageType == 'COMMAND'}"><i class="fa fa-fw fa-database"></i></h:panelGroup>
<p:tooltip for="commandId" value="#{messages.ssh_pub_key_command}" position="top"/>
</div>
</p:repeat>
</h:panelGrid>
<p:commandLink id="delete" action="#{userSshKeyManagementBean.deleteKey(key.pubKeyEntity.name)}" immediate="true" update="@form">
<h:panelGroup styleClass="ui-icon ui-icon-trash" />
<p:confirm header="#{messages.confirm_header}" message="#{messages.confirm}" />
</p:commandLink>
</p:panel>
</p:dataGrid>
<p:panel id="panel" header="#{messages.add_ssh_pub_key}">
<div><p:messages showDetail="true" /></div>
<p:dataGrid var="key" value="#{userSshKeyManagementBean.keyList.toArray()}" styleClass="whitefoot"
columns="2" layout="grid" style="margin-bottom: 16px;">
<f:facet name="header">#{messages.ssh_pub_key_list}</f:facet>
<p:panel styleClass="grayback" style="margin-bottom: 0px;">
<f:facet name="header">
<i class="fa fa-fw fa-key"></i>
<b><h:outputText value="#{key.pubKeyEntity.name}"/></b>
</f:facet>
<h:panelGrid columns="2">
<h:outputText for="@next" value="#{messages.expires}:" style="font-weight: bold;"/>
<p:outputPanel>
<h:outputText value="#{of:formatDate(key.pubKeyEntity.expiresAt, 'dd.MM.yyyy HH:mm')}"
rendered="#{not empty key.pubKeyEntity.expiresAt}" style="font-weight: bold;"/>
<h:outputText value="#{messages.never}"
rendered="#{empty key.pubKeyEntity.expiresAt}" style="font-weight: bold;"/>
</p:outputPanel>
<p:outputLabel for="@next" value="#{messages.ssh_key_type}:"/>
<h:outputText value="#{key.pubKeyEntity.keyType}"/>
<p:outputLabel for="@next" value="#{messages.fingerprint} (SHA256):"/>
<h:panelGroup>
<h:outputText value="#{key.fingerprint}" rendered="#{not empty key.fingerprint}"/>
<h:outputText value="#{messages.unknown}" rendered="#{empty key.fingerprint}"/>
</h:panelGroup>
<h:outputText for="@next" value="#{messages.services}:"/>
<p:repeat var="reg" value="#{key.pubKeyEntity.sshPubKeyRegistries}">
<div>
<h:outputText value="#{reg.registry.service.name}"/>
<h:panelGroup id="interactiveId" rendered="#{reg.usageType == 'INTERACTIVE'}"><i class="fa fa-fw fa-user"></i></h:panelGroup>
<p:tooltip for="interactiveId" value="#{messages.ssh_pub_key_interactiv}" position="top"/>
<h:panelGroup id="commandId" rendered="#{reg.usageType == 'COMMAND'}"><i class="fa fa-fw fa-database"></i></h:panelGroup>
<p:tooltip for="commandId" value="#{messages.ssh_pub_key_command}" position="top"/>
</div>
</p:repeat>
</h:panelGrid>
<p:commandButton action="#{userSshKeyManagementBean.deleteKey(key.pubKeyEntity.name)}" value="#{messages.delete}"
update="@form">
<p:confirm header="#{messages.confirm_header}" message="#{messages.confirm}" />
</p:commandButton>
</p:panel>
</p:dataGrid>
<p:panel>
<p:commandButton id="openAddSshKeyDlg" oncomplete="PF('addSshKeyDlg').show();" value="#{messages.add_ssh_pub_key}"></p:commandButton>
</p:panel>
<p:dialog header="#{messages.add_ssh_pub_key}"
widgetVar="addSshKeyDlg" id="addSshKeyDlgId" modal="true" closable="true" closeOnEscape="true"
showEffect="fade" hideEffect="fade">
<p:ajax event="close" update="@form" />
<div class="panel" style="width:360px;">
<h:outputText value="#{messages.add_ssh_pub_key_desc}" escape="false" />
</div>
<p:panelGrid id="baseData" columns="2">
<bw:inputText id="sshKeyName" label="#{messages.ssh_key_name}:"
value="#{userSshKeyManagementBean.newName}" required="true"/>
<h:outputText value="#{messages.ssh_key}:"/>
<p:inputTextarea value="#{userSshKeyManagementBean.newKey}" style="width: 400px; height: 100px;"
autoResize="false" />
<h:outputText for="@next" value="#{messages.ssh_key}:"/>
<p:outputPanel>
<p:inputTextarea id="keyInputArea" value="#{userSshKeyManagementBean.newKey}"
style="width: 400px; height: 100px;" autoResize="false">
<f:validator validatorId="edu.kit.SshKeyValidator"/>
<p:ajax update="keyInputMessage" event="keyup" />
</p:inputTextarea>
<p:message id="keyInputMessage" for="keyInputArea" />
</p:outputPanel>
</p:panelGrid>
<p:commandButton id="add" action="#{userSshKeyManagementBean.deployKey()}" value="#{messages.add}" update="@form" />
<p:ajaxStatus id="ajaxStatusPanel" style="display: inline-block; margin-left: 8px; vertical-align: baseline;">
<f:facet name="start">
......@@ -88,7 +112,8 @@
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
</p:panel>
</p:dialog>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade" closable="false" closeOnEscape="true">
<p:commandButton value="#{messages.yes}" type="button" styleClass="ui-confirmdialog-yes" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment