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

Refactor Azure authentication classes #2002

Merged

Conversation

jemrobinson
Copy link
Member

@jemrobinson jemrobinson commented Jul 8, 2024

✅ Checklist

  • You have given your pull request a meaningful title (e.g. Enable foobar integration rather than 515 foobar).
  • You are targeting the appropriate branch. If you're not certain which one this is, it should be develop.
  • Your branch is up-to-date with the target branch (it probably was when you started, but it may have changed since then).

🚦 Depends on

n/a

⤴️ Summary

  • Reduce Azure-connected classes to two: AzureSdk and GraphApi
  • Use our own DeferredCredential class which can cache tokens to reduce external API calls
    • use of cached tokens avoids the "stalling bug" which was otherwise triggered by making an AzureCLI call during the finally clause of a try statement
  • AzureSdkCredential provides authentication for AzureSdk using the Azure CLI
  • GraphApiCredential provides authentication for GraphApi using a browser device-code
  • Fixes a bug in http_get where we were ignoring additional pages for paged responses.
  • N.B. this removes the confirm dialogue which was applied for AzureCLI logins but not for Browser logins. If we want this, I can easily add it to both.

🌂 Related issues

Closes #2001
Closes #1980

🔬 Tests

… new GraphApiCredentialLoader rather than using the token directly
…m/.default scope (note that this only allows a subset of functions).
@jemrobinson jemrobinson requested a review from a team as a code owner July 8, 2024 14:41
Copy link
Member

@JimMadge JimMadge left a comment

Choose a reason for hiding this comment

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

Still a few gaps in the coverage in credentials.py, graph_api.py and azure_sdk.py.

Things like getting credentials from files and exception handling.

@jemrobinson
Copy link
Member Author

@JimMadge : I think this now tests all the functions under external/api. Are you happy to merge with these changes?

Copy link
Member

@JimMadge JimMadge left a comment

Choose a reason for hiding this comment

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

Just one comment, could leave for another PR if we open an issue.

tests/conftest.py Outdated Show resolved Hide resolved
@jemrobinson jemrobinson requested a review from JimMadge July 12, 2024 09:30
@jemrobinson jemrobinson merged commit bfc3662 into alan-turing-institute:develop Jul 12, 2024
11 checks passed
@jemrobinson jemrobinson deleted the 1980-stalling-bug branch January 30, 2025 11:46
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.

Simplify classes that interact with Azure CLI commands hanging
2 participants