|
5 | 5 | use crate::{AuthenticationMethod, ClientId, SessionId, TokenId, oauth::Scopes}; |
6 | 6 | use chrono::{DateTime, Utc}; |
7 | 7 | use serde::{Deserialize, Serialize}; |
8 | | -use std::collections::BTreeMap; |
9 | 8 |
|
10 | 9 | piquel_common::open_str_enum! { |
11 | 10 | /// `amr` values (RFC 8176): how the user authenticated. This is the wire view, |
@@ -237,76 +236,3 @@ pub struct UserInfo { |
237 | 236 | #[serde(flatten)] |
238 | 237 | pub profile: ProfileClaims, |
239 | 238 | } |
240 | | - |
241 | | -/// The `events` member a logout token must carry (OIDC Back-Channel Logout 1.0 §2.4). |
242 | | -pub const BACKCHANNEL_LOGOUT_EVENT: &str = "http://schemas.openid.net/event/backchannel-logout"; |
243 | | - |
244 | | -/// An event's payload: a JSON object, empty for back-channel logout. Members are |
245 | | -/// ignored, but anything other than an object is refused. |
246 | | -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)] |
247 | | -pub struct Event {} |
248 | | - |
249 | | -impl<'de> Deserialize<'de> for Event { |
250 | | - /// Requires an object. |
251 | | - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { |
252 | | - BTreeMap::<String, serde::de::IgnoredAny>::deserialize(deserializer).map(|_| Self {}) |
253 | | - } |
254 | | -} |
255 | | - |
256 | | -/// A claim whose presence alone matters, whatever its value, such as a logout |
257 | | -/// token's forbidden `nonce`. Present even as `null`; serialized as `null`. |
258 | | -#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] |
259 | | -pub struct Present; |
260 | | - |
261 | | -impl Present { |
262 | | - /// Reads a claim as present whenever it appears. |
263 | | - fn some<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<Option<Self>, D::Error> { |
264 | | - serde::de::IgnoredAny::deserialize(deserializer).map(|_| Some(Self)) |
265 | | - } |
266 | | -} |
267 | | - |
268 | | -impl Serialize for Present { |
269 | | - /// Writes `null`. |
270 | | - fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { |
271 | | - serializer.serialize_unit() |
272 | | - } |
273 | | -} |
274 | | - |
275 | | -/// Claims of a back-channel logout token (OIDC Back-Channel Logout 1.0 §2.4), signed |
276 | | -/// with `typ: logout+jwt`. It ends one session (`sid`) or every session of a user at |
277 | | -/// one client (`sub` alone). |
278 | | -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] |
279 | | -pub struct LogoutTokenClaims { |
280 | | - /// Issuer, exactly as in discovery. |
281 | | - pub iss: String, |
282 | | - /// The client being told. |
283 | | - pub aud: Audience, |
284 | | - /// Issue time. |
285 | | - #[serde(with = "chrono::serde::ts_seconds")] |
286 | | - pub iat: DateTime<Utc>, |
287 | | - /// Expiry time. |
288 | | - #[serde(with = "chrono::serde::ts_seconds")] |
289 | | - pub exp: DateTime<Utc>, |
290 | | - /// Unique token ID, for replay detection. |
291 | | - pub jti: String, |
292 | | - /// The user whose sessions end. |
293 | | - #[serde(default, skip_serializing_if = "Option::is_none")] |
294 | | - pub sub: Option<String>, |
295 | | - /// The session that ends. |
296 | | - #[serde(default, skip_serializing_if = "Option::is_none")] |
297 | | - pub sid: Option<SessionId>, |
298 | | - /// Must contain [`BACKCHANNEL_LOGOUT_EVENT`]. |
299 | | - #[expect( |
300 | | - clippy::zero_sized_map_values, |
301 | | - reason = "The wire format is a JSON object of event URIs to empty objects." |
302 | | - )] |
303 | | - pub events: BTreeMap<String, Event>, |
304 | | - /// Must be absent, even as `null`, so an ID token can never pass as a logout |
305 | | - /// token. |
306 | | - #[serde( |
307 | | - default, |
308 | | - deserialize_with = "Present::some", |
309 | | - skip_serializing_if = "Option::is_none" |
310 | | - )] |
311 | | - pub nonce: Option<Present>, |
312 | | -} |
0 commit comments