-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POST methods always redirects #4
Comments
Have you ensured that you have...
|
Another pitfall you need to watch out for, assuming that you have done all the steps above correctly - nearly ALL OAuth client libraries out there right now do not know how to handle redirects correctly. They would happily reuse the same Authorization header on the redirected location thus that causes signature to fail. I typically disable redirection in my use case and handle redirects manually.
On the other hand, if the redirects are enabled.
This would then cause these server logs
That said, I simply don't know why you are getting redirects to the login page, that should never happen |
To anwser your questions. I dit set the POST in the permitted http methods and did the whole oauth dance again. The problem is that only post methods give me a hard time, while the rest works fluently. Also i have found in the logs that prm2.oauth always says its an invalid token, even with the get methods which works, still display that error message in the logs. |
To further test POST methods, I tried the tutorial example site and went to the document view of private file, but with a post instead of a get. The get method works but the post method redirects me to the login page. |
As I said, you need to disable the use of automatic redirect from your HTTP library. You have not told me whether your POST request generates its own redirects, and I have verified that the OAuth PAS Plugin does not result in a redirect to the login page if a valid OAuth request was permitted. Also, lastly, what kind of signature method is your library using. I still have not enable the support for the Naturally, if you post your code sooner it would aid in getting this working faster. I can't even begin to reproduce your problem without knowing exactly what you did. So from what you said there are two reasons why the requests get redirected to login page:
|
Alright I am going to post my code, forgive me I am new to Plone so I dont know what really is neccessary but I am going to try: The goal of the code is to upload a file to a plone site. This plone site has some extra objects that inherits from the plone archetypes like File, Folder, etc. The get oauth methods work perfectly on the extra objects. A colleague of mine has written an API which i can talk to to do different things. One of these methods is a POST method called upload-file which as you might have guessed it uploads a file to the plone site. The code for this API is found here: On the client side we have my code. I have uploaded my test code, the real code stores and saves the access tokens, but since im in development I want new tokens every request. The client code can be found here: The problem is that even before the API code is called upon. PMR2.oauth says the request is invalid, while if i change the method to a get method it works (albeit crashes at the API method). In the contenttype scope manager I have added upload-file to every type to try and make this work. I hope you can help me with it and I would like to thank you in advance for taking time to help me with this problem, Its greatly appreciated. |
Please use header_auth. I did mention that the Plone PAS Plugin only detected the header base authentication method due to difficulty in ensuring that it doesn't choke on non-OAuth request as I haven't had the time figured out how to safely handle Another point where I can see things go wrong is that your scope configuration is not permissive enough. I assume Back to
Of course that would require changes to the way the endpoint handle incoming requests. Anyway, it does look like correct handling of |
Heh. Looks like the case sensitivity is a cause for all these mess. Zope/Plone doesn't really do case sensitive headers but oauthlib does. Will be making a test/fix shortly but I am not getting these two hours of sleep back. Good thing it's a weekend or something. |
Wow nice find, Never thought about the case sensitive headers and again I 2013/11/22 Tommy Yu [email protected]
|
- Correct the case so that oauthlib can correctly handle the content- type of application/x-www-form-urlencoded.
Again, try adding setting
Oh yeah, are you using buildout for your instance along with mr.developer? If not just clone the repo and look up how to use the develop flag in buildout. I am going to bed. |
Well I tested it and it works perfectly now. Thank you again for your help |
Glad to be of your assistance. I have to thank you very much for bringing this flaw to my attention and your patience in putting up with working with a beta level product. |
- Correct the case so that oauthlib can correctly handle the content- type of application/x-www-form-urlencoded.
Fix released in pmr2.oauth-0.5.1. |
After succesfully added pmr2.oauth to a plone site for a project. Everything works perfectly except for one thing. POST methods always get redirected to the login page. I even tried it with the manage-ctsp/add function but that doenst work either.
What weird is though that if i change the post to a get request (session.post(....) to session.get(....)) then the authentication works, but breaks at the function im trying to addres because of the wrong http method. This unusual behavior looks like a bug with POST methods.
The text was updated successfully, but these errors were encountered: