steer_auth_plugin/
plugin.rs1use crate::directive::AuthDirective;
2use crate::error::AuthError;
3use crate::flow::{AuthMethod, DynAuthenticationFlow};
4use crate::identifiers::{ModelId, ProviderId};
5use crate::storage::AuthStorage;
6use crate::strategy::AuthSource;
7use async_trait::async_trait;
8use std::sync::Arc;
9
10#[async_trait]
11pub trait AuthPlugin: Send + Sync {
12 fn provider_id(&self) -> ProviderId;
13 fn supported_methods(&self) -> Vec<AuthMethod>;
14
15 fn create_flow(&self, storage: Arc<dyn AuthStorage>) -> Option<Box<dyn DynAuthenticationFlow>>;
16
17 async fn resolve_auth(
18 &self,
19 storage: Arc<dyn AuthStorage>,
20 ) -> Result<Option<AuthDirective>, AuthError>;
21
22 async fn is_authenticated(&self, storage: Arc<dyn AuthStorage>) -> Result<bool, AuthError>;
23
24 fn model_visibility(&self) -> Option<Box<dyn ModelVisibilityPolicy>> {
25 None
26 }
27}
28
29pub trait ModelVisibilityPolicy: Send + Sync {
30 fn allow_model(&self, model_id: &ModelId, auth_source: &AuthSource) -> bool;
31}