-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v15] Fix AWS App Access creation for AWS OIDC Integration when using…
… the account number as name (#45818) * Fix AWS App Access creation for AWS OIDC Integration If the integration name is digits only, the resulting address for the application will look like this: `123456789012.proxy.example.com:443` This fails to parse with go's `url.Parse`. This PR keeps the existing logic for creating the AWS App Access but does a best effort to fix this issue by removing the `:443` from the public proxy addr. If another port is used, we would still get the error. * prepend the protocol so that url.parse accepts any port number * move change to types/app
- Loading branch information
1 parent
aa4701e
commit 6e03a2e
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import ( | |
"encoding/base64" | ||
"fmt" | ||
"net/url" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
|
@@ -974,6 +975,7 @@ func TestAWSOIDCAppAccessAppServerCreationDeletion(t *testing.T) { | |
require.NoError(t, err) | ||
|
||
proxy := env.proxies[0] | ||
proxy.handler.handler.cfg.PublicProxyAddr = strings.TrimPrefix(proxy.handler.handler.cfg.PublicProxyAddr, "https://") | ||
proxyPublicAddr := proxy.handler.handler.cfg.PublicProxyAddr | ||
pack := proxy.authPack(t, "[email protected]", []types.Role{roleTokenCRD}) | ||
|
||
|
@@ -1040,4 +1042,20 @@ func TestAWSOIDCAppAccessAppServerCreationDeletion(t *testing.T) { | |
appServers, err = env.server.Auth().GetApplicationServers(ctx, "default") | ||
require.NoError(t, err) | ||
require.Empty(t, appServers) | ||
|
||
t.Run("using the account id as name works as expected", func(t *testing.T) { | ||
// Creating an Integration using the account id as name should not return an error if the proxy is listening at the default HTTPS port | ||
myIntegrationWithAccountID, err := types.NewIntegrationAWSOIDC(types.Metadata{ | ||
Name: "123456789012", | ||
}, &types.AWSOIDCIntegrationSpecV1{ | ||
RoleARN: "some-arn-role", | ||
}) | ||
require.NoError(t, err) | ||
|
||
_, err = env.server.Auth().CreateIntegration(ctx, myIntegrationWithAccountID) | ||
require.NoError(t, err) | ||
endpoint = pack.clt.Endpoint("webapi", "sites", "localhost", "integrations", "aws-oidc", "123456789012", "aws-app-access") | ||
_, err = pack.clt.PostJSON(ctx, endpoint, nil) | ||
require.NoError(t, err) | ||
}) | ||
} |