https://github.com/bugov/http-basic-auth
💂UTF-8 compatible implementation of HTTP Basic Auth for Python
https://github.com/bugov/http-basic-auth
basic-authentication http python python3 utf-8
Last synced: 17 days ago
JSON representation
💂UTF-8 compatible implementation of HTTP Basic Auth for Python
- Host: GitHub
- URL: https://github.com/bugov/http-basic-auth
- Owner: bugov
- License: other
- Created: 2018-02-20T17:20:19.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-07T21:37:37.000Z (over 6 years ago)
- Last Synced: 2025-09-24T23:34:28.731Z (6 months ago)
- Topics: basic-authentication, http, python, python3, utf-8
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# http-basic-auth
[](https://travis-ci.org/bugov/http-basic-auth)
Yep, it's one more HTTP Basic Auth python lib. The second. And I tried
to use the first, but it had a bug (which I fixed) and... completely
wrong realisation of non-latin encoding/decoding.
# Install
```bash
pip3 install http-basic-auth
```
# ♥️ RFC
It supports only RFC-2617 (RFC-7617 planning).
If you find some mistake – please write to [issue list 🐨](https://github.com/bugov/http-basic-auth/issues).
# ♥️ Non-latin symbols
http-basic-auth ♥ utf-8
```bash
→ curl --user name:пароль https://httpbin.org/headers
{
"headers": {
"Accept": "*/*",
"Authorization": "Basic bmFtZTrQv9Cw0YDQvtC70Yw=",
"Connection": "close",
"Host": "httpbin.org",
"User-Agent": "curl/7.54.0"
}
}
```
And even
```bash
→ curl --user 😁:пар:öль https://httpbin.org/headers
{
"headers": {
"Accept": "*/*",
"Authorization": "Basic 8J+YgTrQv9Cw0YA6w7bQu9GM",
"Connection": "close",
"Host": "httpbin.org",
"User-Agent": "curl/7.54.0"
}
}
```
All works well
```python
from http_basic_auth import generate_header, parse_header
assert "Basic 8J+YgTrQv9Cw0YA6w7bQu9GM" == generate_header('😁', 'пар:öль')
assert ('😁', 'пар:öль') == parse_header("Basic 8J+YgTrQv9Cw0YA6w7bQu9GM")
```
# Provides functions
- `generate_header`: `(user, password) → "Basic "`
- `parse_header`: `"Basic " → (user, password)`
- `generate_token`: `(user, password) → ""`
- `parse_token`: `"" → (user, password)`