You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[DISCUSSION] Making the API more REST compatible and predictable #266
Before reaching 1.0, we still have the privilege to make some API breaking changes. This change aims to improve the developer experience while using the Appwrite REST API.
Some of the ideas I have regarding this are to consider to combination of the auth and account services. This change is not exclusively related to the "RESTification" of the API but also to make the API more predictable and easier to master.
Some of the route I am thinking of changing are:
POST/auth/register -> POST /account (Create an account)
POST/auth/login -> POST /account/sessions (Create a new session using email & password)
POST/auth/login/oauth/{provider} -> POST /account/sessions/oauth (Create a new session using a OAuth provider)
DELETE/auth/logout -> DELETE /account/sessions (Delete all account sessions?)
DELETE/auth/logout/{id} -> DELETE /account/sessions/{id} (Delete a specific session)
POST/auth/recovery -> POST /account/recovery (Treat this as an account recovery token entity? account/recoveries?)
PUT/auth/recovery/reset -> ?
I would love to hear more feedback on this, but keep in mind, the more important issue here is to make the API experience great for developers and not strictly following REST 1:1. REST is our tool, and developer experience is the goal.
Also, keep in mind that some constrains related to the way the SDK and Docs generation and framework architecture work might introduce some limitations. This issue will probably accompany us in all upcoming versions v0.5, v0.6, and v0.7.
I think it makes sense to make these changes. Keep in mind non browser clients. Right now there is an requirement for passing redirect url when logging in.
Post account/sessions should return sessionid and user info.
The SDK client class should store the sessionid and pass it in subsequent calls.
Actually, storing the session from the client SDK would have made life a lot easier. The problem is that once the client has access to the session key, any 3rd party script (or browser extension) on the user page can hijack it.
This is why we are currently using a secure cookie for session storing on browsers, and this is also the reason we are forced to use the (unwanted) redirect URL parameter.
I am testing if the SameSite cookie option can help us with that, but there are some compatibility issues with chrome and safari that I'm trying to overcome.
The current endpoints sound more predictable to me. If I were provided no or very poor documentation, the first endpoints I'd consider would be /login or /user/login in the case of a web app, and /auth/login in the case of an API. Full or semi-RESTification of authentication APIs might end up with a longer learning curve.
Add a new app platform for non browser sdk client login where there is no requirement for redirect urls. The requirement for secure httponly session cookies is mostly required for browser clients because it is possible to inject malicious javascript in the browser.
The current endpoints sound more predictable to me. If I were provided no or very poor documentation, the first endpoints I'd consider would be /login or /user/login in the case of a web app, and /auth/login in the case of an API. Full or semi-RESTification of authentication APIs might end up with a longer learning curve.
I truly understand your view on this, I was thinking about this change for a few months now, when looking how our entire API works the auth service is the only one not working with entities and not aligned with REST principles. This could also be a better reflection of how Appwrite actually implement authentication internally (using sessions entities).
I agree with you that it might make a longer learning curve. To tackle this issue I want to try and add the new endpoint without deprecating the old ones, and release a tutorial dedicated to user authentication and account management.
This tutorial will be the first from a series of step by step tutorials in our docs covering each and every service in addition to the API references we have today. Once live we'll be able to get more feedbacks about this.
As this is a big change now is the best (and maybe only?) time to test it out.
Activity
wentzlau commentedon Dec 12, 2019
I think it makes sense to make these changes. Keep in mind non browser clients. Right now there is an requirement for passing redirect url when logging in.
Post account/sessions should return sessionid and user info.
The SDK client class should store the sessionid and pass it in subsequent calls.
eldadfux commentedon Dec 12, 2019
Actually, storing the session from the client SDK would have made life a lot easier. The problem is that once the client has access to the session key, any 3rd party script (or browser extension) on the user page can hijack it.
This is why we are currently using a secure cookie for session storing on browsers, and this is also the reason we are forced to use the (unwanted) redirect URL parameter.
I am testing if the SameSite cookie option can help us with that, but there are some compatibility issues with chrome and safari that I'm trying to overcome.
monatis commentedon Dec 12, 2019
The current endpoints sound more predictable to me. If I were provided no or very poor documentation, the first endpoints I'd consider would be
/loginor/user/loginin the case of a web app, and/auth/loginin the case of an API. Full or semi-RESTification of authentication APIs might end up with a longer learning curve.wentzlau commentedon Dec 12, 2019
Add a new app platform for non browser sdk client login where there is no requirement for redirect urls. The requirement for secure httponly session cookies is mostly required for browser clients because it is possible to inject malicious javascript in the browser.
eldadfux commentedon Dec 12, 2019
@wentzlau yes, I created a new issue that is related to this problem: #268
eldadfux commentedon Dec 12, 2019
I truly understand your view on this, I was thinking about this change for a few months now, when looking how our entire API works the auth service is the only one not working with entities and not aligned with REST principles. This could also be a better reflection of how Appwrite actually implement authentication internally (using sessions entities).
I agree with you that it might make a longer learning curve. To tackle this issue I want to try and add the new endpoint without deprecating the old ones, and release a tutorial dedicated to user authentication and account management.
This tutorial will be the first from a series of step by step tutorials in our docs covering each and every service in addition to the API references we have today. Once live we'll be able to get more feedbacks about this.
As this is a big change now is the best (and maybe only?) time to test it out.
W4nn4Die commentedon Dec 18, 2019
For me some have sense and are easy to remind and some no, so I think this really depends on the dev
Merge pull request appwrite#266 from utopia-php/feat/messaging-bird-a…