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 |
177
main.go
177
main.go
@@ -9,8 +9,22 @@ import (
|
||||
|
||||
const (
|
||||
passwordLength = 32
|
||||
// Zeichensatz mit 62 möglichen Zeichen pro Position
|
||||
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 {
|
||||
@@ -32,82 +46,95 @@ func passwordHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, password)
|
||||
}
|
||||
|
||||
// new help handler
|
||||
func helpHandler(w http.ResponseWriter, r *http.Request) {
|
||||
helpHTML := `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Hilfe</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Helvetica Neue', Arial, sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
background-color: #f5f5f5;
|
||||
color: #333;
|
||||
}
|
||||
.help-container {
|
||||
text-align: left;
|
||||
background: white;
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
max-width: 800px;
|
||||
width: 90%;
|
||||
min-width: 600px;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
color: #444;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
background: #f0f0f0;
|
||||
padding: 0.8rem;
|
||||
border-radius: 4px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
a {
|
||||
color: #007BFF;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="help-container">
|
||||
<h1>Hilfe: API-Endpunkt</h1>
|
||||
<p>
|
||||
Diese Anwendung bietet einen API-Endpunkt, um Passwörter direkt über die Kommandozeile abzurufen.
|
||||
Der Endpunkt gibt das Passwort im Plain-Text-Format zurück.
|
||||
</p>
|
||||
<h2>Endpunkt:</h2>
|
||||
<p><code>http://localhost:8080/api/password</code></p>
|
||||
<h2>Beispiele:</h2>
|
||||
<h3>Mac/Linux (Terminal):</h3>
|
||||
<pre>echo $(curl -s http://localhost:8080/api/password)</pre>
|
||||
<h3>Windows (PowerShell):</h3>
|
||||
<pre>Invoke-RestMethod -Uri http://localhost:8080/api/password</pre>
|
||||
<h3>Windows (cmd):</h3>
|
||||
<pre>curl http://localhost:8080/api/password</pre>
|
||||
<p>
|
||||
<a href="/">Zurück zur Passwort-Generierung</a>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
fmt.Fprint(w, helpHTML)
|
||||
helpHTML := `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Hilfe</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Helvetica Neue', Arial, sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
background-color: #f5f5f5;
|
||||
color: #333;
|
||||
}
|
||||
.help-container {
|
||||
text-align: left;
|
||||
background: white;
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
max-width: 800px;
|
||||
width: 90%;
|
||||
min-width: 500px;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
color: #444;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
background: #f0f0f0;
|
||||
padding: 0.8rem;
|
||||
border-radius: 4px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
a {
|
||||
color: #007BFF;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="help-container">
|
||||
<h1>Hilfe: API-Endpunkt</h1>
|
||||
<p>
|
||||
Diese Anwendung bietet einen API-Endpunkt, um Passwörter direkt über die Kommandozeile abzurufen.
|
||||
Der Endpunkt gibt das Passwort im Plain-Text-Format zurück.
|
||||
</p>
|
||||
<h2>Endpunkt:</h2>
|
||||
<p><code id="api-endpoint"></code></p>
|
||||
<h2>Beispiele:</h2>
|
||||
<h3>Mac/Linux (Terminal):</h3>
|
||||
<pre id="curl-example"></pre>
|
||||
<h3>Windows (PowerShell):</h3>
|
||||
<pre id="powershell-example"></pre>
|
||||
<h3>Windows (cmd):</h3>
|
||||
<pre id="cmd-example"></pre>
|
||||
<p>
|
||||
<a href="/">Zurück zur Passwort-Generierung</a>
|
||||
</p>
|
||||
</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>
|
||||
</html>
|
||||
`
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
fmt.Fprint(w, helpHTML)
|
||||
}
|
||||
|
||||
|
||||
func webHandler(w http.ResponseWriter, r *http.Request) {
|
||||
password := generatePassword()
|
||||
html := fmt.Sprintf(
|
||||
@@ -134,7 +161,7 @@ html := fmt.Sprintf(
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
width: 90%%;
|
||||
min-width: 600px;
|
||||
min-width: 500px;
|
||||
position: relative;
|
||||
}
|
||||
h1 {
|
||||
|
||||
Reference in New Issue
Block a user