16#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
23 bool challengeThirdParties,
24 const Data& staticRealm,
25 const std::vector<DigestType>& challengeDigestTypes) :
27 mChallengeThirdParties(challengeThirdParties),
28 mStaticRealm(staticRealm),
29 mChallengeDigestTypes(challengeDigestTypes)
36 InfoLog(<<
"~ServerAuthManager: " <<
mMessages.size() <<
" messages in memory when destroying.");
54 InfoLog(<<
"ServerAuth challenged request " << sipMsg->
brief());
57 InfoLog(<<
"ServerAuth requested info (requiresChallenge) " << sipMsg->
brief());
60 InfoLog(<<
"ServerAuth requested credentials " << sipMsg->
brief());
63 InfoLog(<<
"ServerAuth rejected request " << sipMsg->
brief());
73 InfoLog(<<
"ServerAuth got ChallengeInfo " << challengeInfo->
brief());
76 std::unique_ptr<SipMessage> sipMsg(it->second);
83 InfoLog(<<
"ServerAuth requiresChallenge() async failed");
84 auto response = std::make_shared<SipMessage>();
93 InfoLog(<<
"ServerAuth challenged request (after async) " << sipMsg->brief());
119 InfoLog(<<
"ServerAuth rejected request " << *userAuth);
137 InfoLog( <<
"Checking for auth result in realm=" << userAuth->
getRealm()
138 <<
" A1=" << userAuth->
getA1());
144 auto response = std::make_shared<SipMessage>();
148 delete requestWithAuth;
159 auto response = std::make_shared<SipMessage>();
164 delete requestWithAuth;
174 std::pair<Helper::AuthResult,Data> resPair =
181 switch (resPair.first)
184 digestAccepted =
true;
192 InfoLog (<<
"Authentication nonce badly formed for " << userAuth->
getUser());
194 auto response = std::make_shared<SipMessage>();
198 delete requestWithAuth;
219 delete requestWithAuth;
230 return requestWithAuth;
236 " trying to forge request from: " << requestWithAuth->
header(h_From).
uri());
238 auto response = std::make_shared<SipMessage>();
242 delete requestWithAuth;
252 InfoLog (<<
" a1 hash of password from db was " << userAuth->
getA1() );
254 auto response = std::make_shared<SipMessage>();
258 delete requestWithAuth;
309 if ((fromUri.
user() == user) && (fromUri.
host() == realm))
362 if(sipMsg->
method() == CANCEL)
373 if(it->second->isRequest() && it->second->method() == INVITE)
375 std::unique_ptr<SipMessage> inviteMsg(it->second);
378 InfoLog (<<
"Received a CANCEL for an INVITE request that we are still waiting on auth "
379 <<
"info for, responding appropriately, tid="
383 auto inviteResponse = std::make_shared<SipMessage>();
388 auto cancelResponse = std::make_shared<SipMessage>();
396 else if(sipMsg->
method() != ACK)
401 if(!sipMsg->
exists(h_ProxyAuthorizations))
405 auths = &sipMsg->
header(h_ProxyAuthorizations);
409 if(!sipMsg->
exists(h_Authorizations))
413 auths = &sipMsg->
header(h_Authorizations);
422 InfoLog (<<
"Requesting credential for "
423 << it->param(p_username) <<
" @ " << it->param(p_realm));
435 InfoLog (<<
"Didn't find matching realm ");
440 InfoLog (<<
"Invalid auth header provided " << e);
441 auto response = std::make_shared<SipMessage>();
#define resip_assert(x)
This file needs to work for both C and C++ code.
The abstract base-class for all exceptions thrown by resip code.
bool isChallengeRequired() const
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
bool empty() const noexcept
Checks whether the Data is empty.
void send(std::shared_ptr< SipMessage > request)
virtual const Data & getTransactionId() const
DialogUsageManager & mDum
virtual void postCommand(std::unique_ptr< Message > message)
@ FeatureDoneAndEventDone
static SipMessage * makeChallenge(const SipMessage &request, const Data &realm, bool useAuth=true, bool stale=false, bool proxy=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)
The base-class used for message-passing.
virtual Brief brief() const
return a facet for brief encoding of message
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.
virtual bool isMyRealm(const Data &realm)
should return true if realm passed in is ours and we can challenge
Result issueChallengeIfRequired(SipMessage *sipMsg)
virtual SipMessage * handleUserAuthInfo(UserAuthInfo *auth)
std::vector< DigestType > mChallengeDigestTypes
virtual Result handle(SipMessage *sipMsg)
virtual const Data & getChallengeRealm(const SipMessage &msg)
returns the realm to be used for the challenge
virtual bool proxyAuthenticationMode() const
virtual void onAuthSuccess(const SipMessage &msg)
virtual ~ServerAuthManager()
virtual bool useAuthInt() const
virtual AsyncBool requiresChallenge(const SipMessage &msg)
should return true if the request must be challenged The default is to challenge all requests - overr...
virtual bool rejectBadNonces() const
virtual void onAuthFailure(AuthFailureReason reason, const SipMessage &msg)
virtual ProcessingResult process(Message *msg)
void issueChallenge(SipMessage *sipMsg, bool stale=false)
bool mChallengeThirdParties
virtual bool authorizedForThisIdentity(const resip::Data &user, const resip::Data &realm, resip::Uri &fromUri)
should return true if the passed in user is authorized for the provided uri
virtual void requestCredential(const Data &user, const Data &realm, const SipMessage &msg, const Auth &auth, const Data &transactionToken)=0
ServerAuthManager(DialogUsageManager &dum, TargetCommand::Target &target, bool challengeThirdParties=true, const resip::Data &staticRealm="", const std::vector< DigestType > &challengeDigestTypes=std::vector< DigestType >())
Represents a SIP message.
bool isRequest() const
Returns true if message is a request, false otherwise.
const RequestLine & header(const RequestLineType &l) const
Returns the RequestLine. This is only valid for request messages.
virtual const Data & getTransactionId() const
Returns the transaction id from the branch or if 2543, the computed hash.
bool exists(const HeaderBase &headerType) const
Returns true if the given header field is present, false otherwise.
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
const void getErrorInfo(int32_t &errorCode, resip::Data &errorStatusText) const
const resip::Data & getUser() const
const resip::Data & getRealm() const
const resip::Data & getA1() const
dcm! – add UnusedChecking(_enum) below;
RequestLineType h_RequestLine