added oauth flow to get authorization code

This commit is contained in:
2026-01-22 19:52:43 +11:00
parent 7be15160d5
commit c14c5d43ee
15 changed files with 1313 additions and 32 deletions

View File

@@ -53,7 +53,7 @@ func setupHttpServer(
return nil, errors.Wrap(err, "httpServer.LoggerIgnorePaths")
}
err = addRoutes(httpServer, &fs, config, logger, bun, auth)
err = addRoutes(httpServer, &fs, config, bun, auth)
if err != nil {
return nil, errors.Wrap(err, "addRoutes")
}

View File

@@ -9,7 +9,6 @@ import (
"git.haelnorr.com/h/oslstats/internal/db"
"git.haelnorr.com/h/oslstats/internal/handlers"
"git.haelnorr.com/h/golib/hlog"
"github.com/pkg/errors"
"github.com/uptrace/bun"
)
@@ -17,8 +16,7 @@ import (
func addRoutes(
server *hws.Server,
staticFS *http.FileSystem,
config *config.Config,
logger *hlog.Logger,
cfg *config.Config,
conn *bun.DB,
auth *hwsauth.Authenticator[*db.User, bun.Tx],
) error {
@@ -34,6 +32,16 @@ func addRoutes(
Method: hws.MethodGET,
Handler: handlers.Index(server),
},
{
Path: "/login",
Method: hws.MethodGET,
Handler: auth.LogoutReq(handlers.Login(server, cfg)),
},
{
Path: "/auth/callback",
Method: hws.MethodGET,
Handler: auth.LogoutReq(handlers.Callback(server, cfg)),
},
}
// Register the routes with the server