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

Add validator for services with no auth trait #1929

Merged

Conversation

milesziemer
Copy link
Contributor

Adds a validator that warns when there's a service shape that has multiple authDefinition traits applied, but no auth trait. This encourages the use of the auth trait so auth scheme priority is being modeled explicitly. It also allows for tooling to look for and use this validation event.

Documentation was also updated to explain that without the auth trait, auth scheme ordering is alphabetical.

A test for the auth trait (auth-trait-must-target-service-schemes) was updated to avoid getting the warning message from the new validator.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@milesziemer milesziemer requested a review from a team as a code owner August 16, 2023 19:05
@milesziemer milesziemer force-pushed the auth-schemes-with-no-auth-validator branch from edcc172 to f450453 Compare August 16, 2023 19:06
@milesziemer milesziemer force-pushed the auth-schemes-with-no-auth-validator branch from f450453 to 6b5489b Compare August 16, 2023 19:33
* Validates that services with multiple @authDefinition traits applied also
* have an @auth trait applied.
*/
public class ServiceWithNoAuthTraitValidator extends AbstractValidator {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of being so specific, I think this could be ServiceAuthDefinitionsValidator. In the future maybe we'll want to warn if service has 0 auth schemes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Also changed the javadoc for the class

Adds a validator that warns when there's a service shape that has
multiple authDefinition traits applied, but no auth trait. This
encourages the use of the auth trait so auth scheme priority is
being modeled explicitly. It also allows for tooling to look for
and use this validation event.

Documentation was also updated to explain that without the auth
trait, auth scheme ordering is alphabetical.

A test for the auth trait (auth-trait-must-target-service-schemes)
was updated to avoid getting the warning message from the new
validator.
@milesziemer milesziemer force-pushed the auth-schemes-with-no-auth-validator branch from 6b5489b to 8655119 Compare August 16, 2023 19:51
@milesziemer milesziemer merged commit 7bf6e00 into smithy-lang:main Aug 18, 2023
alextwoods pushed a commit to alextwoods/smithy that referenced this pull request Sep 15, 2023
Adds a validator that warns when there's a service shape that has
multiple authDefinition traits applied, but no auth trait. This
encourages the use of the auth trait so auth scheme priority is
being modeled explicitly. It also allows for tooling to look for
and use this validation event.

Documentation was also updated to explain that without the auth
trait, auth scheme ordering is alphabetical.

A test for the auth trait (auth-trait-must-target-service-schemes)
was updated to avoid getting the warning message from the new
validator.
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.

3 participants