Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
11 stars 33 forks source link

Strengthen auth linter to require managed identity by default #785

Open tg-msft opened 3 months ago

tg-msft commented 3 months ago

Clear and concise description of the problem

We should strengthen https://github.com/Azure/typespec-azure/blob/main/packages/typespec-azure-core/src/rules/auth-required.ts to require managed identity for all services and suppress the warning for anything brownfield. We need to make a corresponding change to Azure's guidelines tracked at https://github.com/microsoft/api-guidelines/issues/544.

Checklist

markcowl commented 3 months ago

@tg-msft We don't describe mechanisms for acquiring tokens in API Specs, do we want to discourage authentication mechanisms other than 0auth in API SPecs (like ApiKeyAuth), or is there some other ask here?

There are some API patterns apart from spec authentication that are problematic, such as passing secrets in PUT / POST (Create) payloads, not marking properties named 'password' or 'credential' or 'token' as @secret, etc. Are there some API-specific practices like these that we would like to lint for as well?

tg-msft commented 3 months ago

do we want to discourage authentication mechanisms other than 0auth in API SPecs (like ApiKeyAuth), or is there some other ask here?

The current linting rule validates that any auth mechanism is present and will be happy with just api keys. I'm asking to validate everyone has OAuth so services who don't support it have to explicitly #suppress, explain why to reviewers, and be easily tracked. I don't think we need to do anything about other auth mechanisms for now.

We could probably do more security linting for worst practices, but this issue is scoped to just aligning this linting rule with whatever we do for https://github.com/microsoft/api-guidelines/issues/544.