package route import ( "net/http" "forge.cadoles.com/Cadoles/daddy/internal/config" oidc "forge.cadoles.com/wpetit/goweb-oidc" "gitlab.com/wpetit/goweb/logger" "gitlab.com/wpetit/goweb/middleware/container" ) func handleLogin(w http.ResponseWriter, r *http.Request) { ctn := container.Must(r.Context()) client := oidc.Must(ctn) client.Login(w, r) } func handleLoginCallback(w http.ResponseWriter, r *http.Request) { ctx := r.Context() ctn := container.Must(ctx) conf := config.Must(ctn) idToken, err := oidc.IDToken(w, r) if err != nil { logger.Error(ctx, "could not retrieve idToken", logger.E(err)) http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) return } logger.Info(ctx, "user logged in", logger.F("sub", idToken.Subject)) http.Redirect(w, r, conf.HTTP.FrontendURL, http.StatusSeeOther) }