Skip to content

Commit

Permalink
revert code
Browse files Browse the repository at this point in the history
  • Loading branch information
hexaforce committed Feb 26, 2025
1 parent 9fcd7b2 commit 3a07893
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
18 changes: 5 additions & 13 deletions server/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,22 @@ func initEcho(ctx context.Context, cfg *ServerConfig) *echo.Echo {
}

// auth
authConfig := cfg.Config.JWTProviders()
log.Infof("auth: config: %#v", authConfig)

var wrapHandler func(http.Handler) http.Handler
if cfg.Config.UseMockAuth() {
log.Infof("Using mock auth for local development")
wrapHandler = func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

ctx := r.Context()
ctx = adapter.AttachMockAuth(ctx, true)
next.ServeHTTP(w, r.WithContext(ctx))
})
}
} else {
authConfig := cfg.Config.JWTProviders()
log.Infof("auth: config: %#v", authConfig)
if cfg.Config.AuthSrv.Disabled {
wrapHandler = lo.Must(AuthMiddlewareDummy())
} else {
wrapHandler = lo.Must(appx.AuthMiddleware(authConfig, adapter.ContextAuthInfo, true))
}
wrapHandler = lo.Must(appx.AuthMiddleware(authConfig, adapter.ContextAuthInfo, true))
}

e.Use(echo.WrapMiddleware(wrapHandler))
Expand Down Expand Up @@ -161,12 +159,6 @@ func initEcho(ctx context.Context, cfg *ServerConfig) *echo.Echo {
return e
}

func AuthMiddlewareDummy() (func(http.Handler) http.Handler, error) {
return func(next http.Handler) http.Handler {
return next
}, nil
}

func errorHandler(next func(error, echo.Context)) func(error, echo.Context) {
return func(err error, c echo.Context) {
if c.Response().Committed {
Expand Down
8 changes: 2 additions & 6 deletions server/internal/app/auth_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,15 @@ func attachOpMiddleware(cfg *ServerConfig) echo.MiddlewareFunc {

if u != nil {
ctx = adapter.AttachUser(ctx, u)
if u.Name() != "e2e" {
log.Debugfc(ctx, "auth: user: id=%s name=%s email=%s", u.ID(), u.Name(), u.Email())
}
log.Debugfc(ctx, "auth: user: id=%s name=%s email=%s", u.ID(), u.Name(), u.Email())

op, err := generateOperator(ctx, cfg, u)
if err != nil {
return err
}

ctx = adapter.AttachOperator(ctx, op)
if u.Name() != "e2e" {
log.Debugfc(ctx, "auth: op: %#v", op)
}
log.Debugfc(ctx, "auth: op: %#v", op)
}

ctx = adapter.AttachCurrentHost(ctx, cfg.Config.Host)
Expand Down

0 comments on commit 3a07893

Please sign in to comment.