Skip to content

Commit d3d3997

Browse files
authored
feat: Add project_roles and metadata to all IntrospectedUser (#571)
Adds `project_roles` and `metadata` fields to all three `IntrospectedUser` structs
1 parent 4ebde7b commit d3d3997

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/actix/introspection/extractor.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use actix_web::error::{ErrorInternalServerError, ErrorUnauthorized};
55
use actix_web::{Error, FromRequest, HttpRequest};
66
use custom_error::custom_error;
77
use openidconnect::TokenIntrospectionResponse;
8+
use std::collections::HashMap;
89

910
use crate::actix::introspection::config::IntrospectionConfig;
1011
use crate::oidc::introspection::{introspect, IntrospectionError, ZitadelIntrospectionResponse};
@@ -37,6 +38,8 @@ pub struct IntrospectedUser {
3738
pub email: Option<String>,
3839
pub email_verified: Option<bool>,
3940
pub locale: Option<String>,
41+
pub project_roles: Option<HashMap<String, HashMap<String, String>>>,
42+
pub metadata: Option<HashMap<String, String>>,
4043
}
4144

4245
impl From<ZitadelIntrospectionResponse> for IntrospectedUser {
@@ -51,6 +54,8 @@ impl From<ZitadelIntrospectionResponse> for IntrospectedUser {
5154
email: response.extra_fields().email.clone(),
5255
email_verified: response.extra_fields().email_verified,
5356
locale: response.extra_fields().locale.clone(),
57+
project_roles: response.extra_fields().project_roles.clone(),
58+
metadata: response.extra_fields().metadata.clone(),
5459
}
5560
}
5661
}

src/axum/introspection/user.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub struct IntrospectedUser {
108108
pub email_verified: Option<bool>,
109109
pub locale: Option<String>,
110110
pub project_roles: Option<HashMap<String, HashMap<String, String>>>,
111+
pub metadata: Option<HashMap<String, String>>,
111112
}
112113

113114
#[async_trait]
@@ -193,6 +194,7 @@ impl From<ZitadelIntrospectionResponse> for IntrospectedUser {
193194
email_verified: response.extra_fields().email_verified,
194195
locale: response.extra_fields().locale.clone(),
195196
project_roles: response.extra_fields().project_roles.clone(),
197+
metadata: response.extra_fields().metadata.clone(),
196198
}
197199
}
198200
}

src/rocket/introspection/guard.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use openidconnect::TokenIntrospectionResponse;
33
use rocket::http::Status;
44
use rocket::request::{FromRequest, Outcome};
55
use rocket::{async_trait, Request};
6+
use std::collections::HashMap;
67

78
use crate::oidc::introspection::{introspect, IntrospectionError, ZitadelIntrospectionResponse};
89
use crate::rocket::introspection::IntrospectionConfig;
@@ -35,6 +36,8 @@ pub struct IntrospectedUser {
3536
pub email: Option<String>,
3637
pub email_verified: Option<bool>,
3738
pub locale: Option<String>,
39+
pub project_roles: Option<HashMap<String, HashMap<String, String>>>,
40+
pub metadata: Option<HashMap<String, String>>,
3841
}
3942

4043
impl From<ZitadelIntrospectionResponse> for IntrospectedUser {
@@ -49,6 +52,8 @@ impl From<ZitadelIntrospectionResponse> for IntrospectedUser {
4952
email: response.extra_fields().email.clone(),
5053
email_verified: response.extra_fields().email_verified,
5154
locale: response.extra_fields().locale.clone(),
55+
project_roles: response.extra_fields().project_roles.clone(),
56+
metadata: response.extra_fields().metadata.clone(),
5257
}
5358
}
5459
}

0 commit comments

Comments
 (0)