feat: Define redirect uris with env variables

This commit is contained in:
Andrey Rusakov 2024-08-27 16:29:00 +02:00
parent 52e8b651d3
commit f61bb00c74
2 changed files with 7 additions and 9 deletions

View file

@ -12,7 +12,6 @@ import (
"github.com/zitadel/logging" "github.com/zitadel/logging"
"golang.org/x/text/language" "golang.org/x/text/language"
"github.com/zitadel/oidc/v3/example/server/storage"
"github.com/zitadel/oidc/v3/pkg/op" "github.com/zitadel/oidc/v3/pkg/op"
) )
@ -20,14 +19,6 @@ const (
pathLoggedOut = "/logged-out" pathLoggedOut = "/logged-out"
) )
func init() {
storage.RegisterClients(
storage.NativeClient("native"),
storage.WebClient("web", "secret"),
storage.WebClient("api", "secret"),
)
}
type Storage interface { type Storage interface {
op.Storage op.Storage
authenticate authenticate

View file

@ -5,6 +5,7 @@ import (
"log/slog" "log/slog"
"net/http" "net/http"
"os" "os"
"strings"
"github.com/zitadel/oidc/v3/example/server/exampleop" "github.com/zitadel/oidc/v3/example/server/exampleop"
"github.com/zitadel/oidc/v3/example/server/storage" "github.com/zitadel/oidc/v3/example/server/storage"
@ -16,6 +17,12 @@ func main() {
//which gives us the issuer: http://localhost:9998/ //which gives us the issuer: http://localhost:9998/
issuer := fmt.Sprintf("http://localhost:%s/", port) issuer := fmt.Sprintf("http://localhost:%s/", port)
storage.RegisterClients(
storage.NativeClient("native", strings.Split(os.Getenv("REDIRECT_URI"), ",")...),
storage.WebClient("web", "secret"),
storage.WebClient("api", "secret"),
)
// the OpenIDProvider interface needs a Storage interface handling various checks and state manipulations // the OpenIDProvider interface needs a Storage interface handling various checks and state manipulations
// this might be the layer for accessing your database // this might be the layer for accessing your database
// in this example it will be handled in-memory // in this example it will be handled in-memory