flv_tls_proxy/
authenticator.rs

1use anyhow::Result;
2use async_trait::async_trait;
3
4use fluvio_future::net::TcpStream;
5use fluvio_future::rust_tls::DefaultServerTlsStream;
6
7/// Abstracts logic to authenticate incoming stream and forward authoization context to target
8#[async_trait]
9pub trait Authenticator: Send + Sync {
10    async fn authenticate(
11        &self,
12        incoming_tls_stream: &DefaultServerTlsStream,
13        target_tcp_stream: &TcpStream,
14    ) -> Result<bool>;
15}
16
17/// Null implementation where authenticate always returns true
18pub(crate) struct NullAuthenticator;
19
20#[async_trait]
21impl Authenticator for NullAuthenticator {
22    async fn authenticate(&self, _: &DefaultServerTlsStream, _: &TcpStream) -> Result<bool> {
23        Ok(true)
24    }
25}