xo::ProtocolHandler instproc preauth (public)

 <instance of xo::ProtocolHandler[i]> preauth args [ args... ]

Defined in packages/xotcl-core/tcl/50-protocol-handler-procs.tcl

Handle authorization. This method is called via ns_filter.

Parameters:
args

Partial Call Graph (max 5 caller/called nodes):
%3 ad_conn ad_conn (public) security::RestrictLoginToSSLP security::RestrictLoginToSSLP (public) security::secure_conn_p security::secure_conn_p (public) xo::ProtocolHandler instproc preauth xo::ProtocolHandler instproc preauth xo::ProtocolHandler instproc preauth->ad_conn xo::ProtocolHandler instproc preauth->security::RestrictLoginToSSLP xo::ProtocolHandler instproc preauth->security::secure_conn_p

Testcases:
No testcase defined.
Source code:
#:log "--preauth args=<$args>"

# Restrict to SSL if required
if { [security::RestrictLoginToSSLP]  && ![security::secure_conn_p] } {
  ns_returnunauthorized
  return filter_return
}

#
# Set common data for all kind of requests. A possible outcome is
# that we cannot proceed (authentication failure), so we have
# to trap such cases.
try {
  :initialize
} trap {AUTH UNAUTHORIZED} {errorMsg} {
  :log "not authorized: $errorMsg"
  ns_returnunauthorized
  return filter_return
} on error {errorMsg} {
  ns_log error "ProtocolHandler: exception during initialization: $errorMsg"
  return filter_return
}

if {${:user_id} == 0} {
  #
  # Check, if we are running under the regression test. For this,
  # the nsv must exist and the peeraddr must be the regression
  # test. If this is all true, accept the user_id if provided.
  #
  if {[nsv_array exists aa_test]
      && [nsv_get aa_test logindata logindata]
      && [ns_conn peeraddr] eq [dict get $logindata peeraddr]
    } {
    #ns_log notice logindata=$logindata
    if {[dict exists $logindata user_id]} {
      ad_conn -set user_id [dict get $logindata user_id]
      ad_conn -set untrusted_user_id [dict get $logindata user_id]
      set :user_id [ad_conn user_id]
    }
  } else {
    # for now, require for every user authentication
    :log "not authorized 2 uri ${:uri} conn-url [ns_conn url]"
    if {${:uri} ne "xxx/principal/"} {
      ns_returnunauthorized
      return filter_return
    }
  }
}

:log "--preauth filter_ok - user_id ${:user_id}"
return filter_ok
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: