Forum OpenACS Q&A: Re: How to stay in http: after i register in https:????

Collapse
Posted by Jorge Garcia on
Hi, Titi:
1.Your code will be very welcome 😉
If you could send me the example i will be very grateful.
2.I have tried that same aproach but with only one filter.
By some strange reason some images doesn't load in https:

3. Do you know any method to restrict the whole protocol 'https' to ONLY the folders you want?
4.There exist any trick to do so or only the filters could be used?

Regards.

/Jorge

P.D. https://openacs.org/forums/message-view?message_id=15982
The same problem for oacs 3.x
There exists some lines added by Ola Hansson, but i can't make it work very fine in oacs 4.5
Maybe this strange thing with the images was another issue.

We have modified  'admin-procs.tcl' and 'admin-init.tcl' in the folder /packages/acs-tcl/tcl

-------------------
'admin-procs.tcl'
-------------------
proc_doc ad_restrict_to_https {conn args why} {
    Redirects user to HTTPS.

    @author Allen Pulsifer (mailto:pulsifer@mediaone.net)
    @creation-date 2 November 2000
} {
        if { [ad_conn driver] == "nsopenssl" } {
            return "filter_ok"
    } else {
        append secure_url "https://[ns_info hostname][ns_conn url]"
        ns_returnredirect $secure_url
        return "filter_return"
    }
}
# Proc added====>>>
proc exit_from_https {args why} {
    if { [ns_conn driver] == "nssock" } {
        return "filter_ok"
    } elseif { [string first "/admin" [ns_conn url]] != -1 || [string first "/acs-admin" [ns_conn url]] != -1 || [string first "/register" [ns_conn url]] != -1} {
        return "filter_ok"
    } else {
        append unsecure_url "http://[ns_info hostname][ns_conn url]"
        ns_returnredirect $unsecure_url
        return "filter_return"
    }
}
# end proc added

-------------------
'admin-init.tcl'
-------------------
if { [ad_ssl_available_p] } {
    set admin_ssl_filters_installed_p 1


    db_foreach path_select {
    select package_id, site_node.url(node_id) as url from apm_packages p, site_nodes n
    where p.package_id = n.object_id
    } {
    ns_log Notice "Processing RestrictToSSL for $url"
    foreach pattern [ad_parameter -package_id $package_id RestrictToSSL "acs-subsite"] {
        ad_register_filter preauth GET "$url$pattern" ad_restrict_to_https
        ns_log Notice "URLs matching \"$url$pattern\" are restricted to SSL"
    }
    }

# Line added====>>>
    ad_register_filter preauth GET /* exit_from_https
# end line added
    db_release_unused_handles
}