版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
UsingFine-GrainedAccessControlObjectivesAftercompletingthislesson,youshouldbeabletodothefollowing:Describehowfine-grainedaccesscontrol(FGAC)andtheVirtualPrivateDatabase(VPD)workImplementFGACortheVPDGrouppoliciesFine-GrainedAccessControl:OverviewLimitsrowaccessUsesapredicateIsreturnedfromafunctionIsassociatedwithatableorviewIsautomaticallyenforcedSELECT*FROMordersWHERE
sales_rep_id
=
406;ORDERSSELECT*FROMorders;SELECT*FROMordersWHEREsales_rep_id=152;SELECT*FROMorders;BenefitsSecurity:FGACisalwaysapplied.Simplicity:DefineonceIndependentofapplicationFlexibility:ApplydifferentaccesstodifferentSQLstatements.Grouppolicies.Highperformance:StaticanddynamicpoliciesActivepoliciesstoredinmemoryVirtualPrivateDatabaseAVirtualPrivateDatabase(VPD)combinesanapplicationcontextandFGACto:EnforcebusinessrulestolimitrowaccessUseasecureapplicationcontexttoprovidehighperformanceresolutionofuserattributes.ExamplesoftheVirtualPrivateDatabaseTheVPDallowsmultiplepoliciesonthesametable:Customerexample:Contextattribute:cust_idPredicate:customer_id=sys_context('oeapp','cust_id')Salesrepresentativeexample:Contextattribute:emp_idPredicate:sales_rep_id=sys_context('oeapp','emp_id')HowFine-GrainedAccessControlWorks1. Theuseraccessesatableorviewwithapolicy.2. Thedataservercallsthepolicyfunction.3. Thepolicyfunctionreturnsapredicate.4. Thedataserveraddsthepredicatetothestatement.5. Thedataserverexecutesthemodifiedstatement.becomesSELECT*FROMordersWHEREcustomer_id=sys_context('oeapp','cust_id');SELECT*FROMorders;ToolsThePL/SQLproceduresandpackages,suchas:SYS_CONTEXTreturnscontextattributesDBMS_SESSIONmanages:-Contexts-GlobalidentifiersDBMS_RLSmanages:-Contexts-Policies-PolicygroupsOraclePolicyManagerisaGUIthat:UsesDBMS_RLSProvidessecuritypolicyadministrationManagestheVPDandOracleLabelSecurityOraclePolicyManagerDBMS_RLSAssociatepolicieswithtablesorviews:ADD_POLICYADD_GROUPED_POLICYEnableanddisablepolicies:ENABLE_POLICYENABLE_GROUPED_POLICYRefreshpolicies:REFRESH_POLICYGrouppolicies:CREATE_POLICY_GROUPManagedrivingcontexts:ADD_POLICY_CONTEXT
DROP_POLICYDROP_GROUPED_POLICY
DISABLE_GROUPED_POLICY
REFRESH_GROUPED_POLICY
DELETE_POLICY_GROUP
DROP_POLICY_CONTEXTColumn-LevelVPDStatementsarenotalwaysrewritten.Example:ApolicyprotectstheSALARYandtheCOMMISSION_PCTcolumnsoftheEMPLOYEEStable.TheFGACis:Notenforcedforthisquery:Enforcedforthesequeries:SQL>SELECTlast_name,salary2FROMemployees;SQL>SELECTlast_nameFROMemployees;SQL>SELECT*FROMemployees;Column-LevelVPD:ExampleBEGIN dbms_rls.add_policy(object_schema=>'hr',object_name=>'employees',policy_name=>'hr_policy',function_schema=>'hr',policy_function=>'hrsec',statement_types=>'select,insert',
sec_relevant_cols=>'salary,commission_pct'
sec_relevant_col_opts=>dbms_rls.ALL_ROWS);END;/PolicyTypes:OverviewThepolicytypesspecifyhowoftenapolicyfunctionshouldbereevaluated.Thetypesare:DynamicDBMS_RLS.DYNAMIC(Default)StaticDBMS_RLS.STATICDBMS_RLS.SHARED_STATICContextsensitiveDBMS_RLS.CONTEXT_SENSITIVEDBMS_RLS.SHARED_CONTEXT_SENSITIVEShared:SharedpoliciesallowyoutosharethesamepolicyfunctionwithdifferentobjectsStaticPoliciesThepolicyfunctionisevaluatedonce.Theresultingpolicypredicateiscachedinmemory.Everystatementaccessingprotectedobjectsusesthesamepolicypredicate.exec dbms_rls.add_policy(object_schema=>'hr',object_name=>'employees',-policy_name=>'hr_policy',-function_schema=>'hr',policy_function=>'hrsec',-statement_types=>'select,insert',-policy_type=>dbms_rls.static,-sec_relevant_cols
=>'salary,commission_pct');Context-SensitivePoliciesThepolicyfunctionisevaluatedforeachsessionwhen:ThestatementisfirstparsedThereisarelatedchangeinthelocalapplicationcontextTheresultingpolicypredicateiscachedintheuser’ssessionmemory.exec dbms_rls.add_policy(object_schema=>'hr',object_name=>'employees2',-policy_name=>'hr_policy2',-function_schema=>'hr',policy_function=>'hrsec2',-statement_types=>'select,insert',-policy_type=>dbms_rls.context_sensitive,-sec_relevant_cols
=>'salary,commission_pct');SharingPolicyFunctionsdepartmentscountriesemp_vemployeesSamepolicy
functionExceptionstoFGACPoliciesPoliciesarenotenforcedfor:DIRECTpathexportUserswithDBAprivileges(AS
SYSDBA)UsersgrantedEXEMPT_ACCESS_POLICYImplementingaVPD1. CreateaPL/SQLpackagethatsetsthecontext.2. Createanapplicationcontext:Isassociatedwiththepackagecreatedinstep1Preventsthecontextfrombeingchanged3. Writethefunctionthatcreatesapredicate:Usetheapplicationcontextcreatedinstep2.ReturnapredicateforaWHEREclause.4.Createapolicy:AssociatesthefunctionwithatableCausesthepredicatetobeaddedtotheWHEREclausesStep3:WritetheFunctionThat
CreatesaPredicateCREATEPACKAGEBODYoe_securityASFUNCTIONcust_order(object_schema VARCHAR2,object_name VARCHAR2)RETURNVARCHAR2ISBEGINRETURN'customer_id=sys_context(''oeapp'',''cust_id'')';ENDcust_order;ENDoe_security;TestingtheSecurityFunctionSQL>SELECToe_security.cust_order('a','b')
FROMdual;OE_SECURITY.CUST_ORDER('A','B')---------------------------------------------customer_id=SYS_CONTEXT('oeapp','cust_id')WritingaFunctionThatReturns
DifferentPredicatesTheownerofthetablehasaccesstoallrows:Salesrepresentativesseeonlytheirorders:Customerscanseeonlytheirownorders:Otherusershavenoaccess:RETURN'sales_rep_id= sys_context(''hrapp'',''emp_id'')';RETURN'customer_id =sys_context(''oeapp'',''cust_id'')';RETURN'1=2';RETURN'1=1';Step4:CreateaPolicyCreatethepolicyasfollows:Argumentsincludethefollowing:Associatedtable:OE.ORDERSPolicyname:OE_POLICYFunction:SECURE.OE_SECURITY.CUST_ORDERAppliesto:SELECTdbms_rls.add_policy( object_schema=>'oe',object_name=>'orders',
policy_name=>'oe_policy', function_schema=>'secure',
policy_function=>'oe_security.cust_order', statement_types=>'select')PartitionedFine-GrainedAccessControlApplication-drivensecuritypoliciesDifferentpoliciesapply,dependingontheactivedrivingcontextPoliciescanbedevelopedindependently.Thedefaultpolicyalwaysapplies.UsefulwhenhostingapplicationsDefaultpolicyOrder-entrypolicygroupInventorypolicygroupANDANDOrdersGroupingPolicies1. Determinethedefaultpolicies.2. Setupadrivingcontextforeachtable:a. Createthecontext.b. Createthefunctionthatsetsthecontext.c. Makethecontextthedrivingcontext.3. Createapolicygroupforeachapplication.4. Addeachpolicytotheappropriategroup.DefaultPolicyGroupApredefineddefaultpolicygroupisalwaysapplied.ItisnamedSYS_DEFAULT.Eachobjecthasadefaultgroup.CreatingaDrivingContextCreatethecontext:Createtheprocedurethatsetsthecontext:CREATECONTEXTapp_driverUSINGsecure.apps_cxt_pkg;CREATEORREPLACEPACKAGEBODYsecure.apps_cxt_pkg PROCEDUREset_driver(policy_groupVARCHAR2)...APP_DRIVERSECURE.APPS_CXT_PKGMakingtheContextaDrivingContextAssociatethedrivingcontextwithatable:dbms_rls.add_policy_context(object_schema=>'OE',object_name=>'ORDERS',namespace=>'APP_DRIVER',
attribute=>'ACTIVE_APP')APP_DRIVEROrdersCreatingaPolicyGroupCreatetheOEgroup:CreatetheACgroup:dbms_rls.create_policy_group(object_schema=>'OE',object_name=>'ORDERS',policy_group=>'OE_GRP');dbms_rls.create_policy_group ('OE','ORDERS','AC_GRP');AddingaPolicytoaGroup1. AddtheOE_SECURITYpolicytotheOEgroup:2. AddtheAC_SECURITYpolicytotheACgroup:dbms_rls.add_grouped_policy(object_schema=>'oe',object_name=>'orders',policy_group=>'oe_grp',policy_name=>'oe_security',function_schema=>'secure',policy_function=>'oe_context');dbms_rls.add_grouped_policy( 'oe','orders','ac_grp','ac_security', 'secure','ac_context');GuidelinesRestrictSELECTandDMLwiththesamepolicy.Ifthereisnocontext,SYS_CONTEXTreturnsNULL.Youcannotselectfromthetablewithinthepolicy.Avoidrecursivecontexts.Lookinthesessiontracefiletoresolveerrors.PerformanceForbestperformance:ConsiderindexingthecolumninthepredicateDonotusesubqueriesinthepredicateDonotuseliteralsinthepredicateUseSTATIC_POLICY=TRUEwhenpossibleUseDBMS_RLS.STATIC_POLICYorSHARED_STATIC_POLICYwhenpossibleExportandImportForexportandimport,considerthefollowingguidelines:
Torestorethepolicies,theusermusthavetheexecuteprivilegeontheDBMS_RLSpackage.Ifauserattemptstoexportatablewithfine-grainedaccesspoliciesenabled,thenonlythoserowsthattheexporterisprivilegedtoreadareexported.OnlySYSoraus
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 商业航天行业2026年投资策略分析报告:星辰大海拐点已至
- 财务独立协议书
- 货车散伙协议书
- 购买狗狗协议书样本
- 2025年生产管理科安全生产管理职责培训
- 2025年副总经理职业健康安全职责培训
- 1234加强班组建设培训课件
- 小于胎龄儿护理查房
- 高血压患者护理专项考核试题及答案解析
- 珠三角通信基站备用电源铅酸电池(2V1000Ah)生产项目可行性研究报告
- 储能电站设备采购与管理方案
- GB/T 7659-2025焊接结构用铸钢件
- 2025年中国石化齐鲁石化招聘笔试备考题库(带答案详解)
- 人工智能 可信赖 第1部分:通则 征求意见稿
- 各国国旗介绍课件
- 音乐在小学生心理健康教育中的价值及教学实践
- 职业压力管理学习通超星期末考试答案章节答案2024年
- 网络传播概论(第5版)课件 第1、2章 网络媒介的演化、网络重构的传播
- 茶艺课教学教案文档
- (正式版)HGT 6270-2024 防雾涂料
- 能源的获取和利用途径
评论
0/150
提交评论