1#[derive(Clone, PartialEq, ::prost::Message)]
6pub struct User {
7 #[prost(string, tag = "1")]
9 pub user_id: ::prost::alloc::string::String,
10 #[prost(string, tag = "2")]
12 pub username: ::prost::alloc::string::String,
13 #[prost(string, tag = "3")]
15 pub email: ::prost::alloc::string::String,
16 #[prost(string, repeated, tag = "4")]
18 pub roles: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
19 #[prost(bool, tag = "5")]
21 pub active: bool,
22 #[prost(message, optional, tag = "6")]
23 pub created_at: ::core::option::Option<prost_types::Timestamp>,
24 #[prost(message, optional, tag = "7")]
25 pub updated_at: ::core::option::Option<prost_types::Timestamp>,
26}
27#[derive(Clone, PartialEq, ::prost::Message)]
31pub struct AuthToken {
32 #[prost(string, tag = "1")]
34 pub token: ::prost::alloc::string::String,
35 #[prost(message, optional, tag = "2")]
36 pub expires_at: ::core::option::Option<prost_types::Timestamp>,
37 #[prost(string, tag = "3")]
39 pub refresh_token: ::prost::alloc::string::String,
40}
41#[derive(Clone, PartialEq, ::prost::Message)]
45pub struct Role {
46 #[prost(string, tag = "1")]
48 pub role_id: ::prost::alloc::string::String,
49 #[prost(string, tag = "2")]
51 pub name: ::prost::alloc::string::String,
52 #[prost(message, repeated, tag = "3")]
53 pub permissions: ::prost::alloc::vec::Vec<Permission>,
54}
55#[derive(Clone, PartialEq, ::prost::Message)]
56pub struct Permission {
57 #[prost(string, tag = "1")]
59 pub permission_id: ::prost::alloc::string::String,
60 #[prost(string, tag = "2")]
62 pub name: ::prost::alloc::string::String,
63 #[prost(string, tag = "3")]
65 pub description: ::prost::alloc::string::String,
66}
67#[derive(Clone, PartialEq, ::prost::Message)]
69pub struct UserRoles {
70 #[prost(string, tag = "1")]
71 pub user_id: ::prost::alloc::string::String,
72 #[prost(string, repeated, tag = "2")]
74 pub role_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
75}
76#[derive(Clone, PartialEq, ::prost::Message)]
80pub struct AuthenticateRequest {
81 #[prost(string, tag = "1")]
82 pub username: ::prost::alloc::string::String,
83 #[prost(string, tag = "2")]
84 pub password: ::prost::alloc::string::String,
85}
86#[derive(Clone, PartialEq, ::prost::Message)]
87pub struct AuthenticateResponse {
88 #[prost(message, optional, tag = "1")]
89 pub token: ::core::option::Option<AuthToken>,
90 #[prost(message, optional, tag = "2")]
91 pub user: ::core::option::Option<User>,
92}
93#[derive(Clone, PartialEq, ::prost::Message)]
94pub struct ValidateTokenRequest {
95 #[prost(string, tag = "1")]
96 pub token: ::prost::alloc::string::String,
97}
98#[derive(Clone, PartialEq, ::prost::Message)]
99pub struct ValidateTokenResponse {
100 #[prost(message, optional, tag = "1")]
101 pub user: ::core::option::Option<User>,
102 #[prost(bool, tag = "2")]
103 pub valid: bool,
104}
105#[derive(Clone, PartialEq, ::prost::Message)]
106pub struct GetUserPermissionsRequest {
107 #[prost(string, tag = "1")]
108 pub user_id: ::prost::alloc::string::String,
109}
110#[derive(Clone, PartialEq, ::prost::Message)]
111pub struct GetUserPermissionsResponse {
112 #[prost(message, repeated, tag = "1")]
113 pub permissions: ::prost::alloc::vec::Vec<Permission>,
114}
115pub mod auth_service_client {
117 #![allow(
118 unused_variables,
119 dead_code,
120 missing_docs,
121 clippy::wildcard_imports,
122 clippy::let_unit_value,
123 )]
124 use tonic::codegen::*;
125 use tonic::codegen::http::Uri;
126 #[derive(Debug, Clone)]
130 pub struct AuthServiceClient<T> {
131 inner: tonic::client::Grpc<T>,
132 }
133 impl AuthServiceClient<tonic::transport::Channel> {
134 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
136 where
137 D: TryInto<tonic::transport::Endpoint>,
138 D::Error: Into<StdError>,
139 {
140 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
141 Ok(Self::new(conn))
142 }
143 }
144 impl<T> AuthServiceClient<T>
145 where
146 T: tonic::client::GrpcService<tonic::body::Body>,
147 T::Error: Into<StdError>,
148 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
149 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
150 {
151 pub fn new(inner: T) -> Self {
152 let inner = tonic::client::Grpc::new(inner);
153 Self { inner }
154 }
155 pub fn with_origin(inner: T, origin: Uri) -> Self {
156 let inner = tonic::client::Grpc::with_origin(inner, origin);
157 Self { inner }
158 }
159 pub fn with_interceptor<F>(
160 inner: T,
161 interceptor: F,
162 ) -> AuthServiceClient<InterceptedService<T, F>>
163 where
164 F: tonic::service::Interceptor,
165 T::ResponseBody: Default,
166 T: tonic::codegen::Service<
167 http::Request<tonic::body::Body>,
168 Response = http::Response<
169 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
170 >,
171 >,
172 <T as tonic::codegen::Service<
173 http::Request<tonic::body::Body>,
174 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
175 {
176 AuthServiceClient::new(InterceptedService::new(inner, interceptor))
177 }
178 #[must_use]
183 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
184 self.inner = self.inner.send_compressed(encoding);
185 self
186 }
187 #[must_use]
189 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
190 self.inner = self.inner.accept_compressed(encoding);
191 self
192 }
193 #[must_use]
197 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
198 self.inner = self.inner.max_decoding_message_size(limit);
199 self
200 }
201 #[must_use]
205 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
206 self.inner = self.inner.max_encoding_message_size(limit);
207 self
208 }
209 pub async fn authenticate(
211 &mut self,
212 request: impl tonic::IntoRequest<super::AuthenticateRequest>,
213 ) -> std::result::Result<
214 tonic::Response<super::AuthenticateResponse>,
215 tonic::Status,
216 > {
217 self.inner
218 .ready()
219 .await
220 .map_err(|e| {
221 tonic::Status::unknown(
222 format!("Service was not ready: {}", e.into()),
223 )
224 })?;
225 let codec = tonic::codec::ProstCodec::default();
226 let path = http::uri::PathAndQuery::from_static(
227 "/aiscanned.v1.auth.AuthService/Authenticate",
228 );
229 let mut req = request.into_request();
230 req.extensions_mut()
231 .insert(
232 GrpcMethod::new("aiscanned.v1.auth.AuthService", "Authenticate"),
233 );
234 self.inner.unary(req, path, codec).await
235 }
236 pub async fn validate_token(
238 &mut self,
239 request: impl tonic::IntoRequest<super::ValidateTokenRequest>,
240 ) -> std::result::Result<
241 tonic::Response<super::ValidateTokenResponse>,
242 tonic::Status,
243 > {
244 self.inner
245 .ready()
246 .await
247 .map_err(|e| {
248 tonic::Status::unknown(
249 format!("Service was not ready: {}", e.into()),
250 )
251 })?;
252 let codec = tonic::codec::ProstCodec::default();
253 let path = http::uri::PathAndQuery::from_static(
254 "/aiscanned.v1.auth.AuthService/ValidateToken",
255 );
256 let mut req = request.into_request();
257 req.extensions_mut()
258 .insert(
259 GrpcMethod::new("aiscanned.v1.auth.AuthService", "ValidateToken"),
260 );
261 self.inner.unary(req, path, codec).await
262 }
263 pub async fn get_user_permissions(
265 &mut self,
266 request: impl tonic::IntoRequest<super::GetUserPermissionsRequest>,
267 ) -> std::result::Result<
268 tonic::Response<super::GetUserPermissionsResponse>,
269 tonic::Status,
270 > {
271 self.inner
272 .ready()
273 .await
274 .map_err(|e| {
275 tonic::Status::unknown(
276 format!("Service was not ready: {}", e.into()),
277 )
278 })?;
279 let codec = tonic::codec::ProstCodec::default();
280 let path = http::uri::PathAndQuery::from_static(
281 "/aiscanned.v1.auth.AuthService/GetUserPermissions",
282 );
283 let mut req = request.into_request();
284 req.extensions_mut()
285 .insert(
286 GrpcMethod::new(
287 "aiscanned.v1.auth.AuthService",
288 "GetUserPermissions",
289 ),
290 );
291 self.inner.unary(req, path, codec).await
292 }
293 }
294}
295pub mod auth_service_server {
297 #![allow(
298 unused_variables,
299 dead_code,
300 missing_docs,
301 clippy::wildcard_imports,
302 clippy::let_unit_value,
303 )]
304 use tonic::codegen::*;
305 #[async_trait]
307 pub trait AuthService: std::marker::Send + std::marker::Sync + 'static {
308 async fn authenticate(
310 &self,
311 request: tonic::Request<super::AuthenticateRequest>,
312 ) -> std::result::Result<
313 tonic::Response<super::AuthenticateResponse>,
314 tonic::Status,
315 >;
316 async fn validate_token(
318 &self,
319 request: tonic::Request<super::ValidateTokenRequest>,
320 ) -> std::result::Result<
321 tonic::Response<super::ValidateTokenResponse>,
322 tonic::Status,
323 >;
324 async fn get_user_permissions(
326 &self,
327 request: tonic::Request<super::GetUserPermissionsRequest>,
328 ) -> std::result::Result<
329 tonic::Response<super::GetUserPermissionsResponse>,
330 tonic::Status,
331 >;
332 }
333 #[derive(Debug)]
337 pub struct AuthServiceServer<T> {
338 inner: Arc<T>,
339 accept_compression_encodings: EnabledCompressionEncodings,
340 send_compression_encodings: EnabledCompressionEncodings,
341 max_decoding_message_size: Option<usize>,
342 max_encoding_message_size: Option<usize>,
343 }
344 impl<T> AuthServiceServer<T> {
345 pub fn new(inner: T) -> Self {
346 Self::from_arc(Arc::new(inner))
347 }
348 pub fn from_arc(inner: Arc<T>) -> Self {
349 Self {
350 inner,
351 accept_compression_encodings: Default::default(),
352 send_compression_encodings: Default::default(),
353 max_decoding_message_size: None,
354 max_encoding_message_size: None,
355 }
356 }
357 pub fn with_interceptor<F>(
358 inner: T,
359 interceptor: F,
360 ) -> InterceptedService<Self, F>
361 where
362 F: tonic::service::Interceptor,
363 {
364 InterceptedService::new(Self::new(inner), interceptor)
365 }
366 #[must_use]
368 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
369 self.accept_compression_encodings.enable(encoding);
370 self
371 }
372 #[must_use]
374 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
375 self.send_compression_encodings.enable(encoding);
376 self
377 }
378 #[must_use]
382 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
383 self.max_decoding_message_size = Some(limit);
384 self
385 }
386 #[must_use]
390 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
391 self.max_encoding_message_size = Some(limit);
392 self
393 }
394 }
395 impl<T, B> tonic::codegen::Service<http::Request<B>> for AuthServiceServer<T>
396 where
397 T: AuthService,
398 B: Body + std::marker::Send + 'static,
399 B::Error: Into<StdError> + std::marker::Send + 'static,
400 {
401 type Response = http::Response<tonic::body::Body>;
402 type Error = std::convert::Infallible;
403 type Future = BoxFuture<Self::Response, Self::Error>;
404 fn poll_ready(
405 &mut self,
406 _cx: &mut Context<'_>,
407 ) -> Poll<std::result::Result<(), Self::Error>> {
408 Poll::Ready(Ok(()))
409 }
410 fn call(&mut self, req: http::Request<B>) -> Self::Future {
411 match req.uri().path() {
412 "/aiscanned.v1.auth.AuthService/Authenticate" => {
413 #[allow(non_camel_case_types)]
414 struct AuthenticateSvc<T: AuthService>(pub Arc<T>);
415 impl<
416 T: AuthService,
417 > tonic::server::UnaryService<super::AuthenticateRequest>
418 for AuthenticateSvc<T> {
419 type Response = super::AuthenticateResponse;
420 type Future = BoxFuture<
421 tonic::Response<Self::Response>,
422 tonic::Status,
423 >;
424 fn call(
425 &mut self,
426 request: tonic::Request<super::AuthenticateRequest>,
427 ) -> Self::Future {
428 let inner = Arc::clone(&self.0);
429 let fut = async move {
430 <T as AuthService>::authenticate(&inner, request).await
431 };
432 Box::pin(fut)
433 }
434 }
435 let accept_compression_encodings = self.accept_compression_encodings;
436 let send_compression_encodings = self.send_compression_encodings;
437 let max_decoding_message_size = self.max_decoding_message_size;
438 let max_encoding_message_size = self.max_encoding_message_size;
439 let inner = self.inner.clone();
440 let fut = async move {
441 let method = AuthenticateSvc(inner);
442 let codec = tonic::codec::ProstCodec::default();
443 let mut grpc = tonic::server::Grpc::new(codec)
444 .apply_compression_config(
445 accept_compression_encodings,
446 send_compression_encodings,
447 )
448 .apply_max_message_size_config(
449 max_decoding_message_size,
450 max_encoding_message_size,
451 );
452 let res = grpc.unary(method, req).await;
453 Ok(res)
454 };
455 Box::pin(fut)
456 }
457 "/aiscanned.v1.auth.AuthService/ValidateToken" => {
458 #[allow(non_camel_case_types)]
459 struct ValidateTokenSvc<T: AuthService>(pub Arc<T>);
460 impl<
461 T: AuthService,
462 > tonic::server::UnaryService<super::ValidateTokenRequest>
463 for ValidateTokenSvc<T> {
464 type Response = super::ValidateTokenResponse;
465 type Future = BoxFuture<
466 tonic::Response<Self::Response>,
467 tonic::Status,
468 >;
469 fn call(
470 &mut self,
471 request: tonic::Request<super::ValidateTokenRequest>,
472 ) -> Self::Future {
473 let inner = Arc::clone(&self.0);
474 let fut = async move {
475 <T as AuthService>::validate_token(&inner, request).await
476 };
477 Box::pin(fut)
478 }
479 }
480 let accept_compression_encodings = self.accept_compression_encodings;
481 let send_compression_encodings = self.send_compression_encodings;
482 let max_decoding_message_size = self.max_decoding_message_size;
483 let max_encoding_message_size = self.max_encoding_message_size;
484 let inner = self.inner.clone();
485 let fut = async move {
486 let method = ValidateTokenSvc(inner);
487 let codec = tonic::codec::ProstCodec::default();
488 let mut grpc = tonic::server::Grpc::new(codec)
489 .apply_compression_config(
490 accept_compression_encodings,
491 send_compression_encodings,
492 )
493 .apply_max_message_size_config(
494 max_decoding_message_size,
495 max_encoding_message_size,
496 );
497 let res = grpc.unary(method, req).await;
498 Ok(res)
499 };
500 Box::pin(fut)
501 }
502 "/aiscanned.v1.auth.AuthService/GetUserPermissions" => {
503 #[allow(non_camel_case_types)]
504 struct GetUserPermissionsSvc<T: AuthService>(pub Arc<T>);
505 impl<
506 T: AuthService,
507 > tonic::server::UnaryService<super::GetUserPermissionsRequest>
508 for GetUserPermissionsSvc<T> {
509 type Response = super::GetUserPermissionsResponse;
510 type Future = BoxFuture<
511 tonic::Response<Self::Response>,
512 tonic::Status,
513 >;
514 fn call(
515 &mut self,
516 request: tonic::Request<super::GetUserPermissionsRequest>,
517 ) -> Self::Future {
518 let inner = Arc::clone(&self.0);
519 let fut = async move {
520 <T as AuthService>::get_user_permissions(&inner, request)
521 .await
522 };
523 Box::pin(fut)
524 }
525 }
526 let accept_compression_encodings = self.accept_compression_encodings;
527 let send_compression_encodings = self.send_compression_encodings;
528 let max_decoding_message_size = self.max_decoding_message_size;
529 let max_encoding_message_size = self.max_encoding_message_size;
530 let inner = self.inner.clone();
531 let fut = async move {
532 let method = GetUserPermissionsSvc(inner);
533 let codec = tonic::codec::ProstCodec::default();
534 let mut grpc = tonic::server::Grpc::new(codec)
535 .apply_compression_config(
536 accept_compression_encodings,
537 send_compression_encodings,
538 )
539 .apply_max_message_size_config(
540 max_decoding_message_size,
541 max_encoding_message_size,
542 );
543 let res = grpc.unary(method, req).await;
544 Ok(res)
545 };
546 Box::pin(fut)
547 }
548 _ => {
549 Box::pin(async move {
550 let mut response = http::Response::new(
551 tonic::body::Body::default(),
552 );
553 let headers = response.headers_mut();
554 headers
555 .insert(
556 tonic::Status::GRPC_STATUS,
557 (tonic::Code::Unimplemented as i32).into(),
558 );
559 headers
560 .insert(
561 http::header::CONTENT_TYPE,
562 tonic::metadata::GRPC_CONTENT_TYPE,
563 );
564 Ok(response)
565 })
566 }
567 }
568 }
569 }
570 impl<T> Clone for AuthServiceServer<T> {
571 fn clone(&self) -> Self {
572 let inner = self.inner.clone();
573 Self {
574 inner,
575 accept_compression_encodings: self.accept_compression_encodings,
576 send_compression_encodings: self.send_compression_encodings,
577 max_decoding_message_size: self.max_decoding_message_size,
578 max_encoding_message_size: self.max_encoding_message_size,
579 }
580 }
581 }
582 pub const SERVICE_NAME: &str = "aiscanned.v1.auth.AuthService";
584 impl<T> tonic::server::NamedService for AuthServiceServer<T> {
585 const NAME: &'static str = SERVICE_NAME;
586 }
587}