13 Commits
v0.0.8 ... main

Author SHA1 Message Date
d7678274be added pull info 2026-01-17 22:57:04 +01:00
4a8f7525e7 updated README 2026-01-17 22:54:57 +01:00
fb55f47e5c fixed spelling 2026-01-17 22:32:35 +01:00
0251b9dc69 undo centered image, did not work 2026-01-17 22:30:58 +01:00
2b505b0d9d centered image 2026-01-17 22:30:00 +01:00
cb3545f261 updated claim in README.md 2026-01-17 22:29:08 +01:00
d673b97b4b deleted obsolete lines in misc/docker-compose.traefik.yml 2026-01-17 22:26:58 +01:00
1be4aeb6b8 updated MoreUsage.md 2026-01-17 22:24:16 +01:00
0a3f4ab5ef added dynamic hostname to helpHandler
All checks were successful
/ push_to_registry (push) Successful in 51s
2026-01-17 21:59:54 +01:00
36ce60aa28 container sized down to 500px width
All checks were successful
/ push_to_registry (push) Successful in 52s
2026-01-17 21:44:01 +01:00
Florian Walther
d21b959104 58er Zeichensatz hinzugefügt 2026-01-17 13:13:09 +01:00
Florian Walther
2b822af907 deleted deprecated workflow 2026-01-17 12:57:04 +01:00
Florian Walther
2aa636409a Screenshot aktualisiert 2026-01-17 12:47:28 +01:00
6 changed files with 158 additions and 114 deletions

View File

@@ -1,29 +0,0 @@
name: Docker Build and Push
#on: [push]
on:
workflow_dispatch:
jobs:
build-and-push:
runs-on: docker
if: branch == 'main'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Login to Registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_URL }} -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Build Docker Image
run: |
docker build -t ${{ secrets.REGISTRY_URL }}/FlorianWalther/password-generator:latest .
- name: Push Docker Image
run: |
docker push ${{ secrets.REGISTRY_URL }}/FlorianWalther/password-generator:latest
- name: Cleanup
run: |
docker system prune -f

View File

@@ -1,6 +1,6 @@
# Web-Password # Web-Password
_a web based password generator_ _a web based password generator, with an API endpoint_
![App Screenshot](img/screenshot.png) ![App Screenshot](img/screenshot.png)
@@ -16,7 +16,7 @@ There is a demo at [https://passwd.scu.si](https://passwd.scu.si)
## Usage ## Usage
The follwoing example shows how to get up your own instance with `docker compose`. The following example shows how to get up your own instance with `docker compose`.
``` ```
git clone https://gitea.scu.si/FlorianWalther/Web-Password.git git clone https://gitea.scu.si/FlorianWalther/Web-Password.git
@@ -26,4 +26,15 @@ docker compose pull
docker compose up -d docker compose up -d
``` ```
## Docker image
The latest official docker image is at [https://gitea.scu.si/FlorianWalther/-/packages/container/password-generator/latest](https://gitea.scu.si/FlorianWalther/-/packages/container/password-generator/latest)
You can pull it like this:
```
docker pull gitea.scu.si/florianwalther/password-generator:latest
```
## more usage examples
There are some more usage example in [misc/MoreUsage.md](misc/MoreUsage.md) There are some more usage example in [misc/MoreUsage.md](misc/MoreUsage.md)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 24 KiB

41
main.go
View File

@@ -9,8 +9,22 @@ import (
const ( const (
passwordLength = 32 passwordLength = 32
// Zeichensatz mit 62 möglichen Zeichen pro Position
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
//chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!?$%&=#+<>-:,.;_*@"
// Zeichensatz mit 58 möglichen Zeichen pro Position
// Verwechslungsanfällige Zeichen (0, O, 1, l, I) sind nicht enthalten.
//
// ## Security Note: ################################################
// Der reduzierte Zeichensatz setzt den Keyspace von 10^57 auf 10^56 herab.
// Die Entropie wird von ~192.6 Bit auf ~190.6 Bit herabgesetzt.
// Solange die Passwortlänge von 32 Zeichen beibehalten wird ist der
// Sicherheitsverlust durch einen reduzierten Zeichensatz akzeptabel,
// weil der Keyspace immer noch so groß ist dass ein erraten praktisch
// unmöglich ist.
//
//const chars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789"
) )
func generatePassword() string { func generatePassword() string {
@@ -32,6 +46,7 @@ func passwordHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, password) fmt.Fprint(w, password)
} }
// new help handler
func helpHandler(w http.ResponseWriter, r *http.Request) { func helpHandler(w http.ResponseWriter, r *http.Request) {
helpHTML := ` helpHTML := `
<!DOCTYPE html> <!DOCTYPE html>
@@ -58,7 +73,7 @@ func helpHandler(w http.ResponseWriter, r *http.Request) {
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
max-width: 800px; max-width: 800px;
width: 90%; width: 90%;
min-width: 600px; min-width: 500px;
} }
h1 { h1 {
font-size: 1.5rem; font-size: 1.5rem;
@@ -89,18 +104,29 @@ func helpHandler(w http.ResponseWriter, r *http.Request) {
Der Endpunkt gibt das Passwort im Plain-Text-Format zurück. Der Endpunkt gibt das Passwort im Plain-Text-Format zurück.
</p> </p>
<h2>Endpunkt:</h2> <h2>Endpunkt:</h2>
<p><code>http://localhost:8080/api/password</code></p> <p><code id="api-endpoint"></code></p>
<h2>Beispiele:</h2> <h2>Beispiele:</h2>
<h3>Mac/Linux (Terminal):</h3> <h3>Mac/Linux (Terminal):</h3>
<pre>echo $(curl -s http://localhost:8080/api/password)</pre> <pre id="curl-example"></pre>
<h3>Windows (PowerShell):</h3> <h3>Windows (PowerShell):</h3>
<pre>Invoke-RestMethod -Uri http://localhost:8080/api/password</pre> <pre id="powershell-example"></pre>
<h3>Windows (cmd):</h3> <h3>Windows (cmd):</h3>
<pre>curl http://localhost:8080/api/password</pre> <pre id="cmd-example"></pre>
<p> <p>
<a href="/">Zurück zur Passwort-Generierung</a> <a href="/">Zurück zur Passwort-Generierung</a>
</p> </p>
</div> </div>
<script>
// Dynamisch den aktuellen Hostnamen ermitteln
const currentHost = window.location.host;
const apiEndpoint = "http://" + currentHost + "/api/password";
// Hostnamen in die Beispiele eintragen
document.getElementById("api-endpoint").textContent = apiEndpoint;
document.getElementById("curl-example").textContent = "curl " + apiEndpoint;
document.getElementById("powershell-example").textContent = "Invoke-RestMethod -Uri " + apiEndpoint;
document.getElementById("cmd-example").textContent = "curl " + apiEndpoint;
</script>
</body> </body>
</html> </html>
` `
@@ -108,6 +134,7 @@ func helpHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, helpHTML) fmt.Fprint(w, helpHTML)
} }
func webHandler(w http.ResponseWriter, r *http.Request) { func webHandler(w http.ResponseWriter, r *http.Request) {
password := generatePassword() password := generatePassword()
html := fmt.Sprintf( html := fmt.Sprintf(
@@ -134,7 +161,7 @@ html := fmt.Sprintf(
border-radius: 8px; border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
width: 90%%; width: 90%%;
min-width: 600px; min-width: 500px;
position: relative; position: relative;
} }
h1 { h1 {

View File

@@ -1,31 +1,60 @@
## bash alias
You can configure an bash alias in your `~/.bashrc` like this:
# Baue die Go-Anwendung ```
## genpasswd alias
alias genpasswd='echo $(curl -s https://passwd.scu.si/api/password)'
```
After making above changes you have to reload your ~/bashrc, in order to activate your changes.
```
. ~/.bashrc
```
Now you can enter `genpasswd` and get a fresh password from the API Endpoint.
# building the app
you can build the app yourself like this:
``` ```
go build -o password-generator ./ go build -o password-generator ./
``` ```
# Baue das Docker-Image
# build a docker container
``` ```
docker build -t password-generator . docker build -t password-generator .
``` ```
# Starte den Docker Container # start the docker container
``` ```
docker run -p 8080:8080 password-generator docker run -p 8080:8080 password-generator
``` ```
## mit docker-compose ## docker-compose
Ein `docker-compose.yml` wird mitgeliefert. There are two example docker-compose files in the [misc](./) directory.
### docker-compose.yml
A basic variant that just brings up the container and export port 8080.
The basic variant can be used without modifications.
### docker-compose.traefik.yml
The other one is meant to be used behind a traefik reverse proxy.
This variant has lables to configure traefik accordingly.
The traefik variant needs to be adjusted to your environment before
you can use it successfully.
### initial pull ### initial pull
``` ```
docker compose login gitea.scu.si
docker compose pull docker compose pull
``` ```
@@ -41,5 +70,13 @@ docker compose up -d
docker compose down docker compose down
``` ```
### update container
In order to update your container to the current version, do this:
```
docker compose pull
docker compose down
docker compose up -d
```

View File

@@ -5,8 +5,6 @@ services:
restart: always restart: always
expose: expose:
- "8080:8080" - "8080:8080"
# Falls die Registry privat ist, muss der Host zuvor mit
# 'docker login gitea.scu.si' angemeldet worden sein.
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.docker.network=traefik_backend" - "traefik.docker.network=traefik_backend"