Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: don't use openidconnect discovery url #1081

Merged
merged 4 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/operator/apis/stack/v1beta3/stack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (s *Stack) GetScheme() string {
}

func (s *Stack) URL() string {
return fmt.Sprintf("%s://%s", s.GetScheme(), s.Spec.Host)
return "http://gateway:8000"
}

func (in *Stack) GetServiceNamespacedName(service string) types.NamespacedName {
Expand Down
21 changes: 12 additions & 9 deletions ee/gateway/pkg/plugins/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"os"
"strconv"
"strings"

Expand All @@ -15,7 +16,6 @@ import (
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
"github.com/caddyserver/caddy/v2/modules/caddyhttp/caddyauth"
"github.com/hashicorp/go-retryablehttp"
"github.com/zitadel/oidc/v2/pkg/client"
"github.com/zitadel/oidc/v2/pkg/client/rp"
"github.com/zitadel/oidc/v2/pkg/oidc"
"github.com/zitadel/oidc/v2/pkg/op"
Expand Down Expand Up @@ -158,16 +158,19 @@ func (ja *JWTAuth) Authenticate(w http.ResponseWriter, r *http.Request) (caddyau
// Helpers
//------------------------------------------------------------------------------

func (ja *JWTAuth) getAccessTokenVerifier(
ctx context.Context,
) (op.AccessTokenVerifier, error) {
func (ja *JWTAuth) getAccessTokenVerifier(ctx context.Context) (op.AccessTokenVerifier, error) {
if ja.accessTokenVerifier == nil {
discoveryConfiguration, err := client.Discover(ja.Issuer, ja.httpClient)
if err != nil {
return nil, err
//discoveryConfiguration, err := client.Discover(ja.Issuer, ja.httpClient)
//if err != nil {
// return nil, err
//}

// todo: ugly quick fix
authServicePort := "8080"
if fromEnv := os.Getenv("AUTH_SERVICE_PORT"); fromEnv != "" {
authServicePort = fromEnv
}

keySet := rp.NewRemoteKeySet(ja.httpClient, discoveryConfiguration.JwksURI)
keySet := rp.NewRemoteKeySet(ja.httpClient, fmt.Sprintf("http://auth:%s/keys", authServicePort))

ja.accessTokenVerifier = op.NewAccessTokenVerifier(
ja.Issuer,
Expand Down
Loading