Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
623cfd3a50 | ||
|
|
2f9ee42071 | ||
| 33fe4b2b80 | |||
| 21f512c2d7 | |||
| dfda16f8e1 | |||
| 44bb35abac | |||
| 1ae5f9c679 | |||
| 9a052b3ef7 | |||
| 9a906ec55c | |||
| 8b93585422 | |||
| 59dd16d4ac | |||
| d7678274be | |||
| 4a8f7525e7 | |||
| fb55f47e5c | |||
| 0251b9dc69 | |||
| 2b505b0d9d | |||
| cb3545f261 | |||
| d673b97b4b | |||
| 1be4aeb6b8 |
@@ -14,8 +14,8 @@ jobs:
|
|||||||
- name: Login to Gitea
|
- name: Login to Gitea
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.REGISTRY_URL }} # gitea.scu.si
|
registry: ${{ vars.REGISTRY_URL }} # gitea.scu.si
|
||||||
username: ${{ gitea.actor }}
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
@@ -26,5 +26,5 @@ jobs:
|
|||||||
# Hier wird die Git-Referenz automatisch als Docker-Tag genutzt
|
# Hier wird die Git-Referenz automatisch als Docker-Tag genutzt
|
||||||
#tags: gitea.scu.si/florianwalther/password-generator:${{ gitea.ref_name }}
|
#tags: gitea.scu.si/florianwalther/password-generator:${{ gitea.ref_name }}
|
||||||
tags: |
|
tags: |
|
||||||
gitea.scu.si/florianwalther/password-generator:${{ gitea.ref_name }}
|
gitea.scu.si/florian.walther/password-generator:${{ gitea.ref_name }}
|
||||||
gitea.scu.si/florianwalther/password-generator:latest
|
gitea.scu.si/florian.walther/password-generator:latest
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Web-Password
|
# Web-Password
|
||||||
|
|
||||||
_a web based password generator_
|
_a web based password generator, with an API endpoint_
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -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/florian.walther/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)
|
||||||
|
|||||||
659
main.go
659
main.go
@@ -42,100 +42,267 @@ func generatePassword() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func passwordHandler(w http.ResponseWriter, r *http.Request) {
|
func passwordHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Printf("APIHandler called from %s\n", r.RemoteAddr)
|
||||||
password := generatePassword()
|
password := generatePassword()
|
||||||
fmt.Fprint(w, password)
|
fmt.Fprint(w, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
// new help handler
|
// new help handler
|
||||||
func helpHandler(w http.ResponseWriter, r *http.Request) {
|
func helpHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
helpHTML := `
|
log.Printf("helpHandler called from %s\n", r.RemoteAddr)
|
||||||
<!DOCTYPE html>
|
helpHTML := `
|
||||||
<html>
|
<!DOCTYPE html>
|
||||||
<head>
|
<html>
|
||||||
<title>Hilfe</title>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<title>Hilfe</title>
|
||||||
<style>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
body {
|
<style>
|
||||||
font-family: 'Helvetica Neue', Arial, sans-serif;
|
:root {
|
||||||
display: flex;
|
--bg-color: #f5f5f5;
|
||||||
justify-content: center;
|
--text-color: #333;
|
||||||
align-items: center;
|
--container-bg: white;
|
||||||
height: 100vh;
|
--button-bg: #007BFF;
|
||||||
margin: 0;
|
--button-hover: #0056b3;
|
||||||
background-color: #f5f5f5;
|
--copy-button-bg: #4CAF50;
|
||||||
color: #333;
|
--copy-button-hover: #45a049;
|
||||||
}
|
--password-bg: #f0f0f0;
|
||||||
.help-container {
|
--border-color: #ddd;
|
||||||
text-align: left;
|
--shadow-color: rgba(0, 0, 0, 0.1);
|
||||||
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
|
@media (prefers-color-scheme: dark) {
|
||||||
document.getElementById("api-endpoint").textContent = apiEndpoint;
|
:root {
|
||||||
document.getElementById("curl-example").textContent = "curl " + apiEndpoint;
|
--bg-color: #121212;
|
||||||
document.getElementById("powershell-example").textContent = "Invoke-RestMethod -Uri " + apiEndpoint;
|
--text-color: #e0e0e0;
|
||||||
document.getElementById("cmd-example").textContent = "curl " + apiEndpoint;
|
--container-bg: #1e1e1e;
|
||||||
</script>
|
--button-bg: #2a7df4;
|
||||||
</body>
|
--button-hover: #1a5fb4;
|
||||||
</html>
|
--copy-button-bg: #4caf60;
|
||||||
`
|
--copy-button-hover: #3d8b40;
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
--password-bg: #2d2d2d;
|
||||||
fmt.Fprint(w, helpHTML)
|
--border-color: #444;
|
||||||
|
--shadow-color: rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
background-color: var(--bg-color);
|
||||||
|
color: var(--text-color);
|
||||||
|
transition: background-color 0.3s, color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
text-align: center;
|
||||||
|
background: var(--container-bg);
|
||||||
|
padding: 2rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 10px var(--shadow-color);
|
||||||
|
width: 90%;
|
||||||
|
min-width: 600px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
#password {
|
||||||
|
font-family: 'Courier New', Courier, monospace;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
margin: 1rem auto;
|
||||||
|
padding: 0.8rem;
|
||||||
|
background: var(--password-bg);
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
width: 90%;
|
||||||
|
word-break: break-all;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.copy-button {
|
||||||
|
background: var(--copy-button-bg);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 0.6rem 1.2rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s;
|
||||||
|
margin: 0.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copy-button:hover {
|
||||||
|
background: var(--copy-button-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.renew-button {
|
||||||
|
background: var(--button-bg);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 0.6rem 1.2rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s;
|
||||||
|
margin: 0.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.renew-button:hover {
|
||||||
|
background: var(--button-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-link {
|
||||||
|
position: absolute;
|
||||||
|
top: 1rem;
|
||||||
|
right: 1rem;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: var(--text-color);
|
||||||
|
opacity: 0.7;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-link:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#toast {
|
||||||
|
visibility: hidden;
|
||||||
|
min-width: 150px;
|
||||||
|
background-color: var(--copy-button-bg);
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0.5rem;
|
||||||
|
position: fixed;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
z-index: 1;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
box-shadow: 0 2px 10px var(--shadow-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-container {
|
||||||
|
text-align: left;
|
||||||
|
background: var(--container-bg);
|
||||||
|
padding: 2rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 10px var(--shadow-color);
|
||||||
|
max-width: 800px;
|
||||||
|
width: 90%;
|
||||||
|
min-width: 600px;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
font-family: 'Courier New', Courier, monospace;
|
||||||
|
background: var(--password-bg);
|
||||||
|
padding: 0.8rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--text-color);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: var(--button-bg);
|
||||||
|
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>
|
||||||
|
<script>
|
||||||
|
// Darkmode-Toggle-Funktion (optional)
|
||||||
|
function toggleDarkMode() {
|
||||||
|
const root = document.documentElement;
|
||||||
|
const isDark = root.style.getPropertyValue('--bg-color') === 'rgb(18, 18, 18)';
|
||||||
|
if (isDark) {
|
||||||
|
// Zu Lightmode wechseln
|
||||||
|
root.style.setProperty('--bg-color', '#f5f5f5');
|
||||||
|
root.style.setProperty('--text-color', '#333');
|
||||||
|
root.style.setProperty('--container-bg', 'white');
|
||||||
|
root.style.setProperty('--button-bg', '#007BFF');
|
||||||
|
root.style.setProperty('--button-hover', '#0056b3');
|
||||||
|
root.style.setProperty('--copy-button-bg', '#4CAF50');
|
||||||
|
root.style.setProperty('--copy-button-hover', '#45a049');
|
||||||
|
root.style.setProperty('--password-bg', '#f0f0f0');
|
||||||
|
root.style.setProperty('--border-color', '#ddd');
|
||||||
|
root.style.setProperty('--shadow-color', 'rgba(0, 0, 0, 0.1)');
|
||||||
|
localStorage.setItem('theme', 'light');
|
||||||
|
} else {
|
||||||
|
// Zu Darkmode wechseln
|
||||||
|
root.style.setProperty('--bg-color', '#121212');
|
||||||
|
root.style.setProperty('--text-color', '#e0e0e0');
|
||||||
|
root.style.setProperty('--container-bg', '#1e1e1e');
|
||||||
|
root.style.setProperty('--button-bg', '#2a7df4');
|
||||||
|
root.style.setProperty('--button-hover', '#1a5fb4');
|
||||||
|
root.style.setProperty('--copy-button-bg', '#4caf60');
|
||||||
|
root.style.setProperty('--copy-button-hover', '#3d8b40');
|
||||||
|
root.style.setProperty('--password-bg', '#2d2d2d');
|
||||||
|
root.style.setProperty('--border-color', '#444');
|
||||||
|
root.style.setProperty('--shadow-color', 'rgba(0, 0, 0, 0.3)');
|
||||||
|
localStorage.setItem('theme', 'dark');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prüfe, ob Nutzer eine manuelle Einstellung gespeichert hat
|
||||||
|
if (localStorage.getItem('theme') === 'dark') {
|
||||||
|
toggleDarkMode();
|
||||||
|
} else if (localStorage.getItem('theme') === 'light') {
|
||||||
|
// Stelle sicher, dass Lightmode aktiv ist (falls Systemtheme dark ist)
|
||||||
|
document.documentElement.style.setProperty('--bg-color', '#f5f5f5');
|
||||||
|
document.documentElement.style.setProperty('--text-color', '#333');
|
||||||
|
document.documentElement.style.setProperty('--container-bg', 'white');
|
||||||
|
document.documentElement.style.setProperty('--button-bg', '#007BFF');
|
||||||
|
document.documentElement.style.setProperty('--button-hover', '#0056b3');
|
||||||
|
document.documentElement.style.setProperty('--copy-button-bg', '#4CAF50');
|
||||||
|
document.documentElement.style.setProperty('--copy-button-hover', '#45a049');
|
||||||
|
document.documentElement.style.setProperty('--password-bg', '#f0f0f0');
|
||||||
|
document.documentElement.style.setProperty('--border-color', '#ddd');
|
||||||
|
document.documentElement.style.setProperty('--shadow-color', 'rgba(0, 0, 0, 0.1)');
|
||||||
|
}
|
||||||
|
</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) {
|
func webHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Printf("webHandler called from %s\n", r.RemoteAddr)
|
||||||
password := generatePassword()
|
password := generatePassword()
|
||||||
html := fmt.Sprintf(
|
html := fmt.Sprintf(
|
||||||
`<DOCTYPE html>
|
`<DOCTYPE html>
|
||||||
@@ -143,119 +310,176 @@ html := fmt.Sprintf(
|
|||||||
<head>
|
<head>
|
||||||
<title>Passwort-Generator</title>
|
<title>Passwort-Generator</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<style>
|
<style>
|
||||||
body {
|
:root {
|
||||||
font-family: 'Helvetica Neue', Arial, sans-serif;
|
--bg-color: #f5f5f5;
|
||||||
display: flex;
|
--text-color: #333;
|
||||||
justify-content: center;
|
--container-bg: white;
|
||||||
align-items: center;
|
--button-bg: #007BFF;
|
||||||
height: 100vh;
|
--button-hover: #0056b3;
|
||||||
margin: 0;
|
--copy-button-bg: #4CAF50;
|
||||||
background-color: #f5f5f5;
|
--copy-button-hover: #45a049;
|
||||||
color: #333;
|
--password-bg: #f0f0f0;
|
||||||
}
|
--border-color: #ddd;
|
||||||
.container {
|
--shadow-color: rgba(0, 0, 0, 0.1);
|
||||||
text-align: center;
|
}
|
||||||
background: white;
|
|
||||||
padding: 2rem;
|
@media (prefers-color-scheme: dark) {
|
||||||
border-radius: 8px;
|
:root {
|
||||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
--bg-color: #121212;
|
||||||
width: 90%%;
|
--text-color: #e0e0e0;
|
||||||
min-width: 500px;
|
--container-bg: #1e1e1e;
|
||||||
position: relative;
|
--button-bg: #2a7df4;
|
||||||
}
|
--button-hover: #1a5fb4;
|
||||||
h1 {
|
--copy-button-bg: #4caf60;
|
||||||
font-size: 1.5rem;
|
--copy-button-hover: #3d8b40;
|
||||||
margin-bottom: 1.5rem;
|
--password-bg: #2d2d2d;
|
||||||
color: #444;
|
--border-color: #444;
|
||||||
}
|
--shadow-color: rgba(0, 0, 0, 0.3);
|
||||||
#password {
|
}
|
||||||
font-family: 'Courier New', Courier, monospace;
|
}
|
||||||
font-size: 1.2rem;
|
|
||||||
letter-spacing: 1px;
|
body {
|
||||||
margin: 1rem auto;
|
font-family: 'Helvetica Neue', Arial, sans-serif;
|
||||||
padding: 0.8rem;
|
display: flex;
|
||||||
background: #f0f0f0;
|
justify-content: center;
|
||||||
border-radius: 4px;
|
align-items: center;
|
||||||
border: 1px solid #ddd;
|
height: 100vh;
|
||||||
width: 90%%;
|
margin: 0;
|
||||||
word-break: break-all;
|
background-color: var(--bg-color);
|
||||||
}
|
color: var(--text-color);
|
||||||
.copy-button {
|
transition: background-color 0.3s, color 0.3s;
|
||||||
background: #4CAF50;
|
}
|
||||||
color: white;
|
|
||||||
border: none;
|
.container {
|
||||||
padding: 0.6rem 1.2rem;
|
text-align: center;
|
||||||
font-size: 1rem;
|
background: var(--container-bg);
|
||||||
border-radius: 4px;
|
padding: 2rem;
|
||||||
cursor: pointer;
|
border-radius: 8px;
|
||||||
transition: background 0.2s;
|
box-shadow: 0 2px 10px var(--shadow-color);
|
||||||
margin: 0.3rem;
|
width: 90%;
|
||||||
}
|
min-width: 600px;
|
||||||
.copy-button:hover {
|
position: relative;
|
||||||
background: #45a049;
|
}
|
||||||
}
|
|
||||||
.renew-button {
|
h1 {
|
||||||
background: #007BFF;
|
font-size: 1.5rem;
|
||||||
color: white;
|
margin-bottom: 1.5rem;
|
||||||
border: none;
|
color: var(--text-color);
|
||||||
padding: 0.6rem 1.2rem;
|
}
|
||||||
font-size: 1rem;
|
|
||||||
border-radius: 4px;
|
#password {
|
||||||
cursor: pointer;
|
font-family: 'Courier New', Courier, monospace;
|
||||||
transition: background 0.2s;
|
font-size: 1.2rem;
|
||||||
margin: 0.3rem;
|
letter-spacing: 1px;
|
||||||
}
|
margin: 1rem auto;
|
||||||
.renew-button:hover {
|
padding: 0.8rem;
|
||||||
background: #0056b3;
|
background: var(--password-bg);
|
||||||
}
|
border-radius: 4px;
|
||||||
.about-link {
|
border: 1px solid var(--border-color);
|
||||||
position: absolute;
|
width: 90%;
|
||||||
top: 1rem;
|
word-break: break-all;
|
||||||
left: 1rem;
|
color: var(--text-color);
|
||||||
font-size: 1.2rem;
|
}
|
||||||
color: #999;
|
|
||||||
text-decoration: none;
|
.copy-button {
|
||||||
}
|
background: var(--copy-button-bg);
|
||||||
.about-link:hover {
|
color: white;
|
||||||
color: #444;
|
border: none;
|
||||||
}
|
padding: 0.6rem 1.2rem;
|
||||||
.help-link {
|
font-size: 1rem;
|
||||||
position: absolute;
|
border-radius: 4px;
|
||||||
top: 1rem;
|
cursor: pointer;
|
||||||
right: 1rem;
|
transition: background 0.2s;
|
||||||
font-size: 1.2rem;
|
margin: 0.3rem;
|
||||||
color: #999;
|
}
|
||||||
text-decoration: none;
|
|
||||||
}
|
.copy-button:hover {
|
||||||
.help-link:hover {
|
background: var(--copy-button-hover);
|
||||||
color: #444;
|
}
|
||||||
}
|
|
||||||
.buttons {
|
.renew-button {
|
||||||
display: flex;
|
background: var(--button-bg);
|
||||||
justify-content: center;
|
color: white;
|
||||||
gap: 0.5rem;
|
border: none;
|
||||||
}
|
padding: 0.6rem 1.2rem;
|
||||||
#toast {
|
font-size: 1rem;
|
||||||
visibility: hidden;
|
border-radius: 4px;
|
||||||
min-width: 150px;
|
cursor: pointer;
|
||||||
background-color: #4CAF50;
|
transition: background 0.2s;
|
||||||
color: white;
|
margin: 0.3rem;
|
||||||
text-align: center;
|
}
|
||||||
border-radius: 4px;
|
|
||||||
padding: 0.5rem;
|
.renew-button:hover {
|
||||||
position: fixed;
|
background: var(--button-hover);
|
||||||
top: 20px;
|
}
|
||||||
right: 20px;
|
|
||||||
z-index: 1;
|
.help-link {
|
||||||
font-size: 0.9rem;
|
position: absolute;
|
||||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
top: 1rem;
|
||||||
}
|
right: 1rem;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: var(--text-color);
|
||||||
|
opacity: 0.7;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-link:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#toast {
|
||||||
|
visibility: hidden;
|
||||||
|
min-width: 150px;
|
||||||
|
background-color: var(--copy-button-bg);
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0.5rem;
|
||||||
|
position: fixed;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
z-index: 1;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
box-shadow: 0 2px 10px var(--shadow-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-container {
|
||||||
|
text-align: left;
|
||||||
|
background: var(--container-bg);
|
||||||
|
padding: 2rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 10px var(--shadow-color);
|
||||||
|
max-width: 800px;
|
||||||
|
width: 90%;
|
||||||
|
min-width: 600px;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
font-family: 'Courier New', Courier, monospace;
|
||||||
|
background: var(--password-bg);
|
||||||
|
padding: 0.8rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--text-color);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: var(--button-bg);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a href="/help" class="help-link">API</a>
|
<a href="/help" class="help-link">API</a>
|
||||||
|
<button onclick="toggleDarkMode()" style="position: absolute; top: 1rem; left: 1rem; background: transparent; border: none; color: var(--text-color); font-size: 1.2rem; cursor: pointer;">🌓</button>
|
||||||
|
|
||||||
<a class="about-link" href="https://gitea.scu.si/FlorianWalther/Web-Password">code</a>
|
<a class="about-link" href="https://gitea.scu.si/FlorianWalther/Web-Password">code</a>
|
||||||
<h1>Generiertes Passwort</h1>
|
<h1>Generiertes Passwort</h1>
|
||||||
<div id="password">%s</div>
|
<div id="password">%s</div>
|
||||||
@@ -288,6 +512,58 @@ html := fmt.Sprintf(
|
|||||||
.catch(error => console.error("Fehler:", error));
|
.catch(error => console.error("Fehler:", error));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
// Darkmode-Toggle-Funktion (optional)
|
||||||
|
function toggleDarkMode() {
|
||||||
|
const root = document.documentElement;
|
||||||
|
const isDark = root.style.getPropertyValue('--bg-color') === 'rgb(18, 18, 18)';
|
||||||
|
if (isDark) {
|
||||||
|
// Zu Lightmode wechseln
|
||||||
|
root.style.setProperty('--bg-color', '#f5f5f5');
|
||||||
|
root.style.setProperty('--text-color', '#333');
|
||||||
|
root.style.setProperty('--container-bg', 'white');
|
||||||
|
root.style.setProperty('--button-bg', '#007BFF');
|
||||||
|
root.style.setProperty('--button-hover', '#0056b3');
|
||||||
|
root.style.setProperty('--copy-button-bg', '#4CAF50');
|
||||||
|
root.style.setProperty('--copy-button-hover', '#45a049');
|
||||||
|
root.style.setProperty('--password-bg', '#f0f0f0');
|
||||||
|
root.style.setProperty('--border-color', '#ddd');
|
||||||
|
root.style.setProperty('--shadow-color', 'rgba(0, 0, 0, 0.1)');
|
||||||
|
localStorage.setItem('theme', 'light');
|
||||||
|
} else {
|
||||||
|
// Zu Darkmode wechseln
|
||||||
|
root.style.setProperty('--bg-color', '#121212');
|
||||||
|
root.style.setProperty('--text-color', '#e0e0e0');
|
||||||
|
root.style.setProperty('--container-bg', '#1e1e1e');
|
||||||
|
root.style.setProperty('--button-bg', '#2a7df4');
|
||||||
|
root.style.setProperty('--button-hover', '#1a5fb4');
|
||||||
|
root.style.setProperty('--copy-button-bg', '#4caf60');
|
||||||
|
root.style.setProperty('--copy-button-hover', '#3d8b40');
|
||||||
|
root.style.setProperty('--password-bg', '#2d2d2d');
|
||||||
|
root.style.setProperty('--border-color', '#444');
|
||||||
|
root.style.setProperty('--shadow-color', 'rgba(0, 0, 0, 0.3)');
|
||||||
|
localStorage.setItem('theme', 'dark');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prüfe, ob Nutzer eine manuelle Einstellung gespeichert hat
|
||||||
|
if (localStorage.getItem('theme') === 'dark') {
|
||||||
|
toggleDarkMode();
|
||||||
|
} else if (localStorage.getItem('theme') === 'light') {
|
||||||
|
// Stelle sicher, dass Lightmode aktiv ist (falls Systemtheme dark ist)
|
||||||
|
document.documentElement.style.setProperty('--bg-color', '#f5f5f5');
|
||||||
|
document.documentElement.style.setProperty('--text-color', '#333');
|
||||||
|
document.documentElement.style.setProperty('--container-bg', 'white');
|
||||||
|
document.documentElement.style.setProperty('--button-bg', '#007BFF');
|
||||||
|
document.documentElement.style.setProperty('--button-hover', '#0056b3');
|
||||||
|
document.documentElement.style.setProperty('--copy-button-bg', '#4CAF50');
|
||||||
|
document.documentElement.style.setProperty('--copy-button-hover', '#45a049');
|
||||||
|
document.documentElement.style.setProperty('--password-bg', '#f0f0f0');
|
||||||
|
document.documentElement.style.setProperty('--border-color', '#ddd');
|
||||||
|
document.documentElement.style.setProperty('--shadow-color', 'rgba(0, 0, 0, 0.1)');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>`,
|
</html>`,
|
||||||
password,
|
password,
|
||||||
@@ -305,4 +581,3 @@ func main() {
|
|||||||
log.Println("Plain-Text-Passwort: curl http://localhost:8080/api/password")
|
log.Println("Plain-Text-Passwort: curl http://localhost:8080/api/password")
|
||||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,66 @@
|
|||||||
|
## 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.
|
||||||
|
|
||||||
|
## get 10 fresh passwords
|
||||||
|
|
||||||
|
```bash
|
||||||
|
for i in {1..10}; do echo $(curl -s https://passwd.scu.si/api/password); done
|
||||||
|
```
|
||||||
|
|
||||||
|
# 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 +76,12 @@ 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 up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user