mirror of
https://github.com/yusing/godoxy.git
synced 2026-01-11 14:20:32 +01:00
[PR #143] [MERGED] Add TinyAuth forward-auth middleware implementation #171
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/yusing/godoxy/pull/143
Author: @FrozenFrog
Created: 9/1/2025
Status: ✅ Merged
Merged: 9/2/2025
Merged by: @yusing
Base:
main← Head:tinyauth-middleware📝 Commits (6)
76d4d41feat: add tinyauth middlewaredcca7efRefactor45a67efadd forward headers06fe9d7refactor(forwardauth): remove unnecessary mutexb8211a3refactor(forwardauth): replace hardcoded http statuses with http constantsa357802refactor(forwardauth): remove hardcoded localhost and port option and construct forwardAuthUrl with route's targetURL📊 Changes
2 files changed (+110 additions, -1 deletions)
View changed files
➕
internal/net/gphttp/middleware/forwardauth.go(+108 -0)📝
internal/net/gphttp/middleware/middlewares.go(+2 -1)📄 Description
This PR adds forward-auth middleware support using TinyAuth’s /api/auth/nginx endpoint.
I have tested the implementation and it works as expected. The video demo below shows the flow in action. In the demo, I used the Cookie-Editor browser extension to delete the tinyauth cookie and then refreshed the page to verify that authentication was properly re-triggered.
🎥 Demo video:
https://github.com/user-attachments/assets/aaa173b9-0c41-48f0-b152-84acdce771f3
Configuration Notes
⚠️ Note: In order to make it work properly, you need to adjust the config.yml by adding the following middleware configuration:
All access control and authorization are handled through TinyAuth’s labels, according to their official documentation.
Request for Feedback
I would really appreciate feedback from @yusing and the community. I am not very experienced with Golang, so any suggestions for improvements are very welcome.
Related Issue
Relate yusing/godoxy#81
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.