Skip to main content

validate_token

Function validate_token 

Source
pub async fn validate_token<B>(
    req: &Request<B>,
    validator_url: &str,
) -> Result<bool>
Expand description

Validate an authentication token from a request

This function extracts the token from the request headers and validates it against an external authentication service.

§Arguments

  • req - The incoming HTTP request containing the token
  • validator_url - URL of the external token validation service

§Returns

  • Ok(true) - Token is valid
  • Ok(false) - Token is invalid
  • Err(...) - Error occurred during validation

§Example

use tiny_proxy::auth::validator::validate_token;
use hyper::Request;
use bytes::Bytes;
use http_body_util::Empty;

let is_valid = validate_token(&req, "http://auth-service:8080/validate").await?;