Conversation
This commit starts the process of converting protocol and auth definitinions into meta-traits that are attached to other traits. This change leans into the idea of "traits are just shapes" and takes that a step further by making auth and protocol applications into normal traits. This removes the need for a custom model layer that we had previously which required things like custom Smithy build transforms and linters.
These were needed when protocol and auth applications weren't real traits. Now that they're traits, they can be added and removed just like any other trait.
The auth and protocol settings for protocol tests now use shape IDs with idRef traits rather than raw strings. This provides more validation of protocol test trait definitions.
OpenAPI conversion now uses the protocol auth traits. Further, Context and security scheme converters are now generic over the protocol/auth trait they convert, making them easier to implement.
This should really just be a known customization to implement when writing an S3 client. It isn't really something I think any other team would ever repeat.
| <suppressions> | ||
| <suppress checks="EqualsHashCode" files="shapes/*"/> | ||
| <suppress checks="InnerAssignment" files="StringUtils"/> | ||
| <suppress checks="TypeName" files="AwsJson1_0Trait.java|AwsJson1_1Trait.java"/> |
There was a problem hiding this comment.
These names are flagged as not meeting Java conventions, but we need to carry the version numbers in the generated class.
| This transformer does not remove shapes from the prelude. | ||
|
|
||
|
|
||
| .. _includeAuth-transform: |
There was a problem hiding this comment.
These are no longer needed since they're just normal traits. You can include/exclude traits using includeTraits, excludeTraits, etc
| specification. The following example defines a ``smithy-build.json`` file | ||
| that builds an OpenAPI specification from a service for the | ||
| ``smithy.example#Weather`` service using the ``aws.rest-json-1.1`` protocol: | ||
| ``smithy.example#Weather`` service using the ``aws.protocols#restJson1`` protocol: |
There was a problem hiding this comment.
We decided to use restJson1 rather than just restJson since we eventually plan to ship an improved REST+JSON protocol.
| @@ -0,0 +1,125 @@ | |||
| .. _aws-authentication: | |||
There was a problem hiding this comment.
Like protocols, I broke authentication traits into their own doc. Unlike protocols, I didn't give each trait it's own page. We could consider doing that if we perhaps add more extensive sigv4 documentation (for example, we may want to recreate the sigv4 test suite to be Smithy protocol tests).
| ], | ||
| "aws.protocols#restJson1": {}, | ||
| "aws.auth#sigv4": { | ||
| "name": "someservice" |
There was a problem hiding this comment.
"name" is required (at least for now). This makes the sigv4 signing name much more explicit.
| $version: "0.5.0" | ||
|
|
||
| namespace aws.protocols.tests.ec2 | ||
| namespace aws.protocoltests.ec2 |
There was a problem hiding this comment.
I renamed these tests to take a page from JPMS modules about split packages. It probably doesn't matter nor ever will, but just in case...
| IDENTITY_VALIDATION_EXPRESSION_KEY, RESULT_TTL_IN_SECONDS); | ||
|
|
||
| private final String scheme; | ||
| private final ShapeId scheme; |
There was a problem hiding this comment.
Authorizers now reference auth scheme shape IDs rather than arbitrary names
smithy-aws-traits/src/main/resources/META-INF/smithy/aws.auth.json
Outdated
Show resolved
Hide resolved
| public void addsHttpDigestAuth() { | ||
| Model model = Model.assembler() | ||
| .addImport(getClass().getResource("http-digest-security.json")) | ||
| .discoverModels() |
There was a problem hiding this comment.
Since we're using dependencies now in tests, we need to use model discovery.
| @@ -0,0 +1,103 @@ | |||
| .. _aws-json-protocols: | |||
There was a problem hiding this comment.
For now could you at least link to the accompanying protocol tests? Maybe in a see-also type section
This PR converts protocol and auth definitinions into meta-traits that are attached to other traits. This change leans into the idea of "traits are just shapes" and takes that a step further by making auth and protocol applications into normal traits. This removes the need for a custom model layer that we had previously which required things like custom Smithy build transforms and linters.
Followup PRs will updates documentation and further improve JSON schema and API Gateway integrations.