Net::SIP::Authorize(3pm) | User Contributed Perl Documentation | Net::SIP::Authorize(3pm) |
Net::SIP::Authorize - enforce authorization of packets
my $auth = Net::SIP::Authorize->new( dispatcher => $dispatcher, realm => 'net-sip.example.com', user2pass => \&give_pass_for_user, i_am_proxy => 1, ); my $proxy = Net::SIP::StatelessProxy->new... my $chain = Net::SIP::ReceiveChain->new( # all requests for proxy need to be authorized [ $auth,$proxy ] );
This package is used inside a Net::SIP::ReceiveChain to make sure, that requests are authorized before they get handled by the next receiver in the chain.
The value can be an additional authorization (in which case it must succeed), a list of authorizations (all of them must succeed), or a list with a list of authorizations (at least one of the inner lists must succeed).
The additional authorization can be a name of a Net::SIP::Authorize subclass (e.g. "ToIsFrom" means "Net::SIP::Authorize::ToIsFrom") which has a "verify" function or a "[\&callback]".
The verify function or callback will be called with "($packet,$leg,$addr,$auth_user,$auth_realm)" where $packet is the request, $leg the Net::SIP::Leg object where the packet came in, $addr the senders address, $auth_user the username from the authorized user and $auth_realm the realm which was used for authorization. Success for verification means that the function must return true.
The following authorization subclasses are defined:
Example:
filter => { REGISTER => [ # all of these must succeed [ 'ToIsFrom','FromIsRealm','FromIsAuthUser' ], # or this [ \&callback ], ], INVITE => 'FromIsRealm', }
Called from the managing Net::SIP::Dispatcher object if a new packet arrives.
Returns TRUE if the packet was fully handled by this object which is the case, if the packet was not authorized so that a 401 or 407 (if "i_am_proxy") response was send back.
Returns FALSE if packet was authorized and should be handled be the next object in the Net::SIP::ReceiveChain. In this case it usually changes the packet to remove the local authorization information.
2023-02-04 | perl v5.36.0 |