1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
use uuid::Uuid;

/// Represents the requests validation token.
///
/// Validation tokens are used to check the validity of the Profile retrieved
/// the every request submitted to the cluster.
#[derive(Clone, Debug, Deserialize, Serialize, ToSchema, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct TokenDTO {
    /// This token should be used as the request identifier.
    pub token: Uuid,

    /// This field should contains the name of the requester service. Such name
    /// should be used to check if the token was consumed by the downstream
    /// route, enabled by the service router.
    pub own_service: String,
}

impl TokenDTO {
    pub async fn new_undated_token(own_service: String) -> Self {
        Self {
            token: Uuid::new_v4(),
            own_service,
        }
    }
}