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

Not connecting via AAD when Local Auth is disabled. #2205

Closed
NonlinearMusings opened this issue Oct 27, 2023 · 11 comments · Fixed by #2277
Closed

Not connecting via AAD when Local Auth is disabled. #2205

NonlinearMusings opened this issue Oct 27, 2023 · 11 comments · Fixed by #2277
Assignees
Labels
blocked Can't make progress to due external reasons feature
Milestone

Comments

@NonlinearMusings
Copy link
Member

Disabling Local Auth throws "Error: Local Authorization is disabled. Use an AAD token to authorize all requests." error. As I've already authenticated to Azure in VS Code via AAD, I would expect those credentials to be sufficient for connecting to Cosmos too. Note that everything works as expected when Local Auth is enabled.

@JasonYeMSFT
Copy link
Contributor

@NonlinearMusings Which Cosmos service are you using? Currently only PostgreSQL Flexible in the extension has AAD authentication support. For other types of Cosmos services, you still need to use access keys or passwords to authenticate.

@NonlinearMusings
Copy link
Member Author

NonlinearMusings commented Oct 28, 2023

This is for the Cosmos SQL API. Do we have a Roadmap for enabling AAD with this extension for SQL API?

@JasonYeMSFT JasonYeMSFT added this to the 0.21.0 milestone Nov 20, 2023
@JasonYeMSFT
Copy link
Contributor

This will be something we prioritize for the next extension release. I am working on a proof of concept. Once I get a more concrete timeline I'll update it here.

@ludwhe
Copy link

ludwhe commented Jan 31, 2024

Really into this being added as well, would really make my workflow much easier!

@JasonYeMSFT JasonYeMSFT self-assigned this Feb 2, 2024
@JasonYeMSFT JasonYeMSFT added the blocked Can't make progress to due external reasons label Feb 16, 2024
@NonlinearMusings
Copy link
Member Author

@JasonYeMSFT - any updates on this?

@arwinlashawn
Copy link

Hi @JasonYeMSFT, seeing some promising progress with OAuth support changes merged already. Do we have an ETA on when AAD auth for Cosmos DB will be released for this extension?

@JasonYeMSFT
Copy link
Contributor

I'll work on the release. Should be ready in a few days.

@JasonYeMSFT
Copy link
Contributor

Out of curiosity, what roles do you use to authenticate with your Cosmos DB resources (e.g. Cosmos DB Account Reader or Cosmos DB Operator)? Even if the local auth is disabled, Cosmos DB Operators will still be able to list keys and will confuse my credential selection. Some users might need to manually override it in the setting.

@arwinlashawn
Copy link

arwinlashawn commented Apr 25, 2024

@JasonYeMSFT Great news. Generally, for data-plane RBAC access on Cosmos DB, we would assign either of these two built-in roles to the AAD principal.

Example of assigning the role to an AAD principal

If only data-plane access permissions are needed, this is the way to go as it aligns with the principle of least privilege (no access to Portal, etc).

Note: Have tested the above by accessing cosmos.azure.com/aad, authenticating with an AAD principal with Cosmos DB Built-in Data Reader role, and managing to view Cosmos DB data. Feel free to reach out to me directly on Teams if you need assistance on testing this.

@JasonYeMSFT
Copy link
Contributor

I published the 0.22.0 vsix on GitHub. You may install it and try it. You might need to enable the Azure Databases > Use Cosmos OAuth setting to tell the extension to use your MS Entra ID in case you still have the permission to list database keys even though local auth has been disabled. I will publish the gallery release shortly after.

@arwinlashawn
Copy link

Thanks a lot @JasonYeMSFT for promptly addressing this. Yes, I needed to enable the "Azure Databases: Use Cosmos OAuth" extension setting to make AAD auth work.

A slight note: After authenticating with my principal, it took quite a while (approx. 5 minutes) for the authentication to fully complete so I can view the underlying Cosmos DB data successfully. Not sure if this is by design. Will create a separate issue if I can reproduce this consistently.

@microsoft microsoft locked and limited conversation to collaborators Jun 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked Can't make progress to due external reasons feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants