RTPHPLib
RTPHPLib copied to clipboard
Support cookie authentication
Having to specify username & password all the time is bad if you want to use rt's users and not have a global username/password for every request.
Probably needs the v2.0 tag
@dersam , is this something that can happen?
It's definitely something that should be included, but I don't really have the time to implement it.
If a pull request comes in for this, I'll prioritize reviewing it for inclusion.
@dersam, could you give me a general direction and I will if I can make the time to implement it?
The username/password is only used in the constructor (to store it in the object) and then in the send() method to attach the credentials to the request. You'd have to look up on the RT wiki how to include cookie authentication info in the request (it's probably on the api page).
Off the top of my head, I think the best way to tackle it without breaking backwards compatibility would be to add a method to the class along the lines of "useCookieAuthentication", which would take the cookie provided, store it as a class property. Then whenever send() is called, check if the cookie property isn't null, and use that instead of username/password if available.
Good suggestion. We should also make user/pass optional in the constructor and then in send() check: if username/password AND cookie are not defined, give an exception with a nice descriptive message