What security benefits are provided by using stored procedures to access data?

后端 未结 9 1166
臣服心动
臣服心动 2021-02-07 20:52

I have seen some guidance which recommends that you secure a database by layering all data access through stored procedures.

I know that for SQL Server, you can secure t

9条回答
  •  眼角桃花
    2021-02-07 21:06

    In stored procedures, you can add logic controls. You can return a error code if something is not right instead of update table data directly.

    For example, you have a feedback system. Feedback can only be submitted after the administrat started the feedback campaign. It is simply updating a flag in some table. Then when user comes to submit feedback, SP can check if the flag is set.

    Select @IsFeedbackDefined = IsFeedbackDefined From sometable where ID = @ID
    
    IF @IsFeedbackDefined is Null or @IsFeedbackDefined = false 
    Begin
        Return -2   --can not submit feedback
    End
    

提交回复
热议问题