From d3d39970ecb7c84aae6d8b600b3e117a450f0af1 Mon Sep 17 00:00:00 2001 From: Frederik Terstappen Date: Fri, 6 Sep 2024 11:22:05 +0200 Subject: [PATCH] feat: Add project_roles and metadata to all IntrospectedUser (#571) Adds `project_roles` and `metadata` fields to all three `IntrospectedUser` structs --- src/actix/introspection/extractor.rs | 5 +++++ src/axum/introspection/user.rs | 2 ++ src/rocket/introspection/guard.rs | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/src/actix/introspection/extractor.rs b/src/actix/introspection/extractor.rs index 0f9669e..4089a91 100644 --- a/src/actix/introspection/extractor.rs +++ b/src/actix/introspection/extractor.rs @@ -5,6 +5,7 @@ use actix_web::error::{ErrorInternalServerError, ErrorUnauthorized}; use actix_web::{Error, FromRequest, HttpRequest}; use custom_error::custom_error; use openidconnect::TokenIntrospectionResponse; +use std::collections::HashMap; use crate::actix::introspection::config::IntrospectionConfig; use crate::oidc::introspection::{introspect, IntrospectionError, ZitadelIntrospectionResponse}; @@ -37,6 +38,8 @@ pub struct IntrospectedUser { pub email: Option, pub email_verified: Option, pub locale: Option, + pub project_roles: Option>>, + pub metadata: Option>, } impl From for IntrospectedUser { @@ -51,6 +54,8 @@ impl From for IntrospectedUser { email: response.extra_fields().email.clone(), email_verified: response.extra_fields().email_verified, locale: response.extra_fields().locale.clone(), + project_roles: response.extra_fields().project_roles.clone(), + metadata: response.extra_fields().metadata.clone(), } } } diff --git a/src/axum/introspection/user.rs b/src/axum/introspection/user.rs index ea4def4..ecdd218 100644 --- a/src/axum/introspection/user.rs +++ b/src/axum/introspection/user.rs @@ -108,6 +108,7 @@ pub struct IntrospectedUser { pub email_verified: Option, pub locale: Option, pub project_roles: Option>>, + pub metadata: Option>, } #[async_trait] @@ -193,6 +194,7 @@ impl From for IntrospectedUser { email_verified: response.extra_fields().email_verified, locale: response.extra_fields().locale.clone(), project_roles: response.extra_fields().project_roles.clone(), + metadata: response.extra_fields().metadata.clone(), } } } diff --git a/src/rocket/introspection/guard.rs b/src/rocket/introspection/guard.rs index e8e5fd1..11d9c38 100644 --- a/src/rocket/introspection/guard.rs +++ b/src/rocket/introspection/guard.rs @@ -3,6 +3,7 @@ use openidconnect::TokenIntrospectionResponse; use rocket::http::Status; use rocket::request::{FromRequest, Outcome}; use rocket::{async_trait, Request}; +use std::collections::HashMap; use crate::oidc::introspection::{introspect, IntrospectionError, ZitadelIntrospectionResponse}; use crate::rocket::introspection::IntrospectionConfig; @@ -35,6 +36,8 @@ pub struct IntrospectedUser { pub email: Option, pub email_verified: Option, pub locale: Option, + pub project_roles: Option>>, + pub metadata: Option>, } impl From for IntrospectedUser { @@ -49,6 +52,8 @@ impl From for IntrospectedUser { email: response.extra_fields().email.clone(), email_verified: response.extra_fields().email_verified, locale: response.extra_fields().locale.clone(), + project_roles: response.extra_fields().project_roles.clone(), + metadata: response.extra_fields().metadata.clone(), } } }