linkerd2_proxy_api/gen/
io.linkerd.proxy.identity.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct CertifyRequest {
4    #[prost(string, tag = "1")]
5    pub identity: ::prost::alloc::string::String,
6    /// Proof of the requester's identity.
7    ///
8    /// In Kubernetes, for instance, this is the contents of a service account
9    /// token.
10    #[prost(bytes = "vec", tag = "2")]
11    pub token: ::prost::alloc::vec::Vec<u8>,
12    /// A PEM-encoded x509 Certificate Signing Request.
13    #[prost(bytes = "vec", tag = "3")]
14    pub certificate_signing_request: ::prost::alloc::vec::Vec<u8>,
15}
16#[derive(Clone, PartialEq, ::prost::Message)]
17pub struct CertifyResponse {
18    /// A PEM-encoded x509 Certificate.
19    #[prost(bytes = "vec", tag = "1")]
20    pub leaf_certificate: ::prost::alloc::vec::Vec<u8>,
21    /// A list of PEM-encoded x509 Certificates that establish the trust chain
22    /// between the leaf_certificate and the well-known trust anchors.
23    #[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}
30/// Generated client implementations.
31pub 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<T> IdentityClient<T>
46    where
47        T: tonic::client::GrpcService<tonic::body::Body>,
48        T::Error: Into<StdError>,
49        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
50        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
51    {
52        pub fn new(inner: T) -> Self {
53            let inner = tonic::client::Grpc::new(inner);
54            Self { inner }
55        }
56        pub fn with_origin(inner: T, origin: Uri) -> Self {
57            let inner = tonic::client::Grpc::with_origin(inner, origin);
58            Self { inner }
59        }
60        pub fn with_interceptor<F>(
61            inner: T,
62            interceptor: F,
63        ) -> IdentityClient<InterceptedService<T, F>>
64        where
65            F: tonic::service::Interceptor,
66            T::ResponseBody: Default,
67            T: tonic::codegen::Service<
68                http::Request<tonic::body::Body>,
69                Response = http::Response<
70                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
71                >,
72            >,
73            <T as tonic::codegen::Service<
74                http::Request<tonic::body::Body>,
75            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
76        {
77            IdentityClient::new(InterceptedService::new(inner, interceptor))
78        }
79        /// Compress requests with the given encoding.
80        ///
81        /// This requires the server to support it otherwise it might respond with an
82        /// error.
83        #[must_use]
84        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
85            self.inner = self.inner.send_compressed(encoding);
86            self
87        }
88        /// Enable decompressing responses.
89        #[must_use]
90        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
91            self.inner = self.inner.accept_compressed(encoding);
92            self
93        }
94        /// Limits the maximum size of a decoded message.
95        ///
96        /// Default: `4MB`
97        #[must_use]
98        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
99            self.inner = self.inner.max_decoding_message_size(limit);
100            self
101        }
102        /// Limits the maximum size of an encoded message.
103        ///
104        /// Default: `usize::MAX`
105        #[must_use]
106        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
107            self.inner = self.inner.max_encoding_message_size(limit);
108            self
109        }
110        /// Requests that a time-bounded certificate be signed.
111        ///
112        /// The requester must provide a token that verifies the client's identity and
113        /// a Certificate Signing Request that adheres to the service naming rules.
114        ///
115        /// Errors are returned when the provided request is invalid or when
116        /// authentication cannot be performed.
117        pub async fn certify(
118            &mut self,
119            request: impl tonic::IntoRequest<super::CertifyRequest>,
120        ) -> std::result::Result<
121            tonic::Response<super::CertifyResponse>,
122            tonic::Status,
123        > {
124            self.inner
125                .ready()
126                .await
127                .map_err(|e| {
128                    tonic::Status::unknown(
129                        format!("Service was not ready: {}", e.into()),
130                    )
131                })?;
132            let codec = tonic::codec::ProstCodec::default();
133            let path = http::uri::PathAndQuery::from_static(
134                "/io.linkerd.proxy.identity.Identity/Certify",
135            );
136            let mut req = request.into_request();
137            req.extensions_mut()
138                .insert(
139                    GrpcMethod::new("io.linkerd.proxy.identity.Identity", "Certify"),
140                );
141            self.inner.unary(req, path, codec).await
142        }
143    }
144}
145/// Generated server implementations.
146pub mod identity_server {
147    #![allow(
148        unused_variables,
149        dead_code,
150        missing_docs,
151        clippy::wildcard_imports,
152        clippy::let_unit_value,
153    )]
154    use tonic::codegen::*;
155    /// Generated trait containing gRPC methods that should be implemented for use with IdentityServer.
156    #[async_trait]
157    pub trait Identity: std::marker::Send + std::marker::Sync + 'static {
158        /// Requests that a time-bounded certificate be signed.
159        ///
160        /// The requester must provide a token that verifies the client's identity and
161        /// a Certificate Signing Request that adheres to the service naming rules.
162        ///
163        /// Errors are returned when the provided request is invalid or when
164        /// authentication cannot be performed.
165        async fn certify(
166            &self,
167            request: tonic::Request<super::CertifyRequest>,
168        ) -> std::result::Result<tonic::Response<super::CertifyResponse>, tonic::Status>;
169    }
170    #[derive(Debug)]
171    pub struct IdentityServer<T> {
172        inner: Arc<T>,
173        accept_compression_encodings: EnabledCompressionEncodings,
174        send_compression_encodings: EnabledCompressionEncodings,
175        max_decoding_message_size: Option<usize>,
176        max_encoding_message_size: Option<usize>,
177    }
178    impl<T> IdentityServer<T> {
179        pub fn new(inner: T) -> Self {
180            Self::from_arc(Arc::new(inner))
181        }
182        pub fn from_arc(inner: Arc<T>) -> Self {
183            Self {
184                inner,
185                accept_compression_encodings: Default::default(),
186                send_compression_encodings: Default::default(),
187                max_decoding_message_size: None,
188                max_encoding_message_size: None,
189            }
190        }
191        pub fn with_interceptor<F>(
192            inner: T,
193            interceptor: F,
194        ) -> InterceptedService<Self, F>
195        where
196            F: tonic::service::Interceptor,
197        {
198            InterceptedService::new(Self::new(inner), interceptor)
199        }
200        /// Enable decompressing requests with the given encoding.
201        #[must_use]
202        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
203            self.accept_compression_encodings.enable(encoding);
204            self
205        }
206        /// Compress responses with the given encoding, if the client supports it.
207        #[must_use]
208        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
209            self.send_compression_encodings.enable(encoding);
210            self
211        }
212        /// Limits the maximum size of a decoded message.
213        ///
214        /// Default: `4MB`
215        #[must_use]
216        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
217            self.max_decoding_message_size = Some(limit);
218            self
219        }
220        /// Limits the maximum size of an encoded message.
221        ///
222        /// Default: `usize::MAX`
223        #[must_use]
224        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
225            self.max_encoding_message_size = Some(limit);
226            self
227        }
228    }
229    impl<T, B> tonic::codegen::Service<http::Request<B>> for IdentityServer<T>
230    where
231        T: Identity,
232        B: Body + std::marker::Send + 'static,
233        B::Error: Into<StdError> + std::marker::Send + 'static,
234    {
235        type Response = http::Response<tonic::body::Body>;
236        type Error = std::convert::Infallible;
237        type Future = BoxFuture<Self::Response, Self::Error>;
238        fn poll_ready(
239            &mut self,
240            _cx: &mut Context<'_>,
241        ) -> Poll<std::result::Result<(), Self::Error>> {
242            Poll::Ready(Ok(()))
243        }
244        fn call(&mut self, req: http::Request<B>) -> Self::Future {
245            match req.uri().path() {
246                "/io.linkerd.proxy.identity.Identity/Certify" => {
247                    #[allow(non_camel_case_types)]
248                    struct CertifySvc<T: Identity>(pub Arc<T>);
249                    impl<T: Identity> tonic::server::UnaryService<super::CertifyRequest>
250                    for CertifySvc<T> {
251                        type Response = super::CertifyResponse;
252                        type Future = BoxFuture<
253                            tonic::Response<Self::Response>,
254                            tonic::Status,
255                        >;
256                        fn call(
257                            &mut self,
258                            request: tonic::Request<super::CertifyRequest>,
259                        ) -> Self::Future {
260                            let inner = Arc::clone(&self.0);
261                            let fut = async move {
262                                <T as Identity>::certify(&inner, request).await
263                            };
264                            Box::pin(fut)
265                        }
266                    }
267                    let accept_compression_encodings = self.accept_compression_encodings;
268                    let send_compression_encodings = self.send_compression_encodings;
269                    let max_decoding_message_size = self.max_decoding_message_size;
270                    let max_encoding_message_size = self.max_encoding_message_size;
271                    let inner = self.inner.clone();
272                    let fut = async move {
273                        let method = CertifySvc(inner);
274                        let codec = tonic::codec::ProstCodec::default();
275                        let mut grpc = tonic::server::Grpc::new(codec)
276                            .apply_compression_config(
277                                accept_compression_encodings,
278                                send_compression_encodings,
279                            )
280                            .apply_max_message_size_config(
281                                max_decoding_message_size,
282                                max_encoding_message_size,
283                            );
284                        let res = grpc.unary(method, req).await;
285                        Ok(res)
286                    };
287                    Box::pin(fut)
288                }
289                _ => {
290                    Box::pin(async move {
291                        let mut response = http::Response::new(
292                            tonic::body::Body::default(),
293                        );
294                        let headers = response.headers_mut();
295                        headers
296                            .insert(
297                                tonic::Status::GRPC_STATUS,
298                                (tonic::Code::Unimplemented as i32).into(),
299                            );
300                        headers
301                            .insert(
302                                http::header::CONTENT_TYPE,
303                                tonic::metadata::GRPC_CONTENT_TYPE,
304                            );
305                        Ok(response)
306                    })
307                }
308            }
309        }
310    }
311    impl<T> Clone for IdentityServer<T> {
312        fn clone(&self) -> Self {
313            let inner = self.inner.clone();
314            Self {
315                inner,
316                accept_compression_encodings: self.accept_compression_encodings,
317                send_compression_encodings: self.send_compression_encodings,
318                max_decoding_message_size: self.max_decoding_message_size,
319                max_encoding_message_size: self.max_encoding_message_size,
320            }
321        }
322    }
323    /// Generated gRPC service name
324    pub const SERVICE_NAME: &str = "io.linkerd.proxy.identity.Identity";
325    impl<T> tonic::server::NamedService for IdentityServer<T> {
326        const NAME: &'static str = SERVICE_NAME;
327    }
328}