mirror of
https://github.com/MedzikUser/rust-crypto-utils
synced 2024-08-14 23:54:22 +00:00
update
This commit is contained in:
parent
deb2a9b86d
commit
40e7c3ddab
3 changed files with 46 additions and 1 deletions
23
CHANGELOG.md
Normal file
23
CHANGELOG.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
<!-- next-header -->
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.2.0] - 2022-06-11
|
||||
### Added
|
||||
- Json Web Token
|
||||
|
||||
## [0.1.0] - 2022-06-11
|
||||
### Added
|
||||
- Sha1, Sha256, Sha512 hasher
|
||||
|
||||
<!-- next-url -->
|
||||
[Unreleased]: https://github.com/MedzikUser/imgurs/compare/v0.2.0...HEAD
|
||||
[0.2.0]: https://github.com/MedzikUser/imgurs/commits/v0.2.0
|
||||
[0.1.0]: https://github.com/MedzikUser/imgurs/commits/v0.1.0
|
|
@ -1,10 +1,31 @@
|
|||
//! Module for creating and decoding json web token.
|
||||
//!
|
||||
//! **Required `jwt` feature!**
|
||||
//!
|
||||
//! Examples:
|
||||
//! ```
|
||||
//! use crypto_utils::jsonwebtoken::{Claims, Token};
|
||||
//!
|
||||
//! let secret = b"secret";
|
||||
//! let user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
|
||||
//!
|
||||
//! // create claims
|
||||
//! let claims = Claims::new(user_id, 24);
|
||||
//!
|
||||
//! // create token
|
||||
//! let token = Token::new(secret, claims).unwrap();
|
||||
//!
|
||||
//! // decode token
|
||||
//! let decoded = Token::decode(secret, token.encoded).unwrap();
|
||||
//! ```
|
||||
|
||||
use chrono::{Duration, Utc};
|
||||
use jsonwebtoken::{
|
||||
errors::Error, Algorithm, DecodingKey, EncodingKey, Header, TokenData, Validation,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Json Web Token Claims
|
||||
/// Token Claims
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Claims {
|
||||
/// Token value
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
//! ```
|
||||
//! use crypto_utils::jsonwebtoken::{Claims, Token};
|
||||
//!
|
||||
//! let secret = b"secret";
|
||||
//! let user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
|
||||
//!
|
||||
//! // create claims
|
||||
|
|
Loading…
Reference in a new issue