mirror of
https://github.com/vcscsvcscs/GenerationsHeritage.git
synced 2025-08-15 23:39:05 +02:00
backend remove auth
This commit is contained in:
@@ -4,20 +4,16 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/zitadel/zitadel-go/v3/pkg/authorization/oauth"
|
||||
"github.com/zitadel/zitadel-go/v3/pkg/http/middleware"
|
||||
)
|
||||
|
||||
func auth(mw *middleware.Interceptor[*oauth.IntrospectionContext]) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
mw.RequireAuthorization()(http.HandlerFunc(authHTTPHandler(mw, c))).ServeHTTP(c.Writer, c.Request)
|
||||
func auth(c *gin.Context) {
|
||||
id := c.Request.Header.Get("id")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "no id provided"})
|
||||
c.Abort()
|
||||
}
|
||||
}
|
||||
|
||||
func authHTTPHandler(mw *middleware.Interceptor[*oauth.IntrospectionContext], c *gin.Context) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
authCtx := mw.Context(r.Context())
|
||||
c.Set("id", authCtx.UserID())
|
||||
c.Next()
|
||||
}
|
||||
c.Set("id", id)
|
||||
c.Next()
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user