Trên GitHub, miguelgrinberg/REST-auth đã đạt 916 sao, ngôn ngữ Python. Example application for my RESTful Authentication with Flask article.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
(venv) $ python api.py
* Running on http://127.0.0.1:5000/
* Restarting with reloader
Then from a different terminal window you can send requests.
API Documentation
POST /api/users
Register a new user.
The body must contain a JSON object that defines username and password fields.
On success a status code 201 is returned. The body of the response contains a JSON object with the newly added user. A Location header contains the URI of the new user.
On failure status code 400 (bad request) is returned.
Notes:
The password is hashed before it is stored in the database. Once hashed, the original password is discarded.
In a production deployment secure HTTP must be used to protect the password in transit.
GET /api/users/<int:id>
Return a user.
On success a status code 200 is returned. The body of the response contains a JSON object with the requested user.
On failure status code 400 (bad request) is returned.
GET /api/token
Return an authentication token.
This request must be authenticated using a HTTP Basic Authentication header.
On success a JSON object is returned with a field token set to the authentication token for the user and a field duration set to the (approximate) number of seconds the token is valid.
On failure status code 401 (unauthorized) is returned.
GET /api/resource
Return a protected resource.
This request must be authenticated using a HTTP Basic Authentication header. Instead of username and password, the client can provide a valid authentication token in the username field. If using an authentication token the password field is not used and can be set to any value.
On success a JSON object with data for the authenticated user is returned.
On failure status code 401 (unauthorized) is returned.
Example
The following curl command registers a new user with username miguel and password python:
And now during the token validity period there is no need to send username and password to authenticate anymore:
$ curl -u eyJhbGciOiJIUzI1NiIsImV4cCI6MTM4NTY2OTY1NSwiaWF0IjoxMzg1NjY5MDU1fQ.eyJpZCI6MX0.XbOEFJkhjHJ5uRINh2JA1BPzXjSohKYDRT472wGOvjc:x -i -X GET http://127.0.0.1:5000/api/resource
HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 30
Server: Werkzeug/0.9.4 Python/2.7.3
Date: Thu, 28 Nov 2013 20:05:08 GMT
{
"data": "Hello, miguel!"
}
Once the token expires it cannot be used anymore and the client needs to request a new one. Note that in this last example the password is arbitrarily set to x, since the password isn't used for token authentication.
An interesting side effect of this implementation is that it is possible to use an unexpired token as authentication to request a new token that extends the expiration time. This effectively allows the client to change from one token to the next and never need to send username and password after the initial token was obtained.
Change Log
v0.3 - Return token duration.
v0.2 - Return a 201 status code and Location header from /api/users endpoint.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/miguelgrinberg/REST-auth là nguồn chính thức.
miguelgrinberg/REST-auth có bao nhiêu sao?
miguelgrinberg/REST-auth có 916 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/miguelgrinberg/REST-auth. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
miguelgrinberg/REST-auth có phải mã nguồn mở không?
Có — miguelgrinberg/REST-auth phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/miguelgrinberg/REST-auth.
miguelgrinberg/REST-auth còn đang phát triển không?
Commit gần nhất trên miguelgrinberg/REST-auth là 3.5 năm trước (theo timestamp GitHub). Repo có 327 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
miguelgrinberg/REST-auth dùng license gì?
miguelgrinberg/REST-auth phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
miguelgrinberg/REST-auth là gì?
miguelgrinberg/REST-auth (miguelgrinberg/REST-auth) là dự án Python trên GitHub. Theo mô tả gốc: Example application for my RESTful Authentication with Flask article.
miguelgrinberg/REST-auth viết bằng ngôn ngữ gì?
miguelgrinberg/REST-auth chủ yếu viết bằng Python. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
REST-auth có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về REST-auth.