Crate cc_auth

source ·
Expand description

Crate that implementing simple authorization system.

CC Auth uses passwords’ hashing with salts, SHA3-256 hash function and Redis-like tokens’ storage.

Usage:

use bb8_redis::{RedisConnectionManager, bb8::Pool};
use cc_auth::{ApiToken, check_token};
use cc_utils::prelude::MResult;

pub async fn authorized_action(
  cacher: &Pool<RedisConnectionManager>,
  token: ApiToken,
) -> MResult<()> {
  let user_id = check_token(&token, cacher).await?;
  Ok(())
}

Structs§

Constants§

  • Limit of token validation time (each token lives 28 days).
  • Limit of tokens for one user (3 tokens). If the token limit is exceeded, old tokens will be overwritten.

Functions§

Type Aliases§

  • Token as string (e.g. one that got from Authorization header).
  • User identifier type.