#[cfg(feature = "rest-api-actix-web-1")]
pub mod actix_web_1;
#[cfg(feature = "rest-api-actix-web-3")]
pub mod actix_web_3;
pub mod auth;
#[cfg(feature = "rest-api-cors")]
pub mod cors;
mod errors;
pub mod paging;
mod response_models;
pub mod secrets;
pub mod sessions;
use percent_encoding::{AsciiSet, CONTROLS};
#[cfg(feature = "oauth")]
use std::boxed::Box;
#[cfg(feature = "oauth")]
use crate::oauth::{rest_api::OAuthResourceProvider, store::InflightOAuthRequestStore};
pub use errors::{RequestError, RestApiServerError};
pub use response_models::ErrorResponse;
#[cfg(feature = "rest-api-actix-web-1")]
pub use actix_web_1::{
get_authorization_token, into_bytes, into_protobuf, new_websocket_event_sender, require_header,
AuthConfig, Continuation, EventSender, HandlerFunction, Method, ProtocolVersionRangeGuard,
Request, RequestGuard, Resource, Response, ResponseError, RestApi, RestApiBuilder,
RestApiShutdownHandle, RestResourceProvider,
};
#[cfg(any(
feature = "admin-service",
feature = "authorization",
feature = "biome-credentials",
feature = "biome-key-management",
feature = "oauth",
feature = "registry",
))]
pub(crate) const SPLINTER_PROTOCOL_VERSION: u32 = 2;
const QUERY_ENCODE_SET: &AsciiSet = &CONTROLS
.add(b' ')
.add(b'"')
.add(b'<')
.add(b'>')
.add(b'`')
.add(b'=')
.add(b'!')
.add(b'{')
.add(b'}')
.add(b'[')
.add(b']')
.add(b':')
.add(b',');
#[derive(Clone)]
pub enum BindConfig {
#[cfg(feature = "https-bind")]
Https {
bind: String,
cert_path: String,
key_path: String,
},
Http(String),
}
impl std::fmt::Display for BindConfig {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
#[cfg(feature = "https-bind")]
BindConfig::Https { bind, .. } => write!(f, "{}", bind),
BindConfig::Http(bind) => write!(f, "{}", bind),
}
}
}
#[cfg(feature = "oauth")]
pub enum OAuthConfig {
Azure {
client_id: String,
client_secret: String,
redirect_url: String,
oauth_openid_url: String,
inflight_request_store: Box<dyn InflightOAuthRequestStore>,
},
GitHub {
client_id: String,
client_secret: String,
redirect_url: String,
inflight_request_store: Box<dyn InflightOAuthRequestStore>,
},
Google {
client_id: String,
client_secret: String,
redirect_url: String,
inflight_request_store: Box<dyn InflightOAuthRequestStore>,
},
OpenId {
client_id: String,
client_secret: String,
redirect_url: String,
oauth_openid_url: String,
auth_params: Option<Vec<(String, String)>>,
scopes: Option<Vec<String>>,
inflight_request_store: Box<dyn InflightOAuthRequestStore>,
},
}
pub fn percent_encode_filter_query(input: &str) -> String {
percent_encoding::utf8_percent_encode(input, QUERY_ENCODE_SET).to_string()
}