RTPHPLib icon indicating copy to clipboard operation
RTPHPLib copied to clipboard

Support cookie authentication

Open ParisLiakos opened this issue 9 years ago • 5 comments

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

ParisLiakos avatar Feb 10 '16 23:02 ParisLiakos

@dersam , is this something that can happen?

chrisShick avatar Jun 07 '16 21:06 chrisShick

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 avatar Jun 08 '16 15:06 dersam

@dersam, could you give me a general direction and I will if I can make the time to implement it?

chrisShick avatar Jun 08 '16 16:06 chrisShick

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.

dersam avatar Jun 08 '16 16:06 dersam

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

ParisLiakos avatar Jun 13 '16 14:06 ParisLiakos