2#if defined(HAVE_CONFIG_H)
24#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
32 const Data& staticRealm,
33 const std::vector<resip::DigestType>& challengeDigestTypes) :
35 mAuthRequestDispatcher(authRequestDispatcher),
36 mStaticRealm(staticRealm),
37 mNoIdentityHeaders(config.getConfigBool(
"DisableIdentity", false)),
38 mHttpHostname(config.getConfigData(
"HttpHostname",
"")),
39 mHttpPort(config.getConfigInt(
"HttpPort", 5080)),
40 mUseAuthInt(!config.getConfigBool(
"DisableAuthInt", false)),
41 mRejectBadNonces(config.getConfigBool(
"RejectBadNonces", false)),
42 mAllowInDialogImpersonationWithinRealm(config.getConfigBool(
"AllowInDialogImpersonationWithinRealm", false)),
43 mChallengeDigestTypes(challengeDigestTypes)
54 DebugLog(<<
"Monkey handling request: " << *
this <<
"; reqcontext = " << rc);
64 if (sipMessage->
method() == ACK ||
65 sipMessage->
method() == BYE)
71 if (sipMessage->
exists(h_ProxyAuthorizations))
73 Auths &authHeaders = sipMessage->
header(h_ProxyAuthorizations);
93 sipMessage->
header(h_From).isAllContacts() )
95 InfoLog(<<
"Malformed From header: cannot get realm to challenge with. Rejecting.");
115 const Data& user = userInfo->
user();
116 InfoLog (<<
"Received user auth info for " << user <<
" at realm " << realm);
126 const Data& a1 = userInfo->
A1();
127 StackLog (<<
"Received user auth info for " << user <<
" at realm " << realm
130 pair<Helper::AuthResult,Data> result =
132 authResult = result.first;
150 WarningLog(<<
"UserInfoMessage mode == ERROR");
155 ErrLog(<<
"Unrecognised UserInfoMessage mode value: " << userInfo->
getMode());
161 InfoLog (<<
"Authentication failed for " << user <<
" at realm " << realm <<
". Sending 403");
172 InfoLog (<<
"Authentication ok for " << user);
175 sipMessage->
header(h_From).isAllContacts())
177 InfoLog(<<
"From header is malformed in"
178 " digest response.");
197 sipMessage->
header(h_To).exists(p_tag) &&
276 if(sipMessage->
exists(h_IdentityInfo))
279 " request with an Identity-Info, but no Identity"
280 " header. Removing it.");
284 "Identity-Info header was malformed!");
287 sipMessage->
remove(h_IdentityInfo);
290 sipMessage->
header(h_IdentityInfo).
uri() = http + realm;
299 InfoLog (<<
"User: " << user <<
" at realm: " << realm <<
300 " trying to forge request from: " << sipMessage->
header(h_From).
uri());
309 InfoLog (<<
"Authentication expired for " << user);
314 InfoLog (<<
"Authentication nonce badly formed for " << user);
337 if (fromUri.
host() == realm)
339 if ((fromUri.
user() == user) || (fromUri.
user() ==
"anonymous"))
364 defaultIdentity.
uri().
user() = user;
365 defaultIdentity.
uri().
host() = realm;
366 return defaultIdentity;
390 Auths &authorizationHeaders = sipMessage->
header(h_ProxyAuthorizations);
394 for (i = authorizationHeaders.
begin(); i != authorizationHeaders.
end(); i++)
396 if (i->exists(p_realm) &&
397 i->param(p_realm) == realm
398 && i->exists(p_username))
400 user = i->param(p_username);
402 InfoLog (<<
"Request user auth info for " << user
403 <<
" at realm " << realm);
412 async->
realm()=realm;
434 std::unique_ptr<ApplicationMessage> app(userInfo);
#define WarningLog(args_)
#define resip_assert(x)
This file needs to work for both C and C++ code.
virtual resip::Data getRealm(RequestContext &)
virtual resip::NameAddr getDefaultIdentity(const resip::Data &user, const resip::Data &realm, resip::NameAddr &from)
virtual bool isMyRealm(RequestContext &, const resip::Data &realm)
resip::Dispatcher * mAuthRequestDispatcher
std::vector< resip::DigestType > mChallengeDigestTypes
virtual void challengeRequest(RequestContext &, bool stale=false)
resip::Data mHttpHostname
virtual bool authorizedForThisIdentity(const resip::Data &user, const resip::Data &realm, resip::Uri &fromUri)
virtual processor_action_t requestUserAuthInfo(RequestContext &, resip::Data &realm)
bool mAllowInDialogImpersonationWithinRealm
DigestAuthenticator(ProxyConfig &config, resip::Dispatcher *authRequestDispatcher, const resip::Data &staticRealm=resip::Data::Empty, const std::vector< resip::DigestType > &challengeDigestTypes=std::vector< resip::DigestType >())
virtual processor_action_t process(RequestContext &)
static resip::KeyValueStore::Key mFromTrustedNodeKey
bool isPAssertedIdentityProcessingEnabled()
resip::SipMessage & getOriginalRequest()
Returns the SipMessage associated with the server transaction.
void setDigestIdentity(const resip::Data &)
const resip::Data & getDigestRealm()
resip::Message * getCurrentEvent()
Returns the event that we are currently working on.
void sendResponse(resip::SipMessage &response)
resip::KeyValueStore & getKeyValueStore()
resip::Data getTransactionId() const
const resip::Data & A1() const
const resip::Data & user() const
const resip::Data & domain() const
resip::UserAuthInfo::InfoMode getMode() const
const resip::Data & realm() const
Represents the "credentials" and "challenge" elements in the SIP grammar.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
bool empty() const noexcept
Checks whether the Data is empty.
A generic thread-bank class.
virtual bool post(std::unique_ptr< resip::ApplicationMessage > &work)
Posts a message to this thread bank.
static SipMessage * makeProxyChallenge(const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, const std::vector< DigestType > &digestTypes=std::vector< DigestType >())
static void makeResponse(SipMessage &response, const SipMessage &request, int responseCode, const Data &reason=Data::Empty, const Data &hostname=Data::Empty, const Data &warning=Data::Empty)
Make a response to a provided request.
static std::pair< AuthResult, Data > advancedAuthenticateRequest(const SipMessage &request, const Data &realm, const Data &resipPasswordHashA1, int expiresDelta=0, bool proxyAuthorization=true)
Represents an Identity header from RFC8824.
const bool & getBoolValue(Key key) const
bool isWellFormed() const
Returns true iff this element was parsed successfully, according to the implementation of parse().
The base-class used for message-passing.
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
An iterator class (bidirectional)
Container class for ParserCategory, used by SipMessage to represent multi-valued headers (Contact,...
iterator end()
Returns an iterator pointing to the last header field value.
iterator begin()
Returns an iterator pointing to the first header field value.
Represents a SIP message.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
void remove(const HeaderBase &headerType)
Prevents a header field from being present when the message is prepared for sending to a transport.
resip::MethodTypes method() const
returns the method type of the message
bool isMyDomain(const Data &domain) const
Returns true iff domain matches one of the domains that this TransactionUser is responsible for.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
Data getAorNoPort() const
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
H_PPreferredIdentitys h_PPreferredIdentities
H_PAssertedIdentitys h_PAssertedIdentities