Expand description
§r-token
§日本語
actix-web / axum 向けの軽量なインメモリ token 認証ヘルパーです。
このライブラリは主に次の 2 つを提供します:
RTokenManager: token(UUID v4)の発行/失効と、インメモリストアの管理RUser:Authorizationを自動検証する extractor(actix-web / axum)
§認証の流れ
- ログイン処理で
RTokenManager::loginを呼び、ユーザー ID と TTL(秒)を渡します。 - token をクライアントへ返します(多くはプレーンテキストまたは JSON)。
- クライアントは
Authorizationheader で token を送ります:Authorization: <token>Authorization: Bearer <token>
- handler が
RUserを引数に持つと保護されたエンドポイントになります。抽出が成功すれば認証済みとして扱われ、失敗すれば actix-web がエラーを返します。
§English
A small, in-memory token authentication helper for actix-web and axum.
The library exposes two main building blocks:
RTokenManager: issues and revokes tokens (UUID v4) and keeps an in-memory store.RUser: an extractor that validatesAuthorizationautomatically (actix-web / axum).
§How authentication works
- Your login handler calls
RTokenManager::loginwith a user id and a TTL (seconds). - The token is returned to the client (typically as plain text or JSON).
- The client sends the token back via
Authorizationheader:Authorization: <token>Authorization: Bearer <token>
- Any handler that declares an
RUserparameter becomes a protected endpoint. If extraction succeeds, the request is considered authenticated; otherwise the framework returns an error.
Structs§
- RToken
Manager - 日本語
- RUser
- 日本語
- Token
Source Config - 日本語