Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/handlers/src/oauth2/introspection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const INACTIVE: IntrospectionResponse = IntrospectionResponse {
username: None,
token_type: None,
exp: None,
expires_in: None,
iat: None,
nbf: None,
sub: None,
Expand Down Expand Up @@ -281,6 +282,9 @@ pub(crate) async fn post(
username,
token_type: Some(OAuthTokenTypeHint::AccessToken),
exp: access_token.expires_at,
expires_in: access_token
.expires_at
.map(|expires_at| expires_at.signed_duration_since(clock.now()).num_seconds()),
iat: Some(access_token.created_at),
nbf: Some(access_token.created_at),
sub,
Expand Down Expand Up @@ -341,6 +345,7 @@ pub(crate) async fn post(
username,
token_type: Some(OAuthTokenTypeHint::RefreshToken),
exp: None,
expires_in: None,
iat: Some(refresh_token.created_at),
nbf: Some(refresh_token.created_at),
sub,
Expand Down Expand Up @@ -414,6 +419,9 @@ pub(crate) async fn post(
username: Some(user.username),
token_type: Some(OAuthTokenTypeHint::AccessToken),
exp: access_token.expires_at,
expires_in: access_token
.expires_at
.map(|expires_at| expires_at.signed_duration_since(clock.now()).num_seconds()),
iat: Some(access_token.created_at),
nbf: Some(access_token.created_at),
sub: Some(user.sub),
Expand Down Expand Up @@ -487,6 +495,7 @@ pub(crate) async fn post(
username: Some(user.username),
token_type: Some(OAuthTokenTypeHint::RefreshToken),
exp: None,
expires_in: None,
iat: Some(refresh_token.created_at),
nbf: Some(refresh_token.created_at),
sub: Some(user.sub),
Expand Down
4 changes: 4 additions & 0 deletions crates/oauth2-types/src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ pub struct IntrospectionResponse {
#[serde_as(as = "Option<TimestampSeconds>")]
pub exp: Option<DateTime<Utc>>,

/// Relative timestamp indicating when the token will expire,
/// in seconds from the current instant.
pub expires_in: Option<i64>,

/// Timestamp indicating when the token was issued.
#[serde_as(as = "Option<TimestampSeconds>")]
pub iat: Option<DateTime<Utc>>,
Expand Down
Loading