1#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct CertifyRequest {
4 #[prost(string, tag = "1")]
5 pub identity: ::prost::alloc::string::String,
6 #[prost(bytes = "vec", tag = "2")]
11 pub token: ::prost::alloc::vec::Vec<u8>,
12 #[prost(bytes = "vec", tag = "3")]
14 pub certificate_signing_request: ::prost::alloc::vec::Vec<u8>,
15}
16#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
17pub struct CertifyResponse {
18 #[prost(bytes = "vec", tag = "1")]
20 pub leaf_certificate: ::prost::alloc::vec::Vec<u8>,
21 #[prost(bytes = "vec", repeated, tag = "2")]
24 pub intermediate_certificates: ::prost::alloc::vec::Vec<
25 ::prost::alloc::vec::Vec<u8>,
26 >,
27 #[prost(message, optional, tag = "3")]
28 pub valid_until: ::core::option::Option<::prost_types::Timestamp>,
29}
30pub mod identity_client {
32 #![allow(
33 unused_variables,
34 dead_code,
35 missing_docs,
36 clippy::wildcard_imports,
37 clippy::let_unit_value,
38 )]
39 use tonic::codegen::*;
40 use tonic::codegen::http::Uri;
41 #[derive(Debug, Clone)]
42 pub struct IdentityClient<T> {
43 inner: tonic::client::Grpc<T>,
44 }
45 impl IdentityClient<tonic::transport::Channel> {
46 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
48 where
49 D: TryInto<tonic::transport::Endpoint>,
50 D::Error: Into<StdError>,
51 {
52 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
53 Ok(Self::new(conn))
54 }
55 }
56 impl<T> IdentityClient<T>
57 where
58 T: tonic::client::GrpcService<tonic::body::Body>,
59 T::Error: Into<StdError>,
60 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
61 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
62 {
63 pub fn new(inner: T) -> Self {
64 let inner = tonic::client::Grpc::new(inner);
65 Self { inner }
66 }
67 pub fn with_origin(inner: T, origin: Uri) -> Self {
68 let inner = tonic::client::Grpc::with_origin(inner, origin);
69 Self { inner }
70 }
71 pub fn with_interceptor<F>(
72 inner: T,
73 interceptor: F,
74 ) -> IdentityClient<InterceptedService<T, F>>
75 where
76 F: tonic::service::Interceptor,
77 T::ResponseBody: Default,
78 T: tonic::codegen::Service<
79 http::Request<tonic::body::Body>,
80 Response = http::Response<
81 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
82 >,
83 >,
84 <T as tonic::codegen::Service<
85 http::Request<tonic::body::Body>,
86 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
87 {
88 IdentityClient::new(InterceptedService::new(inner, interceptor))
89 }
90 #[must_use]
95 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
96 self.inner = self.inner.send_compressed(encoding);
97 self
98 }
99 #[must_use]
101 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
102 self.inner = self.inner.accept_compressed(encoding);
103 self
104 }
105 #[must_use]
109 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
110 self.inner = self.inner.max_decoding_message_size(limit);
111 self
112 }
113 #[must_use]
117 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
118 self.inner = self.inner.max_encoding_message_size(limit);
119 self
120 }
121 pub async fn certify(
129 &mut self,
130 request: impl tonic::IntoRequest<super::CertifyRequest>,
131 ) -> std::result::Result<
132 tonic::Response<super::CertifyResponse>,
133 tonic::Status,
134 > {
135 self.inner
136 .ready()
137 .await
138 .map_err(|e| {
139 tonic::Status::unknown(
140 format!("Service was not ready: {}", e.into()),
141 )
142 })?;
143 let codec = tonic_prost::ProstCodec::default();
144 let path = http::uri::PathAndQuery::from_static(
145 "/io.linkerd.proxy.identity.Identity/Certify",
146 );
147 let mut req = request.into_request();
148 req.extensions_mut()
149 .insert(
150 GrpcMethod::new("io.linkerd.proxy.identity.Identity", "Certify"),
151 );
152 self.inner.unary(req, path, codec).await
153 }
154 }
155}
156pub mod identity_server {
158 #![allow(
159 unused_variables,
160 dead_code,
161 missing_docs,
162 clippy::wildcard_imports,
163 clippy::let_unit_value,
164 )]
165 use tonic::codegen::*;
166 #[async_trait]
168 pub trait Identity: std::marker::Send + std::marker::Sync + 'static {
169 async fn certify(
177 &self,
178 request: tonic::Request<super::CertifyRequest>,
179 ) -> std::result::Result<tonic::Response<super::CertifyResponse>, tonic::Status>;
180 }
181 #[derive(Debug)]
182 pub struct IdentityServer<T> {
183 inner: Arc<T>,
184 accept_compression_encodings: EnabledCompressionEncodings,
185 send_compression_encodings: EnabledCompressionEncodings,
186 max_decoding_message_size: Option<usize>,
187 max_encoding_message_size: Option<usize>,
188 }
189 impl<T> IdentityServer<T> {
190 pub fn new(inner: T) -> Self {
191 Self::from_arc(Arc::new(inner))
192 }
193 pub fn from_arc(inner: Arc<T>) -> Self {
194 Self {
195 inner,
196 accept_compression_encodings: Default::default(),
197 send_compression_encodings: Default::default(),
198 max_decoding_message_size: None,
199 max_encoding_message_size: None,
200 }
201 }
202 pub fn with_interceptor<F>(
203 inner: T,
204 interceptor: F,
205 ) -> InterceptedService<Self, F>
206 where
207 F: tonic::service::Interceptor,
208 {
209 InterceptedService::new(Self::new(inner), interceptor)
210 }
211 #[must_use]
213 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
214 self.accept_compression_encodings.enable(encoding);
215 self
216 }
217 #[must_use]
219 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
220 self.send_compression_encodings.enable(encoding);
221 self
222 }
223 #[must_use]
227 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
228 self.max_decoding_message_size = Some(limit);
229 self
230 }
231 #[must_use]
235 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
236 self.max_encoding_message_size = Some(limit);
237 self
238 }
239 }
240 impl<T, B> tonic::codegen::Service<http::Request<B>> for IdentityServer<T>
241 where
242 T: Identity,
243 B: Body + std::marker::Send + 'static,
244 B::Error: Into<StdError> + std::marker::Send + 'static,
245 {
246 type Response = http::Response<tonic::body::Body>;
247 type Error = std::convert::Infallible;
248 type Future = BoxFuture<Self::Response, Self::Error>;
249 fn poll_ready(
250 &mut self,
251 _cx: &mut Context<'_>,
252 ) -> Poll<std::result::Result<(), Self::Error>> {
253 Poll::Ready(Ok(()))
254 }
255 fn call(&mut self, req: http::Request<B>) -> Self::Future {
256 match req.uri().path() {
257 "/io.linkerd.proxy.identity.Identity/Certify" => {
258 #[allow(non_camel_case_types)]
259 struct CertifySvc<T: Identity>(pub Arc<T>);
260 impl<T: Identity> tonic::server::UnaryService<super::CertifyRequest>
261 for CertifySvc<T> {
262 type Response = super::CertifyResponse;
263 type Future = BoxFuture<
264 tonic::Response<Self::Response>,
265 tonic::Status,
266 >;
267 fn call(
268 &mut self,
269 request: tonic::Request<super::CertifyRequest>,
270 ) -> Self::Future {
271 let inner = Arc::clone(&self.0);
272 let fut = async move {
273 <T as Identity>::certify(&inner, request).await
274 };
275 Box::pin(fut)
276 }
277 }
278 let accept_compression_encodings = self.accept_compression_encodings;
279 let send_compression_encodings = self.send_compression_encodings;
280 let max_decoding_message_size = self.max_decoding_message_size;
281 let max_encoding_message_size = self.max_encoding_message_size;
282 let inner = self.inner.clone();
283 let fut = async move {
284 let method = CertifySvc(inner);
285 let codec = tonic_prost::ProstCodec::default();
286 let mut grpc = tonic::server::Grpc::new(codec)
287 .apply_compression_config(
288 accept_compression_encodings,
289 send_compression_encodings,
290 )
291 .apply_max_message_size_config(
292 max_decoding_message_size,
293 max_encoding_message_size,
294 );
295 let res = grpc.unary(method, req).await;
296 Ok(res)
297 };
298 Box::pin(fut)
299 }
300 _ => {
301 Box::pin(async move {
302 let mut response = http::Response::new(
303 tonic::body::Body::default(),
304 );
305 let headers = response.headers_mut();
306 headers
307 .insert(
308 tonic::Status::GRPC_STATUS,
309 (tonic::Code::Unimplemented as i32).into(),
310 );
311 headers
312 .insert(
313 http::header::CONTENT_TYPE,
314 tonic::metadata::GRPC_CONTENT_TYPE,
315 );
316 Ok(response)
317 })
318 }
319 }
320 }
321 }
322 impl<T> Clone for IdentityServer<T> {
323 fn clone(&self) -> Self {
324 let inner = self.inner.clone();
325 Self {
326 inner,
327 accept_compression_encodings: self.accept_compression_encodings,
328 send_compression_encodings: self.send_compression_encodings,
329 max_decoding_message_size: self.max_decoding_message_size,
330 max_encoding_message_size: self.max_encoding_message_size,
331 }
332 }
333 }
334 pub const SERVICE_NAME: &str = "io.linkerd.proxy.identity.Identity";
336 impl<T> tonic::server::NamedService for IdentityServer<T> {
337 const NAME: &'static str = SERVICE_NAME;
338 }
339}