Merge branch 'main' of github.com:nhost/nhost into timing

This commit is contained in:
David Barroso
2025-10-31 13:02:03 +01:00
3 changed files with 33 additions and 14 deletions

View File

@@ -56,12 +56,17 @@ in
{ buildInputs ? [ ]
, shellHook ? ""
}: pkgs.mkShell {
inherit shellHook;
buildInputs = with pkgs; [
gnumake
nixpkgs-fmt
] ++ goCheckDeps ++ buildInputs;
shellHook = shellHook + pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
export SDKROOT=${pkgs.apple-sdk_12}
export SDKROOT_FOR_TARGET=${pkgs.apple-sdk_12}
export DEVELOPER_DIR=${pkgs.apple-sdk_12}
export DEVELOPER_DIR_FOR_TARGET=${pkgs.apple-sdk_12}
'';
};
check =

View File

@@ -47,6 +47,15 @@ func (ctrl *Controller) getStateData(
return stateData, nil
}
func attachURLValues(u *url.URL, values map[string]string) {
q := u.Query()
for k, v := range values {
q.Set(k, v)
}
u.RawQuery = q.Encode()
}
func (ctrl *Controller) signinProviderProviderCallbackValidate(
ctx context.Context,
req providerCallbackData,
@@ -56,6 +65,10 @@ func (ctrl *Controller) signinProviderProviderCallbackValidate(
stateData, apiErr := ctrl.getStateData(ctx, req.State, logger)
if apiErr != nil {
attachURLValues(redirectTo, map[string]string{
"provider_state": req.State,
})
return nil, nil, redirectTo, apiErr
}
@@ -72,16 +85,17 @@ func (ctrl *Controller) signinProviderProviderCallbackValidate(
}
if req.Error != nil && *req.Error != "" {
values := redirectTo.Query()
values.Add("provider_error", deptr(req.Error))
values.Add("provider_error_description", deptr(req.ErrorDescription))
values.Add("provider_error_url", deptr(req.ErrorURI))
if stateData.State != nil && *stateData.State != "" {
values.Add("state", *stateData.State)
values := map[string]string{
"provider_error": deptr(req.Error),
"provider_error_description": deptr(req.ErrorDescription),
"provider_error_url": deptr(req.ErrorURI),
}
redirectTo.RawQuery = values.Encode()
if stateData.State != nil && *stateData.State != "" {
values["state"] = *stateData.State
}
attachURLValues(redirectTo, values)
return nil, nil, redirectTo, ErrOauthProviderError
}
@@ -93,9 +107,9 @@ func (ctrl *Controller) signinProviderProviderCallbackValidate(
}
if stateData.State != nil && *stateData.State != "" {
values := optionsRedirectTo.Query()
values.Add("state", *stateData.State)
optionsRedirectTo.RawQuery = values.Encode()
attachURLValues(optionsRedirectTo, map[string]string{
"state": *stateData.State,
})
}
return stateData.Options, stateData.Connect, optionsRedirectTo, nil

View File

@@ -666,7 +666,7 @@ func TestSignInProviderCallback(t *testing.T) { //nolint:maintidx
},
expectedResponse: controller.ErrorRedirectResponse{
Headers: struct{ Location string }{
Location: `http://localhost:3000?error=invalid-state&errorDescription=Invalid+state`,
Location: `^http://localhost:3000\?error=invalid-state&errorDescription=Invalid\+state&provider_state=wrong-state$`, //nolint:lll
},
},
expectedJWT: nil,