简体   繁体   English

Windows 身份验证 - 限制 SQL Server 后端访问

[英]Windows Authentication - Restrict SQL Server Backend Access

The Problem问题

Good Morning!早上好! I work on an application team that supports a few applications which utilize SQL Server for data storage.我在一个应用程序团队工作,该团队支持一些利用SQL Server进行数据存储的应用程序。 Recently, our Database Support team decided that SQL Authentication was no longer permissible (for security and logging reasons) and so my team was forced to convert all connections to Windows Authentication including several dedicated Service IDs that our applications had been utilizing for data retrieval.最近,我们的数据库支持团队决定不再允许SQL Authentication (出于安全和日志记录的原因),因此我的团队被迫将所有连接转换为Windows Authentication包括我们的应用程序一直用于数据检索的几个专用服务 ID。

First, let me say there most certainly are advantages to moving to Windows Authentication , I am not trying to dispute that.首先,让我说转移到Windows Authentication肯定有好处,我不想对此提出异议。 But this change has raised a huge problem for us... by switching our Service IDs to Windows Authentication we have now opened up our back-end databases to every internal business user with front-end application access.但是这种变化给我们带来了一个巨大的问题......通过将我们的服务 ID 切换为Windows Authentication我们现在向每个具有前端应用程序访问权限的内部业务用户开放了我们的后端数据库。

MS Access is pushed out to every user desktop and a few superusers even have access to SSMS . MS Access被推送到每个用户桌面,一些超级用户甚至可以访问SSMS At this point we are relying entirely on user ignorance to prevent internal users from accessing the back-end database directly.在这一点上,我们完全依靠用户无知来阻止内部用户直接访问后端数据库。 And given that certain roles have elevated DML rights, this presents a possibility for some nasty data consequences.鉴于某些角色提升了DML权限,这可能会导致一些令人讨厌的数据后果。

This new enterprise standard has left my team stuck between a rock and a hard place at this point so we looking for any database, account or architecture solution that would allow us to restrict user access to front-end only.这个新的企业标准让我的团队在这一点上陷入困​​境,所以我们正在寻找任何数据库、帐户或架构解决方案,允许我们限制用户仅访问前端。

Questions问题

  • Has anyone else run into this problem?有没有其他人遇到过这个问题? Is there an architectural solution we are missing that would allow us to eliminate SQL Authentication without exposing our databases?是否有我们缺少的架构解决方案可以让我们在不暴露我们的数据库的情况下消除SQL Authentication
  • Does anyone know of a way to restrict access to a SQL Server database to only certain connection methods?有谁知道限制对SQL Server数据库的访问仅限于某些连接方法的方法? I'm wondering if there is a way to designate a specific ID (or role) as only allowing a connection through a front end (and eliminate ODBC connections entirely).我想知道是否有办法将特定 ID(或角色)指定为只允许通过前端的连接(并完全消除ODBC连接)。
  • Does anyone have any clever workarounds?有没有人有任何聪明的解决方法?

-------------EDIT--------------- - - - - - - -编辑 - - - - - - - -

A couple people brought up a good point about role access so I wanted to clarify our former and current solution... Previously, all role access was managed on the front-end and data retrieval was handled entirely by private system SQL Authenticated IDs to which end users had no visibility.有几个人提出了一个关于角色访问的好点,所以我想澄清我们以前和当前的解决方案......以前,所有角色访问都在前端管理,数据检索完全由私有系统 SQL 身份验证 ID 处理,其中最终用户没有可见性。

When we were forced to eliminate these SQL Auth IDs, we created a similar role-based setup on the back-end database as existed on the front end.当我们被迫消除这些 SQL 身份验证 ID 时,我们在后端数据库上创建了与前端类似的基于角色的设置。 Active Directory Groups were created to house different groups of users and these groups were assigned specific role privileges in the database.创建 Active Directory 组以容纳不同的用户组,并且这些组在数据库中被分配了特定的角色权限。 So currently access is limited by role as much as feasible.因此,目前访问权限受角色限制尽可能多。

The problem is that even the lowest privileged roles have INSERT, UPDATE and DELETE access to some tables (access which is normally controlled through code).问题是,即使是最低权限的角色也具有对某些表的 INSERT、UPDATE 和 DELETE 访问权限(通常通过代码控制的访问权限)。 So while we were able to mitigate risk somewhat by utilizing database roles, we still have areas where a user can bypass front end protections by logging directly into the database.因此,虽然我们能够通过利用数据库角色在一定程度上降低风险,但我们仍然存在用户可以通过直接登录数据库来绕过前端保护的区域。

EDIT: Question clarification makes this answer obsolete, but leaving it for reference since some comments discuss it.编辑:问题澄清使此答案过时,但由于一些评论讨论了它,因此将其留作参考。

Assuming you mean that you have to (based on your architecture) allow access to the DB to each windows user account, one options is to use database roles.假设您的意思是您必须(基于您的架构)允许每个 Windows 用户帐户访问数据库,一个选项是使用数据库角色。

You disable public access to your database, then define a set of database roles, depending on your use cases.您禁用对数据库的公共访问,然后根据您的用例定义一组数据库角色。 Each role is granted permissions such that members of that role are able to manipulate the data they need and or work with the objects they need.每个角色都被授予权限,以便该角色的成员能够操作他们需要的数据和/或使用他们需要的对象。 Users are then mapped into the roles they require.然后将用户映射到他们需要的角色。 When connecting to your database, the user will be granted permissions according to the roles they are members of.连接到您的数据库时,用户将根据他们所属的角色被授予权限。

For example, we have a role in one of our databases named MyAppUser (our name is actually related to the app which uses the db), which is designed for end users to read and insert data only.例如,我们在我们的一个名为MyAppUser的数据库中有一个角色(我们的名字实际上与使用 db 的应用程序相关),该角色专为最终用户读取和插入数据而设计。 These can be created simply as follows:这些可以简单地创建如下:

CREATE ROLE [MyAppUser]

The role is granted just the permissions it to the relevant schemas or tables (assume all our "public" tables are in dbo schema for now).该角色仅被授予对相关模式或表的权限(假设我们所有的“公共”表现在都在 dbo 模式中)。

GRANT SELECT ON SCHEMA::[dbo] TO [MyAppUser] 
GRANT INSERT ON SCHEMA::[dbo] TO [MyAppUser]
GRANT DELETE ON SCHEMA::[dbo] TO [MyAppUser]

Each user who should have this public read-write access is then mapped into the relevant role.然后,每个应该具有此公共读写访问权限的用户都被映射到相关角色。

ALTER ROLE [MyAppUser] ADD MEMBER [UserName]

This separates users and roles / permissions within your database and allows you to have a single point of entry to control who has access to what in your databases.这将您的数据库中的用户和角色/权限分开,并允许您拥有一个入口点来控制谁可以访问您数据库中的内容。

By having the "View Definition" permission denied by default (to end users), they won't be able to "explore" the database / view table definitions etc using access, or even SSMS.默认情况下(对最终用户)拒绝“查看定义”权限,他们将无法使用访问甚至 SSMS 来“探索”数据库/查看表定义等。

NB: SSMS provides wizards for managing and viewing permissions and memberships which are very handy for getting things initially setup / tested / fiddled around with.注意:SSMS 提供了用于管理和查看权限和成员资格的向导,这些向导对于初始设置/测试/摆弄的东西非常方便。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM