http_auth::set_user_id (public)

 http_auth::set_user_id

Defined in packages/acs-tcl/tcl/http-auth-procs.tcl

Get the user_id from HTTP authentication headers. NOTE: This should be handled through SSL since plain HTTP auth is easy to decode

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

Testcases:
No testcase defined.
Source code:

    # should be something like "Basic 29234k3j49a"
    set authorization [ns_set iget [ns_conn headers] Authorization]
    if {[string length $authorization] > 0} {
        set credentials [http_auth::basic_authentication_decode $authorization]
        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
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ]
Show another procedure: