版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【合规与社会责任】环境健康安全(EHS)专项审计计划
- 广东南宁二中2025-2026学年第二学期七年级第十六周数学课堂训练(含答案)
- 电子商务 3-2 供应商选择
- 设计承包合同(范本)
- 电子商务商品知识(第三版) 课件 1-2 品牌设计
- 峨眉山市2027届数学四上期末学业质量监测模拟试题含解析
- 湖北省孝感市大悟县2027届四上数学期末调研模拟试题含解析
- 广西壮族百色市田林县2027届六上数学期末经典试题含解析
- 湖北省天门市多宝镇第二中学2027届数学四上期末质量跟踪监视模拟试题含解析
- 吃转基因食品可以改变基因吗
- 2026版《残疾人保障和发展“十五五”规划》学习与解读
- 2026年保密知识试题库含答案
- 2026年广东省春季高考(学考)语文真题(含解析)
- 给水管道工程监理实施细则
- 2026年云南省基层法律服务工作者管理题库
- 军考2026年考试题及答案
- 中国骨科大手术vte预防指南(2025版)
- 2026深静脉血栓形成诊断和治疗指南(第四版)全面解读
- 雨课堂学堂在线学堂云医学数据分析的SPSS软件实现(山东大学)单元测试考核答案
- 车间内叉车管理制度(3篇)
- (正式版)DB37∕T 4983-2025 《无人机半航空瞬变电磁探测技术规程》
评论
0/150
提交评论