diff --git a/readme.md b/readme.md index 688f46d..a28794c 100644 --- a/readme.md +++ b/readme.md @@ -21,6 +21,7 @@ server { location /auth { proxy_pass http://127.0.0.1:8000; # This is the TOTP Server proxy_set_header X-Original-URI $request_uri; + proxy_set_header X-Real-IP $request_addr; # So we can log attempts by IP } # This ensures that if the TOTP server returns 401 we redirect to login @@ -43,14 +44,20 @@ server { # The rest of the server definition, including SSL and whatnot ``` +If your application already uses /auth then you can change that, as long as you modify the `location` parameter in totpauth.conf during install. ## Additional assembly required: -1. You need to run `main.py` with Python3.5+ in a tmux session or something like supervisord. -2. You should generate a TOTP secret (i.e. `import pyotp; print(pyotp.random_base32())`) and store it in `.totp_secret` alongside `main.py` and also your two factor auth manager of choice (Google Authenticator, Duo, etc.) +1. Create totpauth user, or other user if desired +2. Copy totpauth.py to /opt/totpauth/ or your preferred location, make sure totpauth user can read and execute it +3. Copy totpauth.service to /etc/systemd/system/, update if you're using a different path or totpauth.py location +4. Create /var/log/totpauth/ or some other place to store logs, and ensure the totpauth user can write to it +5. Copy totpauth.conf.example to /etc/totpauth/totpauth.conf, modify it as desired, and make sure totpauth user can read it +6. Generate a TOTP secret using the command below and store it in `/etc/totpauth/secret` (or update totpauth.conf with its correct location), making sure that ONLY the totpauth user can read it ``` python3 -c "import pyotp; print(pyotp.random_base32())" > .totp_secret ``` +7. Import the TOTP secret into your two factor auth manager of choice (Google Authenticator, Duo, etc.) ## FAQ diff --git a/totpauth.conf.example b/totpauth.conf.example new file mode 100644 index 0000000..377a104 --- /dev/null +++ b/totpauth.conf.example @@ -0,0 +1,30 @@ +[TOTP] + +logfile=/var/log/totpauth/totpauth.log +# Log level must be one of DEBUG, INFO, WARNING, ERROR, CRITICAL +loglevel=INFO + +secretfile=/etc/totpauth/secret + +# The totp_window allows codes earlier or later, to account for clock drift and entry time +# For example, a window of 3 will accept a code up to 90 seconds old (assuming 30 second codes) +totp_window=3 + +# These should match the nginx config +port=8000 +location=/auth + +# This should not collide with any cookies your web app sets +cookie_name=totp_token +secure_cookie=true + +# lifetime is in seconds +token_lifetime=86400 + +# A few parameters to make the TOTP landing page your own: +title=Website TOTP Auth + +# This is inserted into the body in a
- +