florimondmanca / djangorestframework-api-key

šŸ” API key permissions for Django REST Framework
https://florimondmanca.github.io/djangorestframework-api-key/
MIT License
678 stars 104 forks source link

Is the API_KEY generated always unique? #236

Closed hilmanski closed 1 year ago

hilmanski commented 1 year ago

Hi

since this key will be used for different users. Is the API_KEY generated always unique? does it have sort of "database" to remember what it has used to make sure no duplication ?

florimondmanca commented 1 year ago

Hi @hilmanski,

Unless I misremember, there is no such mechanism in place for the entire API key. Only the prefix is marked with a UNIQUE constraint. But I donā€™t think we check ahead of time or retry should the same prefix be picked. The package relies on the low collision probability of long strings of tokens for now.

Iā€™ll move this to a discussion but if thereā€™s a specific problem youā€™re encountering because of this, feel free to file a detailed ticket.