<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [X] Commit message has the format required by CONTRIBUTING guide
- [X] Commits are split per component (core, individual modules, libs, utils, ...)
- [X] Each component has a single commit (if not, squash them into one commit)
- [X] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [X] Small bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [X] PR should be backported to stable branches
- [X] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
when handling registration requests we create a transaction for async process and need to use t_on_failure / t_on_failure. when the async processes returns we want to call auth_challenge without the need to create `fake` routes
```
onreply_route[KZ_AUTHORIZATION_OK]
{
$var(password) = $(kzR{kz.json,Auth-Password});
$var(nonce) = $adn;
if( $(kzR{kz.json,Event-Name}) == "authn_err" ) {
==>> auth_challenge("$fd", "0");
xlog("L_INFO", "$ci|end|issued auth challenge from async registrar for $Au $si:$sp\n");
exit;
} else {
xlog("L_INFO", "$ci|log|authenticated $Au via registrar async process\n");
route(SAVE_AUTHORIZATION);
}
}
failure_route[KZ_AUTHORIZATION_ERROR]
{
xlog("L_INFO", "$ci|log|registrar process failed with $T_reply_code for $Au $si:$sp\n");
==>> auth_challenge("$fd", "0");
exit;
}
```
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1641
-- Commit Summary --
* auth: allow challenge from failure/onreply routes
-- File Changes --
M src/modules/auth/auth_mod.c (6)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1641.patchhttps://github.com/kamailio/kamailio/pull/1641.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1641
Module: kamailio
Branch: master
Commit: c3258c2c7d3ce64a1ecb1c187b440b48e1544af3
URL: https://github.com/kamailio/kamailio/commit/c3258c2c7d3ce64a1ecb1c187b440b4…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2018-09-13T12:31:33+02:00
modules: readme files regenerated - sanity ... [skip ci]
---
Modified: src/modules/sanity/README
---
Diff: https://github.com/kamailio/kamailio/commit/c3258c2c7d3ce64a1ecb1c187b440b4…
Patch: https://github.com/kamailio/kamailio/commit/c3258c2c7d3ce64a1ecb1c187b440b4…
---
diff --git a/src/modules/sanity/README b/src/modules/sanity/README
index 027725f150..4493c7f3cd 100644
--- a/src/modules/sanity/README
+++ b/src/modules/sanity/README
@@ -19,10 +19,12 @@ Nils Ohlmeier
3.2. uri_checks (integer)
3.3. proxy_require (string)
3.4. autodrop (integer)
+ 3.5. noreply (int)
4. Functions
4.1. sanity_check([msg_checks [, uri_checks]])
+ 4.2. sanity_reply()
List of Examples
@@ -30,9 +32,11 @@ Nils Ohlmeier
1.2. Set uri_checks parameter
1.3. Set proxy_require parameter
1.4. Set autodrop parameter
- 1.5. sanity_check usage
- 1.6. sanity_check usage with parameter
- 1.7. sanity_check usage with two parameters
+ 1.5. Set noreply parameter
+ 1.6. sanity_check usage
+ 1.7. sanity_check usage with parameter
+ 1.8. sanity_check usage with two parameters
+ 1.9. sanity_reply usage
Chapter 1. Admin Guide
@@ -46,10 +50,12 @@ Chapter 1. Admin Guide
3.2. uri_checks (integer)
3.3. proxy_require (string)
3.4. autodrop (integer)
+ 3.5. noreply (int)
4. Functions
4.1. sanity_check([msg_checks [, uri_checks]])
+ 4.2. sanity_reply()
1. Overview
@@ -111,6 +117,7 @@ Chapter 1. Admin Guide
3.2. uri_checks (integer)
3.3. proxy_require (string)
3.4. autodrop (integer)
+ 3.5. noreply (int)
3.1. default_checks (integer)
@@ -169,9 +176,24 @@ modparam("sanity", "proxy_require", "foo, bar")
modparam("sanity", "autodrop", 1)
...
+3.5. noreply (int)
+
+ If set to 1, then the module does not send a SIP reply internally in
+ case there is an error detected when performing the sanity checks.
+ There is the option to send the reply from config file with functions
+ from sl or tm module as well as sanity_reply() from this module.
+
+ Default value: 0.
+
+ Example 1.5. Set noreply parameter
+...
+modparam("sanity", "noreply", 1)
+...
+
4. Functions
4.1. sanity_check([msg_checks [, uri_checks]])
+ 4.2. sanity_reply()
4.1. sanity_check([msg_checks [, uri_checks]])
@@ -186,7 +208,7 @@ modparam("sanity", "autodrop", 1)
The parameters can be static integers or variables holding integer
values.
- Example 1.5. sanity_check usage
+ Example 1.6. sanity_check usage
...
if (!sanity_check()) {
exit;
@@ -199,7 +221,7 @@ if (!sanity_check()) {
of the checks (like for the module parameter) which should be executed
at this function call.
- Example 1.6. sanity_check usage with parameter
+ Example 1.7. sanity_check usage with parameter
...
if (method=="REGISTER" && !sanity_check("256")) {
/* the register contains an invalid expires value and is replied with a
@@ -212,7 +234,7 @@ if (method=="REGISTER" && !sanity_check("256")) {
overwrites the global module parameter uri_checks and thus determines
which URIs will be checked if the parse uri test will be executed.
- Example 1.7. sanity_check usage with two parameters
+ Example 1.8. sanity_check usage with two parameters
...
if (method=="INVITE" && !sanity_check("1024", "6")) {
/* the INVITE contains an invalid From or To header and is replied with
@@ -220,3 +242,18 @@ a 400 */
exit;
}
...
+
+4.2. sanity_reply()
+
+ Send a SIP reply using the code and reason text set internally by the
+ module when detecting errors while performing the sanity checks. It is
+ done only when parameter noreply is set to 1.
+
+ Example 1.9. sanity_reply usage
+...
+if(!sanity_check("1024", "6")) {
+ xdbg("sanity checks failed\n");
+ sanity_reply();
+ exit;
+}
+...
### Description
According the documentation the module will send reply if one of the checks is failed.
However it doesn't send reply if digest credentials, duplicated To/From tags or authorization header checks are failed.
I would like to propose to add a new parameter which will enable or disable auto sending of reply.
#### Reproduction
Send to kamailio request with empty nonce in Authorization header.
### Possible Solutions
Set autodrop to 0 and send the reply from configuration file. But in some cases this reply will be sent twice from module and from config.
### Additional Information
kamailio version 4.4.7 and the latest 5.x
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1543
Module: kamailio
Branch: master
Commit: aa7c4beafbfee054872a4fa05a7d2a2f105e431e
URL: https://github.com/kamailio/kamailio/commit/aa7c4beafbfee054872a4fa05a7d2a2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-09-13T12:17:19+02:00
sanity: docs for noreply param and sanity_reply() function
---
Modified: src/modules/sanity/doc/sanity_admin.xml
---
Diff: https://github.com/kamailio/kamailio/commit/aa7c4beafbfee054872a4fa05a7d2a2…
Patch: https://github.com/kamailio/kamailio/commit/aa7c4beafbfee054872a4fa05a7d2a2…
---
diff --git a/src/modules/sanity/doc/sanity_admin.xml b/src/modules/sanity/doc/sanity_admin.xml
index f9f63071a0..a8a57d88d9 100644
--- a/src/modules/sanity/doc/sanity_admin.xml
+++ b/src/modules/sanity/doc/sanity_admin.xml
@@ -225,6 +225,27 @@ modparam("sanity", "proxy_require", "foo, bar")
<programlisting>
...
modparam("sanity", "autodrop", 1)
+...
+ </programlisting>
+ </example>
+ </section>
+
+ <section id="sanity.p.noreply">
+ <title><varname>noreply</varname> (int)</title>
+ <para>
+ If set to 1, then the module does not send a SIP reply internally in
+ case there is an error detected when performing the sanity checks.
+ There is the option to send the reply from config file with functions
+ from sl or tm module as well as sanity_reply() from this module.
+ </para>
+ <para>
+ Default value: 0.
+ </para>
+ <example>
+ <title>Set <varname>noreply</varname> parameter</title>
+ <programlisting>
+...
+modparam("sanity", "noreply", 1)
...
</programlisting>
</example>
@@ -302,6 +323,28 @@ if (method=="INVITE" && !sanity_check("1024", "6")) {
]]>
</programlisting>
</example>
- </section>
+ </section>
+ <section id="sanity.f.sanity_reply">
+ <title>
+ <function>sanity_reply()</function>
+ </title>
+ <para>
+ Send a SIP reply using the code and reason text set internally by the module
+ when detecting errors while performing the sanity checks. It is done only
+ when parameter noreply is set to 1.
+ </para>
+ <example>
+ <title><function>sanity_reply</function> usage</title>
+ <programlisting>
+...
+if(!sanity_check("1024", "6")) {
+ xdbg("sanity checks failed\n");
+ sanity_reply();
+ exit;
+}
+...
+ </programlisting>
+ </example>
+ </section>
</section>
</chapter>
Module: kamailio
Branch: master
Commit: 8a8fcc25a2e8faa8ef4d7b69207ac66fabc22827
URL: https://github.com/kamailio/kamailio/commit/8a8fcc25a2e8faa8ef4d7b69207ac66…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2018-09-13T10:01:52+02:00
modules: readme files regenerated - sanity ... [skip ci]
---
Modified: src/modules/sanity/README
---
Diff: https://github.com/kamailio/kamailio/commit/8a8fcc25a2e8faa8ef4d7b69207ac66…
Patch: https://github.com/kamailio/kamailio/commit/8a8fcc25a2e8faa8ef4d7b69207ac66…
---
diff --git a/src/modules/sanity/README b/src/modules/sanity/README
index 588f53deae..027725f150 100644
--- a/src/modules/sanity/README
+++ b/src/modules/sanity/README
@@ -72,10 +72,8 @@ Chapter 1. Admin Guide
supported (sip[s]|tel[s]) by Kamailio
* required headers - (4) -checks if the minimum set of required
headers to, from, cseq, callid and via is present in the request.
- * via sip version - (8) - not working because parser fails already
- when another version then 2.0 is present.
- * via protocol - (16) - not working because parser fails already if
- an unsupported transport is present.
+ * via sip version - (8) - disabled.
+ * via protocol - (16) - disabled.
* Cseq method - (32) - checks if the method from the Cseq header is
equal to the request method.
* Cseq value - (64) - checks if the number in the Cseq header is a
@@ -99,6 +97,8 @@ Chapter 1. Admin Guide
* authorization header (8192) - checks if the Authorization is valid
if the scheme is "digest" (see "digest credentials" above), always
returns success for other schemes.
+ * first via header (16384) - checks if the first Via header is
+ available, can be parsed and has an address value.
2. Dependencies
Module: kamailio
Branch: master
Commit: 5572b37a7a83074c9c3b9d5a07640d040b3fe51f
URL: https://github.com/kamailio/kamailio/commit/5572b37a7a83074c9c3b9d5a07640d0…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-09-13T09:47:14+02:00
sanity: updates to the checks that can be done
---
Modified: src/modules/sanity/doc/sanity_admin.xml
---
Diff: https://github.com/kamailio/kamailio/commit/5572b37a7a83074c9c3b9d5a07640d0…
Patch: https://github.com/kamailio/kamailio/commit/5572b37a7a83074c9c3b9d5a07640d0…
---
diff --git a/src/modules/sanity/doc/sanity_admin.xml b/src/modules/sanity/doc/sanity_admin.xml
index dec9d79a86..f9f63071a0 100644
--- a/src/modules/sanity/doc/sanity_admin.xml
+++ b/src/modules/sanity/doc/sanity_admin.xml
@@ -49,14 +49,12 @@
</listitem>
<listitem>
<para>
- via sip version - (8) - not working because parser fails already
- when another version then 2.0 is present.
+ via sip version - (8) - disabled.
</para>
</listitem>
<listitem>
<para>
- via protocol - (16) - not working because parser fails already if an
- unsupported transport is present.
+ via protocol - (16) - disabled.
</para>
</listitem>
<listitem>
@@ -86,7 +84,7 @@
<listitem>
<para>
proxy require - (512) - checks if all items of the proxy require header
- are present in the list of the extensions from the module
+ are present in the list of the extensions from the module
parameter proxy_require.
</para>
</listitem>
@@ -118,6 +116,12 @@
returns success for other schemes.
</para>
</listitem>
+ <listitem>
+ <para>
+ first via header (16384) - checks if the first Via header is
+ available, can be parsed and has an address value.
+ </para>
+ </listitem>
</itemizedlist>
</para>
</section>