Hi, Maxim!

It seems I have misinterpreted your question then :).

For the first part, you can use the www_challenge()[1] function, which I think it does exactly what you want: sends a reply with the authentication header.

if (!python_exec("www_authenticate")) {
    www_challenge(""); # take the domain from the request.
    exit;
};

The only issue with this code is perhaps figuring out the domain to use for challenge. My example simply takes the same domain as presented in the REGISTER To header. If you want to use a different domain, you need to somehow return it in the script.

Regarding the last part, I am not sure who populates the $contact variable, but a simple save() should do the trick.

[1] http://www.opensips.org/html/docs/modules/2.1.x/auth#id293652

Best regards,

Răzvan Crainea
OpenSIPS Solutions
www.opensips-solutions.com

On 02/20/2017 11:23 AM, Maxim Sobolev wrote:
Hi Razvan, this is the code from SER 2.0. There is no equivalent for "s:digest_challenge" or "s:contact" AVPs as far as I can tell looking to the code in question in OpenSIPS.

-Max

On Mon, Feb 20, 2017 at 12:25 AM Răzvan Crainea <raz...@opensips.org <mailto:raz...@opensips.org>> wrote:

    Hi, Maxim!

    The code you are using now should do what you request. t_newtran()
    returns 0 for retransmissions, therefore for the second message
    (retransmission) that will run the script, t_newtran() will
    immediately absorb the message and return without executing any
    further instructions.

    Best regards,

    Răzvan Crainea
    OpenSIPS Solutions
    www.opensips-solutions.com <http://www.opensips-solutions.com>

    On 02/17/2017 09:15 PM, Maxim Sobolev wrote:
    P.S. python_exec("www_authenticate") does not do any magic here,
    it's just figures out the right domain to use based on some
    business rules and then calls www_authenticate() with that parameter.

    On Fri, Feb 17, 2017 at 11:12 AM, Maxim Sobolev
    <sobo...@sippysoft.com <mailto:sobo...@sippysoft.com>> wrote:

        Hi guys,

        We are underway to migrate from ancient SER-2.0.0 to more
        modern OpenSIPS and one of the question that is still in my
        TODO list is implementing transactional processing of the
        REGISTER requests. In the old SER we had something along
        those lines:

        route[3] {
                # Ensure that all incoming messages contain auth info
        xlog("L_INFO", "processing %rm received from %si:%sp");
                if (!t_newtran()) {
        sl_send_reply("500", "could not create transaction");
        break;
                };
                if (!python_exec("www_authenticate")) {
        xlog("L_INFO", "challenging %ct");
                        if (is_avp_set("s:digest_challenge")) {
          append_to_reply("%$digest_challenge");
                        };
        t_reply("401", "Unauthorized");
        break;
                };
               [....some more unrelated processing and checks...]
         xlog("L_INFO", "saving contact %ct into the database");
        save_noreply("location");
                if (is_avp_set("s:contact")) {
        append_to_reply("%$contact");
                };
        t_reply("$code", "$reason");
        }

        The idea here is to avoid possibly costly DB lookup and other
        checks on each possible re-transmit. What would be the proper
        way of doing this with the OpenSIPS 2.1? Or if it's not
        possible to replicate such scheme, what would be the best way
        to implement this which to get the change accepted into the
        OpenSIPS mainline?

        Any ideas, pointers, hints are greatly appreciated. Thanks in
        advance!

        -Maxim




-- Maksym Sobolyev
    Sippy Software, Inc.
    Internet Telephony (VoIP) Experts
    Tel (Canada): +1-778-783-0474
    Tel (Toll-Free): +1-855-747-7779
    Fax: +1-866-857-6942
    Web: http://www.sippysoft.com
    MSN: sa...@sippysoft.com <mailto:sa...@sippysoft.com>
    Skype: SippySoft

--
Maksym Sobolyev
Sippy Software, Inc.
Internet Telephony (VoIP) Experts
Tel (Canada): +1-778-783-0474
Tel (Toll-Free): +1-855-747-7779
Fax: +1-866-857-6942
Web: http://www.sippysoft.com
MSN: sa...@sippysoft.com <mailto:sa...@sippysoft.com>
Skype: SippySoft


_______________________________________________
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to