[OpenSIPS-Devel] Re-organizing and de-duplicating digest code (related to the RFC8760 work)
Liviu Chircu
liviu at opensips.org
Thu Oct 8 06:37:05 EST 2020
On 08.10.2020 05:42, Maxim Sobolev wrote:
> Hey folks,
Hi!
> The problem that I am hitting now is that we have digest computation
> code duplicated in both modules (auth vs. uac_auth), which of course
> is less than ideal from many perspectives (2x code to test, code
> bloat, pain to add more algorithms etc).
I agree that the uac / uac_auth code is a bit "all over the place" and
could use some re-org into a single "authentication-related" module /
directory / library.
>
> Now the question is what is the best way to deal with it. Couple of
> options I have:
>
> 1. Make uas_auth use code from the auth module and add it as a
> dependency. In general this seems to be the path the project takes to
> solve this problem. The downside is perhaps some small performance
> degradation as well some overhead to define and maintain API. Also
> this method does not work for smallish bits and pieces, too
> heavy-weight for an API.
Classical module API approach - let's see if we can do better.
>
> 2. Move code into the core. I think this is probably the wrong
> direction, some application might not need auth at all. Just listing
> it for completeness sake.
I agree - no need to compile this code into the "opensips" binary if the
app only does IP authentication, for example.
> 3. Move code into some kind of internal static library (say
> "libospcore.a") and link both modules against that library. I really
> like this approach since apart from some make-foo to get the library
> compiled and linked with each of modules, the rest is pretty much
> trivial. This avoids API/dependency overhead. With things like
> link-time-optimization becoming de-facto standard in the next 2-3
> years would give the best possible performance with very small size
> overhead. Also works great for useful functions that are too small for
> an API (for example function to convert binary into hex and the likes).
I like this approach best, but let me suggest an improvement! If you
place the code under and extra directory level, e.g. in *lib/auth/*
instead of just *lib/*, /it will not compile by default!/ This way, any
modules requiring digest auth-related DS and functions will simply
include the *lib/auth/auth.h* header and have everything they need. See
the /modules/registrar/Makefile/ for an example of how to include some
"extra core source code" into your module.
--
Liviu Chircu
www.twitter.com/liviuchircu | www.opensips-solutions.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20201008/8161e9ac/attachment.html>
More information about the Devel
mailing list