django / django/new-features

One Time Password/Token Generation and Validation

Open
#22 6 comments 17 reactions 0 assignees View on GitHub
Authentication/Users
Dominant language
No language data
Stars
188
Forks
7
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow Django's Code of Conduct

### Feature Description

A built in way for Django to generate and validate one time tokens.

### Problem

Many web apps use single-use codes for:
* Passwordless login
* Email/phone verification
* 2FA

Despite being a common requirement, Django currently lacks a built-in, standardized mechanism for generating and validating one-time passwords (OTPs).

### Request or proposal

proposal

### Additional Details

_No response_

### Implementation Suggestions

Proposed APIs (obviously I'm still open to suggestions):
```python
from django.auth import otp

token = otp.create(key, ttl, length, allowed_chars)

# Passing in `delete=True` would invalidate the token after successful validation
otp.authenticate(key, token, invalidate=False)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.