### Controller code
public async Redirect({ ally } : HttpContextContract) {
return ally.use('github').redirect()
}
public async callback({ ally, auth, response } : HttpContextContract) {
const gith = ally.use('github')
if (gith.accessDenied()) {
return 'Access was denied'
}
/**
* Unable to verify the CSRF state
*/
if (gith.stateMisMatch()) {
return 'Request expired. Retry again'
}
if (gith.hasError()) {
return suap.getError()
}
//continues...
}
When redirecting, Ally sends two set-cookies, one of which is encrypted (as expected) and the second one without any encryption. Debugging the code, I realized that the encrypted set-cookie stores the correct state and the decrypted one stores a second state completely different from the first.
Below are the HTTP headers, the state passed by the URL is OKAb_ICu0VGAzaHA6H39JGla_K-XYF55. I checked this state, it's the same one that arrives at the Oauth2Driver.persistState method.
On return to the callback, the encrypted cookie no longer exists, it has been overwritten by the decrypted cookie, causing an error 'Request expired. Retry again'.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Package version
4.1.1
Node.js and npm version
Node: v16.13.2, npm: 8.3.2, yarn: 1.22.15
Sample Code (to reproduce the issue)
When redirecting, Ally sends two set-cookies, one of which is encrypted (as expected) and the second one without any encryption. Debugging the code, I realized that the encrypted set-cookie stores the correct state and the decrypted one stores a second state completely different from the first.
Below are the HTTP headers, the state passed by the URL is OKAb_ICu0VGAzaHA6H39JGla_K-XYF55. I checked this state, it's the same one that arrives at the Oauth2Driver.persistState method.
On return to the callback, the encrypted cookie no longer exists, it has been overwritten by the decrypted cookie, causing an error 'Request expired. Retry again'.
The application is configured to use the AdonisJS web version, using sessions to keep the user authenticated.