This change adds Go 1.22 as a build target and drops support for Go 1.20 and older. The golang.org/x/exp/slog import is migrated to log/slog. Slog has been part of the Go standard library since Go 1.21. Therefore we are dropping support for older Go versions. This is in line of our support policy of "the latest two Go versions".
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log/slog"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/zitadel/oidc/v3/example/server/exampleop"
|
|
"github.com/zitadel/oidc/v3/example/server/storage"
|
|
)
|
|
|
|
func main() {
|
|
//we will run on :9998
|
|
port := "9998"
|
|
//which gives us the issuer: http://localhost:9998/
|
|
issuer := fmt.Sprintf("http://localhost:%s/", port)
|
|
|
|
// the OpenIDProvider interface needs a Storage interface handling various checks and state manipulations
|
|
// this might be the layer for accessing your database
|
|
// in this example it will be handled in-memory
|
|
storage := storage.NewStorage(storage.NewUserStore(issuer))
|
|
|
|
logger := slog.New(
|
|
slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
|
|
AddSource: true,
|
|
Level: slog.LevelDebug,
|
|
}),
|
|
)
|
|
router := exampleop.SetupServer(issuer, storage, logger, false)
|
|
|
|
server := &http.Server{
|
|
Addr: ":" + port,
|
|
Handler: router,
|
|
}
|
|
logger.Info("server listening, press ctrl+c to stop", "addr", fmt.Sprintf("http://localhost:%s/", port))
|
|
err := server.ListenAndServe()
|
|
if err != http.ErrServerClosed {
|
|
logger.Error("server terminated", "error", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|