feat: tailscale oauth

This commit is contained in:
Stavros
2025-02-01 16:28:39 +02:00
parent 99268f80c9
commit 6e5f882e0b
8 changed files with 244 additions and 53 deletions

View File

@@ -3,6 +3,7 @@ package api
import (
"fmt"
"io/fs"
"math/rand/v2"
"net/http"
"os"
"strings"
@@ -294,6 +295,21 @@ func (api *API) SetupRoutes() {
c.SetCookie("tinyauth_redirect_uri", redirectURI, 3600, "/", api.Domain, api.Config.CookieSecure, true)
}
if request.Provider == "tailscale" {
tailscaleQuery, tailscaleQueryErr := query.Values(types.TailscaleQuery{
Code: (1000 + rand.IntN(9000)), // doesn't need to be secure, just there to avoid caching
})
if handleApiError(c, "Failed to build query", tailscaleQueryErr) {
return
}
c.JSON(200, gin.H{
"status": 200,
"message": "Ok",
"url": fmt.Sprintf("%s/api/oauth/callback/tailscale?%s", api.Config.AppURL, tailscaleQuery.Encode()),
})
return
}
c.JSON(200, gin.H{
"status": 200,
"message": "Ok",