<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<section id="auth_db.functions" xmlns:xi="http://www.w3.org/2001/XInclude">
    <sectioninfo>
    </sectioninfo>

    <title>Functions</title>

    <section id="www_authorize">
	<title><function>www_authorize(realm, table)</function></title>
	<para>
	    The function verifies credentials according to RFC2617. If the
	    credentials are verified successfully then the function will
	    succeed and mark the credentials as authorized (marked credentials
	    can be later used by some other functions). If the function was
	    unable to verify the credentials for some reason then it will fail
	    and the script should call <function>www_challenge</function> which
	    will challenge the user again.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<formalpara>
		    <title>realm</title>
		    <para>
			Realm is a opaque string that the user agent should
			present to the user so he can decide what username and
			password to use. Usually this is domain of the host the
			server is running on. If an empty string "" is used
			then the server will generate it from the request. In
			case of REGISTER requests To header field domain will
			be used (because this header field represents a user
			being registered), for all other messages From header
			field domain will be used.
		    </para>
		</formalpara>
	    </listitem>
	    <listitem>
		<formalpara>
		    <title>table</title>
		    <para>
			Table to be used to lookup usernames and passwords
			(usually subscribers table).
		    </para>
		</formalpara>
	    </listitem>
	</itemizedlist>
	<example>
	    <title><function moreinfo="none">www_authorize</function> usage</title>
	    <programlisting>
...
if (www_authorize("iptel.org", "subscriber")) {
    www_challenge("iptel.org", "1");
};
...
	    </programlisting>
	</example>
    </section>

    <section id="proxy_authorize">
	<title><function>proxy_authorize(realm, table)</function></title>
	<para>
	    The function verifies credentials according to RFC2617. If the
	    credentials are verified successfully then the function will
	    succeed and mark the credentials as authorized (marked credentials
	    can be later used by some other functions). If the function was
	    unable to verify the credentials for some reason then it will fail
	    and the script should call <function>proxy_challenge</function>
	    which will challenge the user again.
	</para>
	<para>Meaning of the parameters is as follows:</para>
	<itemizedlist>
	    <listitem>
		<para>
		    <emphasis>realm</emphasis> - Realm is a opaque string that
		    the user agent should present to the user so he can decide
		    what username and password to use. Usually this is domain
		    of the host the server is running on.
		</para>
		<para>
		    If an empty string "" is used then the server will generate
		    it from the request. From header field domain will be used
		    as realm.
		</para>
	    </listitem>
	    <listitem>
		<para>
		    <emphasis>table</emphasis> - Table to be used to lookup
		    usernames and passwords (usually subscribers table).
		</para>
	    </listitem>
	</itemizedlist>
	<example>
	    <title>proxy_authorize usage</title>
	    <programlisting>
...
if (!proxy_authorize("", "subscriber)) {
    proxy_challenge("", "1");  # Realm will be autogenerated
};
...
	    </programlisting>
	</example>
    </section>
</section>
