Azure / azure-sdk-for-rust

This repository is for the active development of the Azure SDK for Rust. For consumers of the SDK we recommend visiting Docs.rs and looking up the docs for any of libraries in the SDK.
MIT License
707 stars 245 forks source link

Remove order dependency of auth policy in pipeline #477

Open thovoll opened 3 years ago

thovoll commented 3 years ago

See this comment: https://github.com/Azure/azure-sdk-for-rust/blob/c6f94bcd494e74dc71977136fa62362d0b8f6fbf/sdk/cosmos/src/clients/cosmos_client.rs#L74

Having to remember this and replicate this comment to all code that creates a new pipeline is not great.

How can we remove this order dependency?

Maybe introduce a separate pipeline parameter for auth policy?

MindFlavor commented 3 years ago

The requirement of being the last policy only applies to authorization polices based on HMAC (like CosmosDB, or Azure Storage). Other mechanisms, like the Bearer Token, can be inserted elsewhere (maybe it must be per retry if we want to handle the refresh token automatically).

For this reason I believe that it's right to have the Pipeline struct in core free of constraints. That said, I agree with you, we should make the pipeline creation as error-proof as possible.