Description
Hello,
After a rich dialogue about the authentication method of Parse Server (Link Community), I hereby propose the implementation of OAuth 2.0 as the platform's authentication mechanism.
The idea is to increase security and eliminate problems with login expiration time (even if defined, 1 year by default).
The suggestion consists of the following steps:
1 - Add 2 more parameters in ParseOptions:
a) timeoutAccessToken = (int) default: 86400 (1 day)
b) oauthKey = (string) the user must set, suggest the creation of 256 bit key
The "refreshToken" field must be added to the "_Sessions" class
2 - In the Login and SignUp return methods:
a) remove the "sessionToken" field
b) add the fields: "accessToken", "timeExpiration" and "refreshToken"
3 - The client's APIs, instead of storing the "sessionToken", should store these 3 new fields.
4 - All authentication instead of passing "X-Parse-Session-Token", will pass "Authrozation: Bearer ACESSTOKEN"
5 - If the "accessToken" has expired, the APIs should request the refresh token, example POST "/ parse / users / refresh" passing the parameters:
{
"refreshToken": "SECRET REFRESH TOKEN"
}
the return will be the new "accessToken" for continuity of access, example
{
"accessToken": "NEW ACCESS TOKEN",
"timeExpitation": 0000-00-00 00:00:00
}
6 - The method to check the current user, when passing the "accessToken" should return the same data that they currently use.
Important: I believe that the APIs did not need to validate the "accessToken" as this must be done on the Parse Server side.
Access token example
Header
{
"alg": "HS256",
"typ": "JWT"
}
Payload
{
"sub": "1234567890", (user's objectId)
"session": Current session id to identify who is performing the access.
"iat": 1516239022 (TimeExpiration)
}
Signature Payload
HMACSHA256 (
base64UrlEncode (header) + "." +
base64UrlEncode (payload),
"oauthKey")
Final example of "accessToken"
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
I want to start this contribution to the project, but I would like to hear the suggestions of the community for this idea,