From 7ecdf7a606d845768fc4033047745b08e6deb57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D0=BB=D0=B8=D0=BD=D0=B8=D0=BD=20=D0=A1=D0=B5?= =?UTF-8?q?=D1=80=D0=B3=D0=B5=D0=B9=20=D0=92=D0=B0=D0=BB=D0=B5=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=D0=B8=D1=87?= Date: Mon, 28 Oct 2024 16:03:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D1=88=D0=B8=D1=84=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20(wrap).?= =?UTF-8?q?=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=B2?= =?UTF-8?q?=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=B6=D0=B8=D0=B7=D0=BD?= =?UTF-8?q?=D0=B8=20=D1=82=D0=BE=D0=BA=D0=B5=D0=BD=D0=B0=20(TTL).=20=D0=94?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BE=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B4=D0=BB=D0=B8=D0=BD=D1=8B=20=D0=BF=D0=B0=D1=80?= =?UTF-8?q?=D0=BE=D0=BB=D1=8F=20=D0=B8=20=D0=B4=D0=BB=D0=B8=D0=BD=D1=8B=20?= =?UTF-8?q?=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=88=D0=B8=D1=84=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F.?= =?UTF-8?q?=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=82=D0=BE=D0=BA=D0=B5=D0=BD=D0=B0=20=D0=BA=20=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D1=88=D0=B8=D1=84=D1=80=D0=BE=D0=B2=D0=BA=D0=B5=20(?= =?UTF-8?q?=D0=BE=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=BB=D0=B8=D0=BD=D1=8B,=20=D1=83=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B1=D0=B5?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20=D1=81=D0=B8=D0=BC=D0=B2=D0=BE?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 2 +- html-template/index.html | 11 ++++++----- vault.go | 15 +++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a4a2312..8bde3c5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -64,7 +64,7 @@ services: labels: - "traefik.enable=true" - "traefik.http.routers.traefik.entrypoints=https" - - "traefik.http.routers.traefik.rule=Host(`somehost.example.ru`)" + - "traefik.http.routers.traefik.rule=Host(`example.ru`)" - "traefik.http.routers.traefik.tls=true" # - "traefik.http.routers.traefik.tls.certresolver=letsEncrypt" - "traefik.http.routers.traefik.service=api@internal" diff --git a/html-template/index.html b/html-template/index.html index 53118a5..cb38e53 100644 --- a/html-template/index.html +++ b/html-template/index.html @@ -15,24 +15,25 @@
- +
- Введите токен: + Введите текст или токен:
- +
+ +

- Длина пароля (от 15 до 1024) + Длина пароля (от 15 до {{ .MAXTEXTLENGTH }})
-
diff --git a/vault.go b/vault.go index 8de6719..b8e3bad 100644 --- a/vault.go +++ b/vault.go @@ -1,10 +1,3 @@ -// ------------------------------------------- -// Hashicorp Vault wrap/unwrap web service -// Distributed under GNU Public License -// Author: Sergey Kalinin svk@nuk-svk.ru -// Home page: https://nuk-svk.ru https://git.nuk-svk.ru -// ------------------------------------------- - package main import ( @@ -63,6 +56,7 @@ type TemplateData struct { URL string TEXT string MAXTEXTLENGTH int + TOKENTTL string } type UnwrappedData struct { Rerquest_id string `json: "request_id"` @@ -192,6 +186,7 @@ func getStaticPage(w http.ResponseWriter, r *http.Request) { templateData.URL = ActionAddress templateData.TEXT = Data templateData.MAXTEXTLENGTH = MaxTextLength + templateData.TOKENTTL = TokenTTL // templateData.URL = FishingUrl + "/" + arrUsers[i].messageUUID if body, err := ParseTemplate(template, templateData); err == nil { @@ -268,7 +263,7 @@ func genPassword(w http.ResponseWriter, r *http.Request) { if err != nil { log.Println(err) } - res, err := password.Generate(passwordLength, 10, 5, false, true) + res, err := password.Generate(passwordLength, 5, 5, false, true) if err != nil { log.Println(err) } @@ -312,6 +307,10 @@ func wrapDataFromHtmlForm(w http.ResponseWriter, r *http.Request) { if Debug { log.Println(Data) } + // Переводим секунды в часы и дабавляем к токену для информации. + ttl, _ := strconv.Atoi(TokenTTL) + ttl = ttl / 3600 + Data = fmt.Sprintf("%s\n\n---\nВремя жизни токена %s ч.", Data, strconv.Itoa(ttl)) } else if secret != "" { Data = "Введите текст для шифровки." }