Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
Signed-off-by: abarreiro <abarreiro@vmware.com>
  • Loading branch information
adambarreiro committed May 8, 2024
1 parent 8eb11d1 commit d0f10c2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions govcd/org_oidc.go
Expand Up @@ -204,15 +204,23 @@ func oidcExecuteRequest(adminOrg *AdminOrg, method string, payload *types.OrgOAu
return nil, fmt.Errorf("error deleting Organization OpenID Connect settings, expected status code %d - received %d", http.StatusNoContent, resp.StatusCode)
}
return nil, nil
default:
case http.MethodGet:
var result types.OrgOAuthSettings
err = decodeBody(types.BodyTypeXML, resp, &result)
if err != nil {
return nil, fmt.Errorf("error decoding Organization OpenID Connect settings: %s", err)
}
// Workaround for a possible bug in VCD: the PUT call never returns the tenant name in the redirect URL
result.OrgRedirectUri = strings.Replace(result.OrgRedirectUri, "tenant:null", "tenant:"+adminOrg.AdminOrg.Name, 1)
return &result, nil
case http.MethodPut:
// Note: This branch of the switch should be exactly the same as the GET operation, however there is a bug found in VCD 10.5.1.1:
// the PUT call returns a wrong redirect URL.
// For that reason, we ignore the response body and call GetOpenIdConnectSettings() to return the correct response body to the caller.
if resp != nil && resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("error saving Organization OpenID Connect settings, expected status code %d - received %d", http.StatusOK, resp.StatusCode)
}
return adminOrg.GetOpenIdConnectSettings()
default:
return nil, fmt.Errorf("not supported HTTP method %s", method)
}
}

Expand Down

0 comments on commit d0f10c2

Please sign in to comment.