Skip to main content

systemprompt_identifiers/
oauth.rs

1//! OAuth flow identifiers.
2//!
3//! Refresh tokens, access-token `jti`s and authorization codes are opaque
4//! strings minted by the platform or presented back by a client. Their only
5//! shape is non-emptiness: `new` is for a value the platform minted or read
6//! back from storage, `try_new` for a value arriving from outside. A refresh
7//! token family groups every rotation of one grant, an SSO provider id
8//! names a configured identity provider, and an SSO request id correlates an
9//! outbound authentication request with its response.
10//!
11//! Copyright (c) systemprompt.io — Business Source License 1.1.
12//! See <https://systemprompt.io> for licensing details.
13
14crate::define_id!(RefreshTokenId, checked, |value| {
15    crate::macros::validate_non_empty("RefreshTokenId", value)
16});
17crate::define_id!(AccessTokenId, checked, |value| {
18    crate::macros::validate_non_empty("AccessTokenId", value)
19});
20crate::define_id!(AuthorizationCode, checked, |value| {
21    crate::macros::validate_non_empty("AuthorizationCode", value)
22});
23crate::define_id!(ChallengeId, checked, |value| {
24    crate::macros::validate_external_id("ChallengeId", value)
25});
26crate::define_id!(RefreshTokenFamilyId, checked, |value| {
27    crate::macros::validate_external_id("RefreshTokenFamilyId", value)
28});
29crate::define_id!(SsoProviderId);
30
31impl AccessTokenId {
32    pub fn generate() -> Self {
33        Self(uuid::Uuid::new_v4().to_string())
34    }
35}
36
37impl ChallengeId {
38    pub fn generate() -> Self {
39        Self(uuid::Uuid::new_v4().to_string())
40    }
41}