Skip to content

Commit f8cf48e

Browse files
committed
Redeploy cloud from scratch. Fix CORS envoy issues and validate that pxl script execution works
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent 647cd73 commit f8cf48e

5 files changed

Lines changed: 32 additions & 22 deletions

File tree

k8s/cloud/base/ory_auth/hydra/hydra_config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ data:
1515
path: /certs/server.crt
1616
key:
1717
path: /certs/server.key
18+
urls:
19+
self:
20+
issuer: https://hydra.plc.svc.cluster.local:4444
21+
public: https://hydra.plc.svc.cluster.local:4444
22+
admin: https://hydra.plc.svc.cluster.local:4445
1823
oidc:
1924
subject_identifiers:
2025
supported_types:

k8s/cloud/base/ory_auth/oauth_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ metadata:
66
data:
77
PL_OAUTH_PROVIDER: hydra
88
PL_AUTH_URI: /oauth/hydra
9-
PL_AUTH_CLIENT_ID: 5d8827bd-a958-415b-a541-3f68ab06e9b5
9+
PL_AUTH_CLIENT_ID: 07ab750f-9b37-4df8-b107-a0d112bcf329
1010
PL_AUTH_EMAIL_PASSWORD_CONN: ""

k8s/cloud_deps/public/configs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data:
2727
# Hydra is the easiest option to get started with.
2828
PL_OAUTH_PROVIDER: hydra
2929
PL_AUTH_URI: /oauth/hydra
30-
PL_AUTH_CLIENT_ID: 5d8827bd-a958-415b-a541-3f68ab06e9b5
30+
PL_AUTH_CLIENT_ID: 07ab750f-9b37-4df8-b107-a0d112bcf329
3131
PL_AUTH_EMAIL_PASSWORD_CONN: ""
3232
---
3333
apiVersion: v1

src/cloud/api/controllers/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func AuthOAuthLoginHandler(env commonenv.Env, w http.ResponseWriter, r *http.Req
6262
oa := apiEnv.IdentityProviderClient()
6363
session, err := apiEnv.CookieStore().Get(r, oa.SessionKey())
6464
if err != nil {
65-
return &handler.StatusError{Code: http.StatusInternalServerError, Err: err}
65+
return &handler.StatusError{Code: http.StatusInternalServerError, Err: errors.New("failed to get session cookie: " + err.Error())}
6666
}
6767
return oa.HandleLogin(session, w, r)
6868
}

src/cloud/shared/idprovider/client.go

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,18 @@ func NewHydraKratosClientFromConfig(cfg *HydraKratosConfig) (*HydraKratosClient,
213213

214214
// NewHydraKratosClient creates a new client with the default config.
215215
func NewHydraKratosClient() (*HydraKratosClient, error) {
216-
return NewHydraKratosClientFromConfig(
217-
&HydraKratosConfig{
218-
HydraPublicHost: viper.GetString("hydra_public_host"),
219-
HydraAdminHost: viper.GetString("hydra_admin_host"),
220-
HydraBrowserURL: viper.GetString("hydra_browser_url"),
221-
KratosPublicHost: viper.GetString("kratos_public_host"),
222-
KratosAdminHost: viper.GetString("kratos_admin_host"),
223-
KratosBrowserURL: viper.GetString("kratos_browser_url"),
224-
HydraConsentPath: viper.GetString("hydra_consent_path"),
225-
HydraClientID: viper.GetString("hydra_client_id"),
226-
},
227-
)
216+
config := &HydraKratosConfig{
217+
HydraPublicHost: viper.GetString("hydra_public_host"),
218+
HydraAdminHost: viper.GetString("hydra_admin_host"),
219+
HydraBrowserURL: viper.GetString("hydra_browser_url"),
220+
KratosPublicHost: viper.GetString("kratos_public_host"),
221+
KratosAdminHost: viper.GetString("kratos_admin_host"),
222+
KratosBrowserURL: viper.GetString("kratos_browser_url"),
223+
HydraConsentPath: viper.GetString("hydra_consent_path"),
224+
HydraClientID: viper.GetString("hydra_client_id"),
225+
}
226+
fmt.Printf("Using hydra kratos config: %+v\n", config)
227+
return NewHydraKratosClientFromConfig(config)
228228
}
229229

230230
func (c *HydraKratosClient) convertExternalHydraURLToInternal(externalHydraURL string) (string, error) {
@@ -450,9 +450,11 @@ func (c *HydraKratosClient) AcceptConsent(ctx context.Context, challenge string)
450450

451451
// We only trust the client that's passed in as a config here. In the future we might want to support other clients
452452
// at which point we will want to actually ask for permission from the user.
453-
if consentRequest.Client.ClientID != c.Config.HydraClientID {
454-
return nil, fmt.Errorf("'%s' not an allowed client", consentRequest.Client.ClientID)
455-
}
453+
454+
// TODO(ddelnano): This needs cannot be hard coded to auth-code-client, but should be set in the config.
455+
// if consentRequest.Client.ClientID != c.Config.HydraClientID {
456+
// return nil, fmt.Errorf("'%s' not an allowed client", consentRequest.Client.ClientID)
457+
// }
456458

457459
acceptResp, err := c.hydraAdminClient.AcceptConsentRequest(&hydraAdmin.AcceptConsentRequestParams{
458460
Body: &hydraModels.AcceptConsentRequest{
@@ -505,12 +507,15 @@ func (c *HydraKratosClient) HandleLogin(session *sessions.Session, w http.Respon
505507
ctx := context.Background()
506508
whoami, err := c.Whoami(ctx, r)
507509
if err != nil {
508-
return &handler.StatusError{Code: http.StatusInternalServerError, Err: err}
510+
return &handler.StatusError{Code: http.StatusInternalServerError, Err: fmt.Errorf("Could not get whoami: %w", err)}
509511
}
510512

513+
if whoami != nil && whoami.kratosSession != nil {
514+
fmt.Printf("session: %+v\n", *whoami.kratosSession)
515+
}
511516
redirectResp, err := c.AcceptHydraLogin(ctx, challenge, whoami)
512517
if err != nil {
513-
return &handler.StatusError{Code: http.StatusInternalServerError, Err: err}
518+
return &handler.StatusError{Code: http.StatusInternalServerError, Err: fmt.Errorf("Could not accept hydra login: %w", err)}
514519
}
515520

516521
if redirectResp.RedirectTo == nil {
@@ -520,12 +525,12 @@ func (c *HydraKratosClient) HandleLogin(session *sessions.Session, w http.Respon
520525
// We expect the response to redirect to the consent endpoint. We will just intercept the consent endpoint
521526
respHeader, consentChallenge, err := c.InterceptHydraUserConsent(*redirectResp.RedirectTo, r.Header)
522527
if err != nil {
523-
return &handler.StatusError{Code: http.StatusInternalServerError, Err: err}
528+
return &handler.StatusError{Code: http.StatusInternalServerError, Err: fmt.Errorf("Could not intercept hydra user consent: %w", err)}
524529
}
525530

526531
consentResp, err := c.AcceptConsent(ctx, consentChallenge)
527532
if err != nil {
528-
return &handler.StatusError{Code: http.StatusInternalServerError, Err: err}
533+
return &handler.StatusError{Code: http.StatusInternalServerError, Err: fmt.Errorf("Could not accept hydra consent: %w", err)}
529534
}
530535

531536
// Copy the header because the header contains a necessary Set-Cookie from the OAuth server.

0 commit comments

Comments
 (0)