开发者

Restrict stored procedure to only perform SELECT operations

开发者 https://www.devze.com 2022-12-20 00:34 出处:网络
Is is possible to restrict a stored proc to only SELECT from a database. I want a stored proc which only selects data to execute correctly and a stored proc with UPDATE, CREATE, DELETE operations to

Is is possible to restrict a stored proc to only SELECT from a database.

I want a stored proc which only selects data to execute correctly and a stored proc with UPDATE, CREATE, DELETE operations to return an开发者_开发知识库 error indicating insufficient permissions.

I am using Sybase 12.5


I think you're looking at the problem the wrong way. Essentially, once you give a user execute permission to a store procedure, they can execute that store procedure no matter what it does.

I think what you want to do is assign a "read-only" client role to your database and grant SELECT permissions as well as the execute permission on only the stored procedures that read data from the database. Add users to that role instead of granting them SELECT access on the database.


Separate writing and selecting actions to different procedures. And then allow selecting user to execute selecting procedures and writing user to execute selecting and writing procedures. This trick works pretty well with PostgreSQL.

0

精彩评论

暂无评论...
验证码 换一张
取 消