ory / fosite

Extensible security first OAuth 2.0 and OpenID Connect SDK for Go.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=fosite
Apache License 2.0
2.28k stars 356 forks source link

fix: call DeleteOpenIDConnectSession during successful authcode exchange #793

Closed cfryanr closed 4 months ago

cfryanr commented 4 months ago

Fixes https://github.com/ory/fosite/issues/790. Please see description and comments in https://github.com/ory/fosite/issues/790 for more information about why this is a necessary and safe change.

Remove deprecation of `DeleteOpenIDConnectSession` storage interface function and call it during
authorization code exchange. This function was not previously called. Implementors of the openid
storage interface who which to preserve the old behavior should implement this function as a
no-op which returns `nil`.

Related Issue or Design Document

Fixes #790.

Checklist

Further comments

cfryanr commented 4 months ago

The format check seems to have failed complaining about almost every copyright date in the repo. Please advise if I should update any copyright dates in this PR.

aeneasr commented 4 months ago

Nice! I recently found the same issue on our prod system. I think we can also delete the PKCE entry if it's not already being deleted

james-d-elliott commented 4 months ago

Small aside, this makes me think there is an issue with the tests since there is only one mock EXPECT added for DeleteOpenIDConnectSession.

cfryanr commented 4 months ago

Thanks for accepting the PR.

I think we can also delete the PKCE entry if it's not already being deleted

I believe those are already correctly deleted here https://github.com/ory/fosite/blob/v0.46.0/handler/pkce/handler.go#L133.

Small aside, this makes me think there is an issue with the tests since there is only one mock EXPECT added for DeleteOpenIDConnectSession.

I added two EXPECTs in the PR. One for each pre-existing happy path unit test.

aeneasr commented 4 months ago

You're right - those are indeed already covered!

james-d-elliott commented 4 months ago

I added two EXPECTs in the PR. One for each pre-existing happy path unit test.

Oh your right my bad. I swore when I looked at the "should pass" test it didn't have one. Was really confusing why it was passing without it. But it's there!