oacs_dav::set_user_id (public)

 oacs_dav::set_user_id

Defined in packages/oacs-dav/tcl/oacs-dav-procs.tcl

set user_id based on authentication header

Partial Call Graph (max 5 caller/called nodes):
%3 oacs_dav::conn_setup oacs_dav::conn_setup (public) oacs_dav::set_user_id oacs_dav::set_user_id oacs_dav::conn_setup->oacs_dav::set_user_id ad_conn ad_conn (public) oacs_dav::set_user_id->ad_conn auth::authenticate auth::authenticate (public) oacs_dav::set_user_id->auth::authenticate auth::authority::get_authority_options auth::authority::get_authority_options (public) oacs_dav::set_user_id->auth::authority::get_authority_options http_auth::basic_authentication_decode http_auth::basic_authentication_decode (public) oacs_dav::set_user_id->http_auth::basic_authentication_decode

Testcases:
No testcase defined.
Source code:
    #
    # Get Authorization header.
    #
    set authorization [ns_set iget [ns_conn headers] Authorization]
    if {[string length $authorization]} {
        set credentials [http_auth::basic_authentication_decode $authorization]
        ns_log debug "\nTDAV 5.0 authentication"
        #
        # check all authorities
        #
        foreach authority [auth::authority::get_authority_options] {
            set authority_id [lindex $authority 1]
            array set auth [auth::authenticate  -username [dict get $credentials user]  -password [dict get $credentials password]  -authority_id $authority_id  -no_cookie]
            if {$auth(auth_status) ne "ok" } {
                array set auth [auth::authenticate  -email [dict get $credentials user]  -password [dict get $credentials password]  -authority_id $authority_id  -no_cookie]
            }
            if {$auth(auth_status) eq "ok"} {
            # we can stop checking
                break
            }
        }
        if {$auth(auth_status) ne "ok" } {
            ns_log debug "\nTDAV 5.0 auth status $auth(auth_status)"
            ns_returnunauthorized
            return 0
        }
        ns_log debug "\nTDAV: auth_check OpenACS 5.0 user_id= $auth(user_id)"
        ad_conn -set user_id $auth(user_id)

    } else {
        # no authenticate header, anonymous visitor
        ad_conn -set user_id 0
        ad_conn -set untrusted_user_id 0
    }
Generic XQL file:
packages/oacs-dav/tcl/oacs-dav-procs.xql

PostgreSQL XQL file:
packages/oacs-dav/tcl/oacs-dav-procs-postgresql.xql

Oracle XQL file:
packages/oacs-dav/tcl/oacs-dav-procs-oracle.xql

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