commit 2d78fbc081fc806beca03c6a290084d04b17c60e
parent 7f4b1a29151ac22cbfb669f3d22c4dfa7d2a8907
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 2 Dec 2022 22:14:46 -0500
simplify gpg sign workflow
Diffstat:
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -473,7 +473,7 @@ func SessionsGpgSignTwoFactorHandler(c echo.Context) error {
var data sessionsGpgSignTwoFactorData
if c.Request().Method == http.MethodGet {
- data.ToBeSignedMessage = generatePgpToBeSignedTokenMessage(user.ID, "Signed message for darkforest 2fa", user.GPGPublicKey)
+ data.ToBeSignedMessage = generatePgpToBeSignedTokenMessage(user.ID, user.GPGPublicKey)
return c.Render(http.StatusOK, "sessions-gpg-sign-two-factor", data)
}
@@ -3341,9 +3341,9 @@ func generatePgpEncryptedTokenMessage(userID database.UserID, pkey string) (stri
return utils.GeneratePgpEncryptedMessage(pkey, msg)
}
-func generatePgpToBeSignedTokenMessage(userID database.UserID, txt, pkey string) string {
+func generatePgpToBeSignedTokenMessage(userID database.UserID, pkey string) string {
token := utils.GenerateToken10()
- msg := fmt.Sprintf("%s\n%s\n%s", txt, token, time.Now().UTC().Format("Jan 02, 2006"))
+ msg := fmt.Sprintf("dkf_%s{%s}", time.Now().UTC().Format("2006.01.02"), token)
pgpTokenCache.Set(userID, ValueTokenCache{Value: msg, PKey: pkey}, 10*time.Minute)
return msg
}
@@ -3360,7 +3360,7 @@ func AddPGPHandler(c echo.Context) error {
data.GpgMode = utils.DoParseBool(c.Request().PostFormValue("gpg_mode"))
if data.GpgMode {
- data.ToBeSignedMessage = generatePgpToBeSignedTokenMessage(authUser.ID, "Signed message for darkforest", data.PGPPublicKey)
+ data.ToBeSignedMessage = generatePgpToBeSignedTokenMessage(authUser.ID, data.PGPPublicKey)
return c.Render(http.StatusOK, "pgp_code", data)
} else {
diff --git a/pkg/web/public/views/pages/pgp_code.gohtml b/pkg/web/public/views/pages/pgp_code.gohtml
@@ -32,7 +32,7 @@
<div class="form-group">
<label for="encrypted_message">{{ t "Please sign the following message with your private key and send the signature" . }}</label>
<p><code>gpg --armor --detach-sign file</code></p>
- <textarea name="to_be_signed_message" id="to_be_signed_message" rows="3" class="form-control" style="font-family: SFMono-Regular,Menlo,Monaco,Consolas,'Liberation Mono','Courier New',monospace;" readonly>{{ .Data.ToBeSignedMessage }}</textarea>
+ <input name="to_be_signed_message" id="to_be_signed_message" value="{{ .Data.ToBeSignedMessage }}" type="text" class="form-control" style="font-family: SFMono-Regular,Menlo,Monaco,Consolas,'Liberation Mono','Courier New',monospace;" readonly />
</div>
<div class="form-group">
<label for="signed_message">{{ t "Message detached signature" . }}</label>
diff --git a/pkg/web/public/views/pages/sessions-gpg-sign-two-factor.gohtml b/pkg/web/public/views/pages/sessions-gpg-sign-two-factor.gohtml
@@ -26,7 +26,7 @@
<div class="form-group">
<label for="encrypted_message">{{ t "Please sign the following message with your private key and send the signature" . }}</label>
<p><code>gpg --armor --detach-sign file</code></p>
- <textarea name="to_be_signed_message" id="to_be_signed_message" rows="3" class="form-control" style="font-family: SFMono-Regular,Menlo,Monaco,Consolas,'Liberation Mono','Courier New',monospace;" readonly>{{ .Data.ToBeSignedMessage }}</textarea>
+ <input name="to_be_signed_message" id="to_be_signed_message" value="{{ .Data.ToBeSignedMessage }}" type="text" class="form-control" style="font-family: SFMono-Regular,Menlo,Monaco,Consolas,'Liberation Mono','Courier New',monospace;" readonly />
</div>
<div class="form-group">
<label for="signed_message">{{ t "Message detached signature" . }}</label>