Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(experimentalIdentityAndAuth): add codegen and TS integration points for config #881

Merged
merged 3 commits into from
Aug 31, 2023

Conversation

syall
Copy link
Contributor

@syall syall commented Aug 17, 2023

Issue #, if available:

N/A.

Description of changes:

NOTE: All of these are under the experimentalIdentityAndAuth feature flag

Start implementing core code generation and TypeScript package for the client config. This change introduces:

  • Adding config properties httpAuthSchemes and httpAuthSchemeProvider and corresponding runtime config defaults
    /**
     * experimentalIdentityAndAuth: Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme.
     * @internal
     */
    httpAuthSchemes?: IdentityProviderConfiguration;
    
    /**
     * experimentalIdentityAndAuth: Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use.
     * @internal
     */
    httpAuthSchemeProvider?: WeatherHttpAuthSchemeProvider;
  • Generating the model-based HttpAuthSchemeProvider and interfaces per client
    • Only no auth trait clients are supported in this PR, but other auth traits support will be implemented in follow-up PRs.
  • The @smithy/experimental-identity-and-auth package, which will be reorganized into proper packages and deprecated after feature development is complete.
    • This package should stay within 0.x.x, and never have a major version bump.
  • Temporarily removing auth traits from generic client test since they will fail codegen until the auth trait is supported

Testing:

TODO:

  • Add javadoc
  • Add TypeScript documentation
  • Add generating documentation for config properties
  • Test with an AuthScheme (planned @httpApiKeyAuth)

If one or more of the packages in the /packages directory has been modified, be sure yarn changeset add has been run and its output has
been committed and included in this pull request. See CONTRIBUTING.md.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@syall syall force-pushed the auth-scheme-codegen-core branch 2 times, most recently from 5738163 to 9b86eed Compare August 17, 2023 23:45
@syall syall changed the title Add experimentalIdentityAndAuth core codegen and TS implementations feat(experimentalIdentityAndAuth): Add core codegen and TS config integration points Aug 17, 2023
@syall syall changed the title feat(experimentalIdentityAndAuth): Add core codegen and TS config integration points feat(experimentalIdentityAndAuth): Add core codegen and TS integration points for config Aug 17, 2023
@syall syall changed the title feat(experimentalIdentityAndAuth): Add core codegen and TS integration points for config feat(experimentalIdentityAndAuth): Add codegen and TS integration points for config Aug 17, 2023
@syall syall force-pushed the auth-scheme-codegen-core branch 18 times, most recently from 266f716 to 77cf3cd Compare August 21, 2023 19:41
@syall syall marked this pull request as ready for review August 21, 2023 20:04
@syall syall requested review from a team as code owners August 21, 2023 20:04
@@ -0,0 +1,64 @@
{
"name": "@smithy/experimental-identity-and-auth",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does the package name include the word experimental? Doesn't that complicate promoting this to non-experimental later?

Copy link
Contributor Author

@syall syall Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking when the feature is ready to move out of experimental (code is stable), this package would be deprecated.

The code from this package would then be moved to the relevant packages (e.g. @smithy/types, individual middleware packages, etc.) and be published as production code.

This package should NOT be used in any production code at all.

Other alternatives being considered are alpha / beta tags, or a combination of semver and tags.

@kuhe
Copy link
Contributor

kuhe commented Aug 22, 2023

I reviewed the TS code 👍 . For the Java code, I'd want to see the output diff to evaluate it.

@syall syall force-pushed the auth-scheme-codegen-core branch 2 times, most recently from 5ec9696 to 95cc17b Compare August 22, 2023 18:55
@syall syall force-pushed the auth-scheme-codegen-core branch 3 times, most recently from 3e02005 to e2d9bec Compare August 24, 2023 18:56
@trivikr trivikr changed the title feat(experimentalIdentityAndAuth): Add codegen and TS integration points for config feat(experimental-identity-and-auth): Add codegen and TS integration points for config Aug 25, 2023
@trivikr trivikr changed the title feat(experimental-identity-and-auth): Add codegen and TS integration points for config feat(experimental-identity-and-auth): add codegen and TS integration points for config Aug 25, 2023
@trivikr trivikr changed the title feat(experimental-identity-and-auth): add codegen and TS integration points for config feat(experimentalIdentityAndAuth): add codegen and TS integration points for config Aug 25, 2023
Steven Yuan added 3 commits August 28, 2023 19:15
…and-auth package

Add interfaces and implementations for `experimentalIdentityAndAuth` in
an NPM package. This will be reorganized into proper packages once
feature development for `experimentalIdentityAndAuth` is complete.
…for `config`

Update `RuntimeConfigGenerator` to generate:

- `httpAuthSchemeProvider` that points to the `default*HttpAuthSchemeProvider`
  implementation.
- `httpAuthSchemes` that creates a `DefaultIdentityProviderConfiguration` that
  houses all the registered auth schemes with default identity providers
  and signers.

Update `ServiceBareBonesClientGenerator` to generate:

- `httpAuthSchemeProvider` that points to the `*HttpAuthSchemeProvider`
  interface
- `httpAuthSchemes` that points to the `IdentityProviderConfiguration`
  interface
- Any `ConfigField`s registered through `HttpAuthScheme`s

The 2 integration points are defined in `HttpAuthTypeScriptIntegration`:

- `getHttpAuthScheme()` which registers an auth scheme
- `customizeSupportedHttpAuthSchemes()` which is an open-ended method
  that allows complete access to the `SupportedAuthSchemesIndex`. This
  allows for adding, removing, mutating, replacing any aspect of the
  registered `HttpAuthScheme`s.

An `HttpAuthScheme` contains all the information needed to generate code
for an HTTP auth trait, from configuration fields, auth option
properties, auth scheme provider properties, default identity providers,
and default signers.

Also added `SupportedHttpAuthSchemesIndex` which registers auth schemes
that can be code generated. Note that this is NOT the same as all of the auth
schemes actually being used by the service: that still depends on the auth
traits in the model.
@syall syall force-pushed the auth-scheme-codegen-core branch 4 times, most recently from e2d9bec to ba0cdee Compare August 29, 2023 02:28
@syall syall merged commit 03f4ce4 into smithy-lang:main Aug 31, 2023
7 checks passed
@syall syall deleted the auth-scheme-codegen-core branch September 7, 2023 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants