Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX][14.0] auth_saml: Add FOR UPDATE NOWAIT clause to SAML provider query #716

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions auth_saml/models/auth_saml_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@
except SignatureError:
# we have a metadata url: try to refresh the metadata document
if self.idp_metadata_url:
self.env.cr.execute(

Check warning on line 311 in auth_saml/models/auth_saml_provider.py

View check run for this annotation

Codecov / codecov/patch

auth_saml/models/auth_saml_provider.py#L311

Added line #L311 was not covered by tests
"""
SELECT id, idp_metadata
FROM auth_saml_provider
WHERE id=%s FOR UPDATE NOWAIT
""",
(self.id,),
)
self.action_refresh_metadata_from_url()
# retry: if it fails again, we let the exception flow
client = self._get_client_for_provider(base_url)
Expand Down Expand Up @@ -424,11 +432,6 @@

# lock the records we might update, so that multiple simultaneous login
# attempts will not cause concurrent updates
provider_ids = tuple(providers_to_update.keys())
self.env.cr.execute(
"SELECT id FROM auth_saml_provider WHERE id in %s FOR UPDATE",
(tuple(provider_ids),),
)
updated = False
for provider in providers:
if provider.id in providers_to_update:
Expand Down
Loading