* first draft of a new server interface * allow any response type * complete interface docs * refelct the format from the proposal * intermediate commit with some methods implemented * implement remaining token grant type methods * implement remaining server methods * error handling * rewrite auth request validation * define handlers, routes * input validation and concrete handlers * check if client credential client is authenticated * copy and modify the routes test for the legacy server * run integration tests against both Server and Provider * remove unuse ValidateAuthRequestV2 function * unit tests for error handling * cleanup tokenHandler * move server routest test * unit test authorize * handle client credentials in VerifyClient * change code exchange route test * finish http unit tests * review server interface docs and spelling * add withClient unit test * server options * cleanup unused GrantType method * resolve typo comments * make endpoints pointers to enable/disable them * jwt profile base work * jwt: correct the test expect --------- Co-authored-by: Livio Spring <livio.a@gmail.com>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/zitadel/oidc/v3/example/server/exampleop"
|
|
"github.com/zitadel/oidc/v3/example/server/storage"
|
|
"golang.org/x/exp/slog"
|
|
)
|
|
|
|
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)
|
|
}
|
|
}
|