是否有适当的挂钩用于拦截OpenACS / AOLServer系统的所有POST?

时间:2013-12-08 22:56:30

标签: http tcl openacs aolserver

我想禁用所有POST到OpenACS / AOLServer安装。是否有一个很好的单一地方 - 请求挂钩或包装/中间件 - 来做到这一点?

(如果拦截可以让一些URI模式或登录用户通过,则加分。)

1 个答案:

答案 0 :(得分:6)

是的,这很容易做到。你可以在这里选择:你可以注册一个proc来运行而不是所有的POST,或者你可以注册一个过滤器在POST之前运行并过滤掉某些用户或其他什么。我认为过滤器是更好的选择。

要执行此操作,请使用ns_register_procns_register_filter(使用preauth)注册您的过程或过滤器。将以下代码放在OpenACS包的tcl文件夹下的.tcl文件中,或者放在主AOLserver / web / servername / tcl目录下。

过滤示例:

ns_register_filter preauth POST / filter_posts
proc filter_posts {} {
    set user_id [ad_verify_and_get_user_id]
    set list_of_allowed_user_ids [21 567 8999] 
    if {[lsearch -exact $list_of_allowed_user_ids $user_id] == -1 } {
      #this user isn't allowed - so redirect them
      ns_returnredirect "/register/"
      # tell AOLserver to abort this thread
      return filter_return
    } else {
      # this user is allowed, tell AOLserver to continue
      return filter_ok
    }
}

Proc例:

 ns_register_proc POST / handle_posts
    proc handle_posts {} {
        ns_returnredirect "http://someotherwebsite.com"
    }