XDB取消浏览器认证

Posted on September 22, 2009

APEX安装后,默认访问路径为http://host:port/apex/,如果直接访问根目录,会弹出浏览器认证窗口要求登录。对于多数浏览器,比如IE或者Firefox都没有问题,但是少数浏览器,会自动访问网站根目录,比如查找默认favicon,此时会时常弹出浏览器登录认证窗口,虽然可以直接取消,但是非常烦人。原因便是XDB对用户ANONYMOUS账号权限的设定,访问apex之外的目录需要登录。这个认证窗口,是可以取消的。

在安装APEX时,最后步骤要求UNLOCK ANONYMOUS账号:

ALTER USER ANONYMOUS ACCOUNT UNLOCK;

该操作启用了ANONYMOUS账号,但是并没有赋予匿名访问XDB Repository的权限。

进入$ORACLE_HOME/RDBMS/Admin,用sysdba权限登录执行:

SQL>@epgstat

检查Allow repository anonymouse access值,默认为false,即默认禁止匿名访问根目录。我们需要将该值修改为true。

所有XDB的配置都存放在xdbconfig.xml中,但是该文件需要编程修改。查看路径为:
1. EM用sysdba登录。
2. Database Instance > XML Database Resources > View XML Database Resource: xdbconfig.xml

默认httpconfig节点中并没有allow-repository-anonymous-access的配置,EM中无法修改该文件,我们需要用以下代码添加节点:

DECLARE
  l_configxml xmltype;
  l_value     VARCHAR2(5) := 'true'; -- (true/false)
BEGIN
  l_configxml := dbms_xdb.cfg_get();

  IF l_configxml.existsnode('/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access') = 0 THEN
    -- Add missing element.
    SELECT insertchildxml(l_configxml,
                          '/xdbconfig/sysconfig/protocolconfig/httpconfig',
                          'allow-repository-anonymous-access',
                          xmltype('' ||
                                  l_value || ''),
                          'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"')
      INTO l_configxml
      FROM dual;
  ELSE
    -- Update existing element.
    SELECT updatexml(dbms_xdb.cfg_get(),
                     '/xdbconfig/sysconfig/protocolconfig/httpconfig/allow-repository-anonymous-access/text()',
                     l_value,
                     'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"')
      INTO l_configxml
      FROM dual;
  END IF;

  dbms_xdb.cfg_update(l_configxml);
  dbms_xdb.cfg_refresh;
END;

重启数据库后检查epgstat:
epgstat

打开匿名访问权限是存在安全风险的,最好是设置一下各目录的访问权限。如果设置匿名访问仅仅是为了避免弹出认证窗口,则不妨直接修改根路径的映射。如:

alter session set current_schema = XDB;

begin
    dbms_epg.create_dad('APEX','/*');
    dbms_epg.set_dad_attribute('APEX','database-username','ANONYMOUS');
    dbms_epg.set_dad_attribute('APEX','default-page','apex');
    dbms_epg.set_dad_attribute('APEX','document-table-name','wwv_flow_file_objects$');
    dbms_epg.set_dad_attribute('APEX','document-path','docs');
    dbms_epg.set_dad_attribute('APEX','nls-language','american_america.al32utf8');
    dbms_epg.set_dad_attribute('APEX','document-procedure','wwv_flow_file_mgr.process_download');
    dbms_epg.set_dad_attribute('APEX','request-validation-function','wwv_flow_epg_include_modules.authorize');
end;
/

这样配置,就可以直接从根路径访问APEX应用了。

参考:
1. 官方文档《Oracle® XML DB Developer’s Guide》中“Anonymous Access to Oracle XML DB Repository using HTTP”章节。
2. OTN Forum: http://forums.oracle.com/forums/thread.jspa?threadID=641846&start=0&tstart=0

Related Posts

  1. APEX Listener 增设管理界面
  2. Oracle Application Express Listener

» Filed Under APEX Print This Post Print This Post

Comments

Leave a Reply