diff --git a/.gitignore b/.gitignore index 0711cb7..f669f17 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # dist -internal/assets/dist \ No newline at end of file +internal/assets/dist + +# binaries +tinyauth \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8d3f8a7 --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +# Tinyauth - The easiest way to secure your traefik apps with a login screen + +Tinyauth is an extremely simple traefik forward auth proxy that adds a login screen to all of your apps that are using the traefik reverse proxy. Tinyauth is configurable through environment variables and it is only 20MB in size. + +## Screenshots + +Talk is cheap, here are some screenshots: + +| | | +| --------------------------------------- | ----------------------------------------- | +|  |  | +|  |  | + +## Getting started + +Tinyauth is extremely easy to run since it's shipped as a docker container. I chose to bundle it with busybox so as you can easily debug the API (e.g. using curl) and have some simple linux tools. If you want to get started with an example just check the example docker compose file [here](./docker-compose.example.yml) + +## Environment variables + +Tinyauth accepts the following environment variables: + +| Name | Description | Default | Required | +| ---------- | ------------------------------------------------------- | ------- | -------- | +| `PORT` | The port the API listens on. | 3000 | no | +| `ADDRESS` | The address the API binds on. | 0.0.0.0 | no | +| `SECRET` | A 32 character long string used for the sessions. | - | yes | +| `ROOT_URL` | The base URL of your domain. (e.g. https://example.com) | - | yes | +| `APP_URL` | The Tinyauth URL. (e.g. https://tinyauth.example.com) | - | yes | +| `USERS` | Comma seperated list of `user:bcrypt-password-hash`. | - | yes | + +## FAQ + +### Why? + +Why make this project? Well we all know that more powerful alternatives like authentik and authelia exist but when I tried to use them I felt overwhelmed with all the configration options and environment variables I had to configure in order for them to work, so, I decided to make a small alternative in Go to both test my skills and cover my simple login screen needs. + +## Is this secure? + +Probably, the sessions are managed with the gin sessions package so it should be very secure. It is definitely not made for production but it could easily serve as a simple login screen to all of your homelab apps. + +## Do I need to login every time? + +No, when you login tinyauth sets a `tinyauth` cookie in your browser that applies to all of the subdomains of the root URL you set. + +## License + +Tinyauth is licensed under the GNU General Public License v3.0. TL;DR — You may copy, distribute and modify the software as long as you track changes/dates in source files. Any modifications to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions. + +## Contributing + +Any contributions to the codebase are welcome! I am not a cybersecurity person so my code may have some vulnerability, if you find something that could be used to exploit and bypass tinyauth please tell me as soon as possible so I can fix it. + +## Acknowledgements + +Credits for the logo go to: + +- Freepik for providing the hat and police badge. +- Renee French for making the gopher logo. diff --git a/assets/logo.xcf b/assets/logo.xcf new file mode 100644 index 0000000..499d9fd Binary files /dev/null and b/assets/logo.xcf differ diff --git a/cmd/root.go b/cmd/root.go index 0c04d6f..e2fd3c2 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -62,7 +62,7 @@ func HandleError(err error, msg string) { func init() { viper.AutomaticEnv() - rootCmd.Flags().IntP("port", "p", 8080, "Port to run the server on.") + rootCmd.Flags().IntP("port", "p", 3000, "Port to run the server on.") rootCmd.Flags().String("address", "0.0.0.0", "Address to bind the server to.") rootCmd.Flags().String("secret", "", "Secret to use for the cookie.") rootCmd.Flags().String("root-url", "", "Root URL of traefik.") diff --git a/docker-compose.yml b/docker-compose.example.yml similarity index 73% rename from docker-compose.yml rename to docker-compose.example.yml index 592938e..f4bfcb8 100644 --- a/docker-compose.yml +++ b/docker-compose.example.yml @@ -5,7 +5,6 @@ services: command: --api.insecure=true --providers.docker ports: - 80:80 - - 8080:8080 volumes: - /var/run/docker.sock:/var/run/docker.sock labels: @@ -14,8 +13,6 @@ services: nginx: container_name: nginx image: nginx:latest - ports: - - 8000:80 labels: traefik.enable: true traefik.http.routers.nginx.rule: Host(`nginx.dev.local`) @@ -24,18 +21,12 @@ services: tinyauth: container_name: tinyauth - build: - context: . - dockerfile: Dockerfile - ports: - - 3000:3000 + image: ghcr.io/steveiliop56/tinyauth:latest environment: - - PORT=3000 - - ADDRESS=0.0.0.0 - - SECRET=ghDaPuDFjvlBuF93zcacFrDiHFHTZhUh - - ROOT_URL=http://dev.local - - APP_URL=http://tinyauth.dev.local - - USERS=user:$$2a$$10$$UdLYoJ5lgPsC0RKqYH/jMua7zIn0g9kPqWmhYayJYLaZQ/FTmH2/u + - SECRET=some-random-32-chars-string + - ROOT_URL=https://example.com + - APP_URL=https://tinyauth.example.com + - USERS=user:$$2a$$10$$UdLYoJ5lgPsC0RKqYH/jMua7zIn0g9kPqWmhYayJYLaZQ/FTmH2/u (user:password) labels: traefik.enable: true traefik.http.routers.tinyauth.rule: Host(`tinyauth.dev.local`) diff --git a/screenshots/continue.png b/screenshots/continue.png new file mode 100644 index 0000000..495a678 Binary files /dev/null and b/screenshots/continue.png differ diff --git a/screenshots/login.png b/screenshots/login.png new file mode 100644 index 0000000..61c36ae Binary files /dev/null and b/screenshots/login.png differ diff --git a/screenshots/logout.png b/screenshots/logout.png new file mode 100644 index 0000000..0d80a00 Binary files /dev/null and b/screenshots/logout.png differ diff --git a/screenshots/not-found.png b/screenshots/not-found.png new file mode 100644 index 0000000..58b30c0 Binary files /dev/null and b/screenshots/not-found.png differ diff --git a/site/index.html b/site/index.html index b95c69f..8533651 100644 --- a/site/index.html +++ b/site/index.html @@ -2,8 +2,11 @@
- + + + +