<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<tt>Hi, Maxim!<br>
<br>
It seems I have misinterpreted your question then :).<br>
<br>
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.<br>
<br>
if (!python_exec("www_authenticate")) {<br>
www_challenge(""); # take the domain from the request.<br>
exit;<br>
};<br>
<br>
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.<br>
<br>
Regarding the last part, I am not sure who populates the $contact
variable, but a simple save() should do the trick.<br>
<br>
[1] <a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/2.1.x/auth#id293652">http://www.opensips.org/html/docs/modules/2.1.x/auth#id293652</a><br>
<br>
Best regards,<br>
</tt>
<pre class="moz-signature" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a class="moz-txt-link-abbreviated" href="http://www.opensips-solutions.com">www.opensips-solutions.com</a></pre>
<div class="moz-cite-prefix">On 02/20/2017 11:23 AM, Maxim Sobolev
wrote:<br>
</div>
<blockquote
cite="mid:CAH7qZfvcomOO8qnyLXDXk5AG8Sp3jKwENS44wJ0rcqONyYt+9g@mail.gmail.com"
type="cite">
<div>
<div>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.</div>
</div>
<div><br>
</div>
<div>-Max</div>
<div><br>
<div class="gmail_quote">
<div>On Mon, Feb 20, 2017 at 12:25 AM Răzvan Crainea <<a
moz-do-not-send="true" href="mailto:razvan@opensips.org">razvan@opensips.org</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000" class="gmail_msg"> <tt
class="gmail_msg">Hi, Maxim!<br class="gmail_msg">
<br class="gmail_msg">
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.<br
class="gmail_msg">
<br class="gmail_msg">
Best regards,<br class="gmail_msg">
</tt>
<pre class="m_7848483611393678603moz-signature gmail_msg" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a moz-do-not-send="true" class="m_7848483611393678603moz-txt-link-abbreviated gmail_msg" href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre>
</div>
<div bgcolor="#FFFFFF" text="#000000" class="gmail_msg">
<div class="m_7848483611393678603moz-cite-prefix
gmail_msg">On 02/17/2017 09:15 PM, Maxim Sobolev wrote:<br
class="gmail_msg">
</div>
<blockquote type="cite" class="gmail_msg">
<div class="gmail_msg">P.S. <span
style="font-size:12.8px" class="gmail_msg">python_exec("www_</span><span
style="font-size:12.8px" class="gmail_msg">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.</span></div>
<div class="gmail_extra gmail_msg"><br class="gmail_msg">
<div class="gmail_quote gmail_msg">On Fri, Feb 17,
2017 at 11:12 AM, Maxim Sobolev <span
class="gmail_msg"><<a moz-do-not-send="true"
href="mailto:sobomax@sippysoft.com"
class="gmail_msg" target="_blank">sobomax@sippysoft.com</a>></span>
wrote:<br class="gmail_msg">
<blockquote class="gmail_quote gmail_msg"
style="margin:0 0 0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div class="gmail_msg">
<div
class="m_7848483611393678603m_6911824313400074143gmail_signature
gmail_msg">
<div class="gmail_msg">Hi guys,</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">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:</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">
<div class="gmail_msg">route[3] {</div>
<div class="gmail_msg"> # Ensure that
all incoming messages contain auth info</div>
<div class="gmail_msg">
xlog("L_INFO", "processing %rm received
from %si:%sp");</div>
<div class="gmail_msg"> if
(!t_newtran()) {</div>
<div class="gmail_msg">
sl_send_reply("500", "could not create
transaction");</div>
<div class="gmail_msg">
break;</div>
<div class="gmail_msg"> };</div>
<div class="gmail_msg"> if
(!python_exec("www_authenticate")) {</div>
<div class="gmail_msg">
xlog("L_INFO", "challenging %ct");</div>
<div class="gmail_msg"> if
(is_avp_set("s:digest_challenge")) {</div>
<div class="gmail_msg">
append_to_reply("%$digest_challenge");</div>
<div class="gmail_msg"> };</div>
<div class="gmail_msg">
t_reply("401", "Unauthorized");</div>
<div class="gmail_msg">
break;</div>
<div class="gmail_msg"> };</div>
<div class="gmail_msg"> [....some more
unrelated processing and checks...]</div>
<div class="gmail_msg">
xlog("L_INFO", "saving contact %ct into
the database");<br class="gmail_msg">
</div>
<div class="gmail_msg">
save_noreply("location");</div>
<div class="gmail_msg"> if
(is_avp_set("s:contact")) {</div>
<div class="gmail_msg">
append_to_reply("%$contact");</div>
<div class="gmail_msg"> };</div>
<div class="gmail_msg">
t_reply("$code", "$reason");</div>
<div class="gmail_msg">}</div>
</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">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?</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">Any ideas, pointers,
hints are greatly appreciated. Thanks in
advance!</div>
<span class="m_7848483611393678603HOEnZb
gmail_msg"><font class="gmail_msg"
color="#888888">
<div class="gmail_msg"><br
class="gmail_msg">
</div>
<div class="gmail_msg">-Maxim</div>
</font></span></div>
</div>
</blockquote>
</div>
<br class="gmail_msg">
<br class="gmail_msg" clear="all">
<div class="gmail_msg"><br class="gmail_msg">
</div>
-- <br class="gmail_msg">
<div class="m_7848483611393678603gmail_signature
gmail_msg" data-smartmail="gmail_signature">
<div class="gmail_msg">Maksym Sobolyev<br
class="gmail_msg">
Sippy Software, Inc.<br class="gmail_msg">
Internet Telephony (VoIP) Experts<br
class="gmail_msg">
Tel (Canada): +1-778-783-0474<br class="gmail_msg">
Tel (Toll-Free): +1-855-747-7779<br
class="gmail_msg">
Fax: +1-866-857-6942<br class="gmail_msg">
Web: <a moz-do-not-send="true"
href="http://www.sippysoft.com"
class="gmail_msg" target="_blank">http://www.sippysoft.com</a><br
class="gmail_msg">
MSN: <a moz-do-not-send="true"
href="mailto:sales@sippysoft.com"
class="gmail_msg" target="_blank">sales@sippysoft.com</a><br
class="gmail_msg">
Skype: SippySoft<br class="gmail_msg">
</div>
</div>
</div>
</blockquote>
<br class="gmail_msg">
</div>
</blockquote>
</div>
</div>
<div dir="ltr">-- <br>
</div>
<div data-smartmail="gmail_signature">
<div dir="ltr">Maksym Sobolyev<br>
Sippy Software, Inc.<br>
Internet Telephony (VoIP) Experts<br>
Tel (Canada): +1-778-783-0474<br>
Tel (Toll-Free): +1-855-747-7779<br>
Fax: +1-866-857-6942<br>
Web: <a moz-do-not-send="true"
href="http://www.sippysoft.com" target="_blank">http://www.sippysoft.com</a><br>
MSN: <a moz-do-not-send="true"
href="mailto:sales@sippysoft.com" target="_blank">sales@sippysoft.com</a><br>
Skype: SippySoft<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</body>
</html>