Currently I have an authentication feature configured like this:
Plugins.Add(new AuthFeature(() => new CustomSession(), // Subclass of AuthUserSession
new IAuthProvider[] {
new JwtAuthProvider(AppSettings) {
CreatePayloadFilter = Payload.CreatePayloadFilter // Some payload func
},
new CustomAuthProvider(), // Subclass of CredentialsAuthProvider
}
));
Authentication works fine. I post the following:
UserName: validUser
Password: validPass
UseTokenCookie: true
and get a response
"UserId": "6",
"SessionId": "AfrMZkrCNvs6toy3TUhB",
"UserName": "validUser",
"DisplayName": "",
"BearerToken": "ey[...]",
"ResponseStatus": {}
My question is. How am I supposed to refresh tokens so that users will not suddenly “log out” after token expiration?
Trying to post to /access-token
gives a response:
"ResponseStatus": {
"ErrorCode": "NotSupportedException",
"Message": "JWT Refresh Tokens requires a registered IUserAuthRepository",
"StackTrace": "[GetAccessToken: 24.05.2017 12.14.03]:[...]",
"Errors": []
}
Adding the following line
container.Register<IUserAuthRepository>(new InMemoryAuthRepository());
makes the authentication response return a RefreshToken
"UserId": "6",
"SessionId": "AfrMZkrCNvs6toy3TUhB",
"UserName": "validUser",
"DisplayName": "",
"BearerToken": "ey[...]",
"BearerToken": "ey[...]",
"ResponseStatus": {}
Trying to post to /access-token
with the refresh token gives a response:
"ResponseStatus": {
"ErrorCode": "NotFound",
"Message": "User does not exist",
"StackTrace": "[GetAccessToken: 24.05.2017 13.05.57]:[...],
"Errors": []
}