1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Stream-level authentication and authorization.
//!
//! Like [`Observer`](crate::Observer), authorization is an **injected trait with
//! a permit-all default** — the engine never bakes in an identity scheme. A host
//! supplies a [`StreamAuthenticator`] (validating stream keys, signed tokens,
//! IP allow-lists, an external auth service, …) and the engine enforces it on
//! the publish and play paths.
//!
//! ```no_run
//! use arcly_stream::auth::{Credentials, StreamAuthenticator};
//! use arcly_stream::prelude::*;
//! use std::sync::Arc;
//!
//! struct KeyAuth { secret: String }
//!
//! #[async_trait]
//! impl StreamAuthenticator for KeyAuth {
//! async fn authorize_publish(&self, _key: &StreamKey, creds: &Credentials) -> Result<()> {
//! match creds.token.as_deref() {
//! Some(t) if t == self.secret => Ok(()),
//! _ => Err(StreamError::Unauthorized("bad publish key".into())),
//! }
//! }
//! }
//!
//! let engine = Engine::builder()
//! .application(AppSpec::new("live"))
//! .authenticator(KeyAuth { secret: "s3cr3t".into() })
//! .build();
//! # let _ = engine;
//! ```
use crate::;
use async_trait;
use SocketAddr;
/// Credentials presented by a connecting publisher or player.
///
/// Protocol handlers populate whichever fields their transport carries (an RTMP
/// stream key in `token`, a WHIP bearer in `token`, the peer address in `addr`,
/// query parameters in `params`).
/// Authorizes publish and play attempts. Both methods **default to permit**, so
/// an implementor overrides only the side it gates.
/// The default authenticator: permits everything. Selected when the builder is
/// given none, preserving the engine's zero-policy default.
;