Skip to content

Proposed fixes for token-based auth in azure fileshare service - #820

Merged
Sergiy Matusevych (motus) merged 11 commits into
microsoft:mainfrom
eujing:fix-fs-auth
Aug 3, 2024
Merged

Sergiy Matusevych (motus) merged 11 commits into
microsoft:mainfrom
eujing:fix-fs-auth

Conversation

@eujing

Copy link
Copy Markdown
Contributor

To use token-based authentication for ShareClient, I think we should be passing in the credential object derived from TokenCredential (in our case, some instance of DefaultAzureCredential.

Previously, we were passing specific string tokens to the credential argument, which is being intepreted as a SAS token.
This leads to errors like: azure.core.exceptions.ClientAuthenticationError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

ShareClient documentation on the credential argument.

By passing in the whole TokenCredential object, I believe ShareClient will manage the token lifecycle and we won't need to do so as mentioned in #818.

@eujing
Eu Jing Chua (eujing) requested a review from a team as a code owner July 25, 2024 01:19
@eujing

Copy link
Copy Markdown
Contributor Author

Want to add that I haven't been able to test this fully on my side yet.
Currently getting a permissions error, so I am trying to grant myself the Storage File Data Privileged Contributor role to see if that works. Currently only have overall Contributor role to the storage account.

azure.core.exceptions.HttpResponseError: This request is not authorized to perform this operation using this permission. RequestId:15e8cf1a-301a-0068-0618-de1302000000 Time:2024-07-24T22:29:41.5702312Z ErrorCode:AuthorizationPermissionMismatch

Comment thread mlos_bench/mlos_bench/services/types/azure_authenticator_type.py Outdated

@motus Sergiy Matusevych (motus) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, although I suspect that we need to make sure that the credential has been properly initialized in get_credential() implementation - just like we do in get_auth_token(). I've pushed an update along with a few cosmetic fixes to eujing#1 - Eu Jing Chua (@eujing) please take a look

credential = self._auth_service.get_credential()
assert isinstance(
credential, TokenCredential
), f"Expected a TokenCredential, but got {type(credential)} instead."

@bpkroth Brian Kroth (bpkroth) Aug 8, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is still a late runtime error that I was trying to turn into a config load error in #819

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alright, I made a new change to #819 to handle that now.
From what I can tell the rest of this one is good, but it'd be good to get confirmation that DefaultCredential doesn't need refreshed, especially with the SP part.

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