Skip to content

Race condition in creation of Access Token with external OAuth2 server #609

@n2ygk

Description

@n2ygk

In oauth2_validators._get_token_from_authentication_server there's a race condition when two requests both present a new Bearer Access Token causing a SQL insertion error for a uniqueness constraint violation.

This has been exercised in the wild by our project that has a client that makes near simultaneous requests of the same Django endpoint with the same Bearer token (see validate_bearer_token.

I believe the fix is to use AccessToken.objects.get_or_create(). Does this make sense @jleclanche?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions