security::get_register_subsite (public)

 security::get_register_subsite

Defined in packages/acs-tcl/tcl/security-procs.tcl

Returns a URL pointing to the subsite, on which the register/unregister should be performed. If there is no current connection, the main site url is returned. TODO: util_current_location and security::get_register_subsite can be probably cached, when using the following parameters in the cache key: - host header field - [ns_conn location] - ... also [security::get_register_subsite] could/should be cached

Author:
Gustaf Neumann

Partial Call Graph (max 5 caller/called nodes):
%3 ad_get_external_registries ad_get_external_registries (public) security::get_register_subsite security::get_register_subsite ad_get_external_registries->security::get_register_subsite ad_get_login_url ad_get_login_url (public) ad_get_login_url->security::get_register_subsite ad_get_logout_url ad_get_logout_url (public) ad_get_logout_url->security::get_register_subsite auth::password::email_password auth::password::email_password (private) auth::password::email_password->security::get_register_subsite boomerang::get_relevant_subsite boomerang::get_relevant_subsite (private) boomerang::get_relevant_subsite->security::get_register_subsite ad_get_node_id_from_host_node_map ad_get_node_id_from_host_node_map (private) security::get_register_subsite->ad_get_node_id_from_host_node_map apm_package_id_from_key apm_package_id_from_key (public) security::get_register_subsite->apm_package_id_from_key apm_package_key_from_id apm_package_key_from_id (public) security::get_register_subsite->apm_package_key_from_id parameter::get parameter::get (public) security::get_register_subsite->parameter::get permission::permission_p permission::permission_p (public) security::get_register_subsite->permission::permission_p

Testcases:
No testcase defined.
Source code:

    util::split_location [util_current_location] current_proto current_host current_port
    set config_hostname [dict get [util_driver_info] hostname]
    set UseHostnameDomainforReg [parameter::get  -package_id [apm_package_id_from_key acs-tcl]  -parameter UseHostnameDomainforReg  -default 0]
    set require_qualified_return_url $UseHostnameDomainforReg
    set host_node_id [ad_get_node_id_from_host_node_map $current_host]

    if { $host_node_id > 0 } {
        #
        # We are on a host-node mapped subsite
        #
        set package_id  [site_node::get_object_id -node_id $host_node_id]
        set package_key [apm_package_key_from_id $package_id]
        if {$package_key eq "acs-subsite"} {
            #
            # The host-node-map points to a subsite, use this for
            # login.
            #
            set url /
            set subsite_id $package_id

            if {$UseHostnameDomainforReg} {
                set url [subsite::get_element -subsite_id $package_id -element url]
                set url [security::get_qualified_url $url]
                # We have a fully qualified url, but we have to remap
                # the URL to the configured hostname, since
                # get_qualified prepends the [ad_conn location], which
                # points to the virtual hostname.
                set url [security::replace_host_in_url -hostname $config_hostname $url]
            }
        } else {
            #
            # The host-node-map points to an application package and
            # not to a subsite. We have to provide logins via next
            # available subsite.
            #
            set subsite_id [site_node::closest_ancestor_package  -node_id $host_node_id  -package_key acs-subsite  -include_self  -element "object_id"]
            set url [subsite::get_element -subsite_id $subsite_id -element url]
            set url [security::get_qualified_url $url]
            set url [security::replace_host_in_url -hostname $config_hostname $url]
            set require_qualified_return_url 1
        }
    } else {
        #
        # We are on normal subsite
        #
        if { [ns_conn isconnected] } {
            set url [subsite::get_element -element url]
            #
            # Check to see that the user (most likely "The Public"
            # party, since there's probably no user logged-in)
            # actually have permission to view that subsite, otherwise
            # we'll get into an infinite redirect loop.
            #
            array set site_node [site_node::get_from_url -url $url]
            set subsite_id $site_node(object_id)
            if { ![permission::permission_p -no_login  -object_id $subsite_id  -privilege read  -party_id 0] } {
                set url /
            }
        } else {
            #
            # If we are not connected, there can't be a virtual
            # server, so we assume to perform the login on the main
            # subsite.
            #
            set url /
            set host_node_id [dict get [site_node::get_from_url -url $url] node_id]
            set subsite_id [site_node::get_object_id -node_id $host_node_id]
        }
        if {$UseHostnameDomainforReg} {
            set url [security::get_qualified_url $url]
            set url [security::replace_host_in_url -hostname $config_hostname $url]
        }
    }
    return [list  url $url  subsite_id $subsite_id  require_qualified_return_url $require_qualified_return_url  host_node_id $host_node_id]
Generic XQL file:
packages/acs-tcl/tcl/security-procs.xql

PostgreSQL XQL file:
packages/acs-tcl/tcl/security-procs-postgresql.xql

Oracle XQL file:
packages/acs-tcl/tcl/security-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: