Skip to main content

nominal_api_conjure/conjure/objects/authorization/
get_access_token_request.rs

1/// We accept an OIDC ID token issued by a trusted identity provider as proof of authentication.
2/// The ID token is validated and exchanged for a Nominal access token with a 24h expiry.
3/// This ID token should generally be short lived since it is fungible with a Nominal access token
4/// via this endpoint. An access token, if provided, is used to get user information from the OIDC
5/// userinfo endpoint.
6/// A workspace rid or an org rid should be provided if the user is a guest or a member of multiple
7/// orgs. These will be resolved to determine what org the Nominal token should be minted for.
8#[derive(
9    Debug,
10    Clone,
11    conjure_object::serde::Serialize,
12    conjure_object::serde::Deserialize,
13    PartialEq,
14    Eq,
15    PartialOrd,
16    Ord,
17    Hash
18)]
19#[serde(crate = "conjure_object::serde")]
20#[conjure_object::private::staged_builder::staged_builder]
21#[builder(crate = conjure_object::private::staged_builder, update, inline)]
22pub struct GetAccessTokenRequest {
23    #[builder(into)]
24    #[serde(rename = "idToken")]
25    id_token: String,
26    #[builder(default, into)]
27    #[serde(rename = "accessToken", skip_serializing_if = "Option::is_none", default)]
28    access_token: Option<String>,
29    #[builder(default, into)]
30    #[serde(rename = "orgRid", skip_serializing_if = "Option::is_none", default)]
31    org_rid: Option<super::super::authentication::api::OrgRid>,
32    #[builder(default, into)]
33    #[serde(rename = "workspaceRid", skip_serializing_if = "Option::is_none", default)]
34    workspace_rid: Option<super::super::api::rids::WorkspaceRid>,
35}
36impl GetAccessTokenRequest {
37    /// Constructs a new instance of the type.
38    #[inline]
39    pub fn new(id_token: impl Into<String>) -> Self {
40        Self::builder().id_token(id_token).build()
41    }
42    #[inline]
43    pub fn id_token(&self) -> &str {
44        &*self.id_token
45    }
46    #[inline]
47    pub fn access_token(&self) -> Option<&str> {
48        self.access_token.as_ref().map(|o| &**o)
49    }
50    #[inline]
51    pub fn org_rid(&self) -> Option<&super::super::authentication::api::OrgRid> {
52        self.org_rid.as_ref().map(|o| &*o)
53    }
54    #[inline]
55    pub fn workspace_rid(&self) -> Option<&super::super::api::rids::WorkspaceRid> {
56        self.workspace_rid.as_ref().map(|o| &*o)
57    }
58}