Rust auth token format similar to JWT.
| src | Remove unwraps in the library | |
| .gitignore | Basic stuff | |
| Cargo.lock | Basic stuff | |
| Cargo.toml | Basic stuff | |
| LICENSE | Initial commit | |
| README.md | update readme | |
auth
Rust auth token format similar to JWT.
Installation
Clone the repo and put this in your Cargo.toml file:
[dependencies]
auth_token = { path = "/path/to/cloned" }
Usage
To use it you need to define your own type and implement the ByteRepr trait.
example:
struct Token{}implByteReprforTest{fn to_bytes(&self)-> Vec<u8>{}fn from_bytes(bytes: Vec<u8>)-> Self{}}after that call from_token or to_token and provide your secret key.
to_token returns a string with the following format: "<base64 encoded data>:<base64 encoded HMAC signature>".
from_token should decode it correctly. It'll return the decoded struct and TokenStatus that MUST be checked.