Compare commits

..

2 commits

Author SHA1 Message Date
1e99
9fe27528bb document installation 2024-10-30 17:05:12 +01:00
1e99
154a739eff allow usage of custom clear interval 2024-10-30 16:57:52 +01:00
2 changed files with 37 additions and 1 deletions

View file

@ -19,3 +19,26 @@ When you create a password URL, PassED firstly encrypts the password in your bro
When someone views the password, PassED looks at the URL. It knows the password ID, AES Key and IV. It reaches out to the server, asks for a password with the ID from the URL, and then decrypts it with the AES Key and IV. When someone views the password, PassED looks at the URL. It knows the password ID, AES Key and IV. It reaches out to the server, asks for a password with the ID from the URL, and then decrypts it with the AES Key and IV.
This model ensures that a malicous host can not read the passwords. This model ensures that a malicous host can not read the passwords.
## Installation
Installation is done with docker compose.
```yaml
services:
"passed":
build: "https://git.1e99.eu/1e99/passed.git"
volumes:
- "./passed:/etc/passed"
environment:
- "PASSED_STORE_TYPE=dir"
- "PASSED_STORE_DIR_PATH=/etc/passed"
ports:
- "3000:3000"
```
## Configuration
Configuration is done with environment variables.
- `PASSED_ADDRESS`: Specifies the address that PassED should listen on, defaults to `:3000`
- `PASSED_STORE_TYPE`: Specify which store to use to save passwords, defaults to `ram`:
- `ram`: Stores all passwords in RAM, they are lost on restart
- `dir`: Stores all passwords in a directory. Requires `PASSED_STORE_DIR_PATH` to be set to the directory, defaults to `passwords`. PassED will not create the directory.
- `STORE_CLEAR_EXPIRED_INTERVAL`: Specifies the delay in seconds to wait between clearing expired passwords, defaults to `30`.

15
main.go
View file

@ -6,6 +6,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"strconv"
"time" "time"
"git.1e99.eu/1e99/passed/middlewares" "git.1e99.eu/1e99/passed/middlewares"
@ -22,8 +23,20 @@ func run() error {
return err return err
} }
clearIntervalString := os.Getenv("STORE_CLEAR_EXPIRED_INTERVAL")
if clearIntervalString == "" {
log.Printf("No STORE_CLEAR_EXPIRED_INTERVAL provided, defaulting to 30 seconds.")
clearIntervalString = "30"
}
clearInterval, err := strconv.ParseInt(clearIntervalString, 10, 64)
if err != nil {
log.Printf("STORE_CLEAR_EXPIRED_INTERVAL is not a number.")
clearInterval = 30
}
go func() { go func() {
ticker := time.Tick(20 * time.Second) ticker := time.Tick(time.Duration(clearInterval) * time.Second)
for { for {
<-ticker <-ticker