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);
24crate::define_id!(RefreshTokenFamilyId);
25crate::define_id!(SsoProviderId);
26
27impl AccessTokenId {
28    pub fn generate() -> Self {
29        Self(uuid::Uuid::new_v4().to_string())
30    }
31}
32
33impl ChallengeId {
34    pub fn generate() -> Self {
35        Self(uuid::Uuid::new_v4().to_string())
36    }
37}