Skip to content

Commit

Permalink
feat(experimentalIdentityAndAuth): make experimentalIdentityAndAuth
Browse files Browse the repository at this point in the history
… default

TODO:

- [ ] AddAwsRuntimeConfig
- [ ] AddBuiltinPlugins
- [ ] AddEventBridgePlugin
- [ ] AddEventStreamHandlingDependency
- [ ] AddS3Config
- [ ] AddS3ControlDependency
  • Loading branch information
syall committed Oct 2, 2023
1 parent ba89e7e commit a462fe5
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 79 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ experimental features that can affect `aws-sdk-js-v3`. These features are enable
Note that any contributions related to these features MUST be reviewed carefully for opt-in behavior via feature flags
as to not break any existing customers. Here are the experimental features that are currently under development:

| Experimental Feature | Flag | Description |
| -------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Identity & Auth | `experimentalIdentityAndAuth` | Standardize identity and auth integrations to match the Smithy specification (see [Authentication Traits](https://smithy.io/2.0/spec/authentication-traits.html)). Newer capabilities include support for multiple auth schemes, `@optionalAuth`, and standardized identity interfaces for authentication schemes both in code generation and TypeScript packages. In `smithy-typescript`, `@httpApiKeyAuth` will be updated to use the new standardized interfaces. In `aws-sdk-js-v3` (`smithy-typescript`'s largest customer), this will affect `@aws.auth#sigv4` and `@httpBearerAuth` implementations, but is planned to be completely backwards-compatible. |
| Experimental Feature | Flag | Description |
| -------------------- | ---- | ----------- |
| Currently None | N/A | N/A |

## Build caching

Expand Down
2 changes: 1 addition & 1 deletion codegen/generic-client-test-codegen/model/weather.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ structure fakeProtocol {}
service Weather {
version: "2006-03-01"
operations: [
// experimentalIdentityAndAuth
// Identity and Auth
OnlyHttpApiKeyAuth
OnlyHttpApiKeyAuthOptional
OnlyHttpBearerAuth
Expand Down
27 changes: 1 addition & 26 deletions codegen/generic-client-test-codegen/smithy-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,7 @@
"version": "1.0",
"imports": ["model/echo.smithy"],
"projections": {
"client-experimental-identity-and-auth": {
"transforms": [
{
"name": "includeServices",
"args": {
"services": ["example.weather#Weather"]
}
}
],
"plugins": {
"typescript-codegen": {
"package": "@aws-sdk/weather",
"packageVersion": "0.0.1",
"packageJson": {
"author": {
"name": "AWS SDK for JavaScript Team",
"url": "https://aws.amazon.com/javascript/"
},
"license": "Apache-2.0"
},
"private": true,
"experimentalIdentityAndAuth": true
}
}
},
"control-experimental-identity-and-auth": {
"control-identity-and-auth": {
"transforms": [
{
"name": "includeServices",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@

/**
* Configure clients with AWS auth configurations and plugin.
*
* This is the existing control behavior for `experimentalIdentityAndAuth`.
*/
@Deprecated
@SmithyInternalApi
public final class AddAwsAuthPlugin implements TypeScriptIntegration {
static final String STS_CLIENT_PREFIX = "sts-client-";
Expand All @@ -67,14 +66,6 @@ public final class AddAwsAuthPlugin implements TypeScriptIntegration {

private static final Logger LOGGER = Logger.getLogger(AddAwsAuthPlugin.class.getName());

/**
* Integration should only be used if `experimentalIdentityAndAuth` flag is false.
*/
@Override
public boolean matchesSettings(TypeScriptSettings settings) {
return !settings.getExperimentalIdentityAndAuth();
}

@Override
public void addConfigInterfaceFields(
TypeScriptSettings settings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,17 @@
import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention.HAS_MIDDLEWARE;

import java.util.List;
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
import software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin;
import software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Configure clients with Token auth configurations and plugin.
*
* This is the existing control behavior for `experimentalIdentityAndAuth`.
*/
@Deprecated
@SmithyInternalApi
public final class AddTokenAuthPlugin implements TypeScriptIntegration {

/**
* Integration should only be used if `experimentalIdentityAndAuth` flag is false.
*/
@Override
public boolean matchesSettings(TypeScriptSettings settings) {
return !settings.getExperimentalIdentityAndAuth();
}

@Override
public List<RuntimeClientPlugin> getClientPlugins() {
return ListUtils.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public enum AwsDependency implements Dependency {
// Conditionally added when auth trait is present
MIDDLEWARE_API_KEY(NORMAL_DEPENDENCY, "@aws-sdk/middleware-api-key"),

// feat(experimentalIdentityAndAuth): Conditionally added when @httpBearerAuth is used in an AWS service
// Conditionally added when @httpBearerAuth is used in an AWS service
TOKEN_PROVIDERS(NORMAL_DEPENDENCY, "@aws-sdk/token-providers"),
TYPES(NORMAL_DEPENDENCY, "@aws-sdk/types"),
REGION_CONFIG_RESOLVER(NORMAL_DEPENDENCY, "@aws-sdk/region-config-resolver");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import software.amazon.smithy.aws.typescript.codegen.AwsDependency;
import software.amazon.smithy.model.traits.HttpBearerAuthTrait;
import software.amazon.smithy.typescript.codegen.LanguageTarget;
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
import software.amazon.smithy.typescript.codegen.auth.http.HttpAuthScheme;
import software.amazon.smithy.typescript.codegen.auth.http.SupportedHttpAuthSchemesIndex;
import software.amazon.smithy.typescript.codegen.auth.http.integration.AddHttpBearerAuthPlugin;
Expand All @@ -18,20 +17,9 @@

/**
* Customize @httpBearerAuth for AWS SDKs.
*
* This is the experimental behavior for `experimentalIdentityAndAuth`.
*/
@SmithyInternalApi
public final class AwsCustomizeHttpBearerTokenAuthPlugin implements HttpAuthTypeScriptIntegration {

/**
* Integration should only be used if `experimentalIdentityAndAuth` flag is true.
*/
@Override
public boolean matchesSettings(TypeScriptSettings settings) {
return settings.getExperimentalIdentityAndAuth();
}

/**
* Run after default AddHttpBearerAuthPlugin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import software.amazon.smithy.aws.traits.auth.SigV4Trait;
import software.amazon.smithy.aws.typescript.codegen.AwsDependency;
import software.amazon.smithy.typescript.codegen.LanguageTarget;
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
import software.amazon.smithy.typescript.codegen.auth.http.HttpAuthScheme;
import software.amazon.smithy.typescript.codegen.auth.http.SupportedHttpAuthSchemesIndex;
import software.amazon.smithy.typescript.codegen.auth.http.integration.AddSigV4AuthPlugin;
Expand All @@ -18,20 +17,9 @@

/**
* Customize @aws.auth#sigv4 for AWS SDKs.
*
* This is the experimental behavior for `experimentalIdentityAndAuth`.
*/
@SmithyInternalApi
public class AwsCustomizeSigv4AuthPlugin implements HttpAuthTypeScriptIntegration {

/**
* Integration should only be used if `experimentalIdentityAndAuth` flag is true.
*/
@Override
public boolean matchesSettings(TypeScriptSettings settings) {
return settings.getExperimentalIdentityAndAuth();
}

/**
* Run after default AddSigV4AuthPlugin.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
software.amazon.smithy.aws.typescript.codegen.AddEndpointsV2ParameterNameMap
software.amazon.smithy.aws.typescript.codegen.AddAwsRuntimeConfig
software.amazon.smithy.aws.typescript.codegen.AddBuiltinPlugins
software.amazon.smithy.aws.typescript.codegen.AddAwsAuthPlugin
software.amazon.smithy.aws.typescript.codegen.AddTokenAuthPlugin
software.amazon.smithy.aws.typescript.codegen.AddProtocols
software.amazon.smithy.aws.typescript.codegen.AwsEndpointGeneratorIntegration
software.amazon.smithy.aws.typescript.codegen.AddNimbleCustomizations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import software.amazon.smithy.build.MockManifest;
import software.amazon.smithy.build.PluginContext;
Expand All @@ -12,7 +13,9 @@
import software.amazon.smithy.typescript.codegen.CodegenUtils;
import software.amazon.smithy.typescript.codegen.TypeScriptCodegenPlugin;

@Deprecated
public class AddAwsAuthPluginTest {
@Disabled("software.amazon.smithy.aws.typescript.codegen.AddAwsAuthPlugin is considered deprecated")
@Test
public void awsClient() {
Model model = Model.assembler()
Expand Down Expand Up @@ -52,6 +55,7 @@ public void awsClient() {
assertThat(manifest.getFileString(CodegenUtils.SOURCE_FOLDER + "/NotSameClient.ts").get(), containsString("getAwsAuthPlugin"));
}

@Disabled("software.amazon.smithy.aws.typescript.codegen.AddAwsAuthPlugin is considered deprecated")
@Test
public void sigV4GenericClient() {
Model model = Model.assembler()
Expand Down

0 comments on commit a462fe5

Please sign in to comment.