从Python中的桌面应用程序连接到Azure SQL数据库:Azure AD授权

发布于 2025-02-09 04:34:32 字数 280 浏览 1 评论 0原文

我有一个用Python编写的桌面应用程序,该应用将一些数据上传到Azure上托管的SQL数据库(SQL Server)。使用Azure AD MFA对访问进行身份验证。该应用程序使用PYODBC。这有点麻烦,因为每次使用该应用程序时,我都需要输入密码和授权代码。我希望该应用程序自动获得身份验证。我不想使用一些简单的解决方法,例如使应用程序直接访问数据库规避广告授权。 第二个问题是该应用程序继承了我所有的访问权限,这不需要,因为它将数据加载到临时表中。我了解我可以在Azure AD上注册该应用程序并获得访问令牌。但是,我不知道下一步该怎么做。

I have a desktop app written in Python which uploads some data to an SQL database (SQL Server) hosted on Azure. The access is authenticated using Azure AD MFA. The application uses pyodbc. This is a bit cumbersome because I need to type in my password and authorization code every time I use the application. I want the application to get authenticated automatically. I do not want to use some simple workarounds like giving the app direct access to the database circumventing AD authorization.
The second problem is that the application inherits all my access privileges, which it does not need since it loads data to temporary tables. I understand that I can register the application with the Azure AD and obtain an access token. However, I do not know what to do next.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒废 2025-02-16 04:34:32

每次使用该应用程序时,我都需要输入密码和授权代码。我希望该应用程序自动获得身份验证。

  • 您可以使用Active Directory集成身份验证方法自动登录到您的应用程序。
  • 为此,您需要使用Azure AD合并您的本地Active Directory实例。
  • 如果您签署了域名的机器,则此功能。您可以访问Azure SQL数据源,而无需通过此模式提示凭据。
  • ,但是您无法设置SQLConnection的凭据属性。
  • 有关更多信息,您可以参考此< a href =“ https://learn.microsoft.com/en-us/sql/connect/connect/ado-net/sql/azure-azure-active-directory-authentication?view = sql-sql-server-server-ver16集成 - 授权“ rel =” nofollow noreferrer“> Microsoft文档。
  • 也,当您引用访问tokens时,这里是 link 提供完整的信息。

I need to type in my password and authorization code every time I use the application. I want the application to get authenticated automatically.

  • You can use Active Directory Integrated Authentication method to login to your appication automatically.
  • For this you need to federate your on-premises active directory instance with Azure AD.
  • With this if you are signing into a domain-joined machine. You can access Azure SQL data sources without being prompted for credentials with this mode.
  • But you can't set the credential property of sqlconnection.
  • For more information you can refer this Microsoft Document.
  • Also, as you are referring Access tokens here is the link with complete information.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文