Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a3f4ab5ef | |||
| 36ce60aa28 | |||
|
|
d21b959104 | ||
|
|
2b822af907 | ||
|
|
2aa636409a |
@@ -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
|
|
||||||
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 24 KiB |
41
main.go
41
main.go
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user