Make google authentication to ersteller-lib

This commit is contained in:
Achim Rohn
2025-09-17 20:58:53 +02:00
parent c4f4c5d637
commit b788fb4898
3 changed files with 62 additions and 32 deletions
+8 -2
View File
@@ -3,6 +3,7 @@ package routes
import (
. "ersteller-lib"
"ersteller-lib/authentication"
google_http "ersteller-lib/authentication/google/http"
"ersteller-lib/starter/about"
"ersteller-lib/starter/contact"
"ersteller-lib/starter/ent"
@@ -29,7 +30,12 @@ func CreateApi(environment env.Environment, db *ent.Client) http.Handler {
sessionStore.Options.HttpOnly = true
}
googleAuth := google.NewGoogleAuth(db, server.GetHttpServer(), environment, sessionStore)
googleAuth := google_http.NewGoogleAuth(google.NewDatabase(db), server.GetHttpServer(), google_http.Environment{
ClientId: environment.GoogleClientId,
ClientSecret: environment.GoogleClientSecret,
IsLocal: environment.IsLocal,
BaseUrl: environment.BaseUrl,
}, sessionStore)
googleAuth.AddRoutes()
indexActivePath := NewActivePath(map[Language]string{
@@ -83,7 +89,7 @@ func CreateApi(environment env.Environment, db *ent.Client) http.Handler {
serverWithMiddleWare := UseMiddleware(server, LoggingMiddleware, MakeGzipHandler,
authentication.Middleware(sessionStore,
[]string{"/de" + login.LoginPathDe, "/en" + authentication.LoginPath, google.GoogleLogin, google.GoogleLoginCallback, "/static"}, loginPaths))
[]string{"/de" + login.LoginPathDe, "/en" + authentication.LoginPath, google_http.GoogleLogin, google_http.GoogleLoginCallback, "/static"}, loginPaths))
return serverWithMiddleWare
}