From fc30a3b7e540fb1a2a4d0efe6361dcd3832f46e7 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Thu, 22 Feb 2024 13:38:29 +0000 Subject: [PATCH] Add OIDC CustomClaims struct. This is needed when custom claims are returned that are not used by ChirpStack, but might be used during user registration. --- chirpstack/src/api/oidc.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chirpstack/src/api/oidc.rs b/chirpstack/src/api/oidc.rs index 38dddf9a..6a49841a 100644 --- a/chirpstack/src/api/oidc.rs +++ b/chirpstack/src/api/oidc.rs @@ -1,3 +1,4 @@ +use std::collections::HashMap; use std::str::FromStr; use anyhow::{Context, Result}; @@ -7,12 +8,13 @@ use openidconnect::core::{ CoreResponseType, }; use openidconnect::reqwest::async_http_client; +use openidconnect::{AdditionalClaims, UserInfoClaims}; use openidconnect::{ AuthenticationFlow, AuthorizationCode, ClientId, ClientSecret, CsrfToken, IssuerUrl, Nonce, OAuth2TokenResponse, RedirectUrl, Scope, }; -use openidconnect::{EmptyAdditionalClaims, UserInfoClaims}; use serde::{Deserialize, Serialize}; +use serde_json::Value; use tracing::{error, trace}; use warp::{Rejection, Reply}; @@ -20,7 +22,15 @@ use crate::config; use crate::helpers::errors::PrintFullError; use crate::storage::{get_async_redis_conn, redis_key}; -pub type User = UserInfoClaims; +pub type User = UserInfoClaims; + +#[derive(Debug, Serialize, Deserialize)] +pub struct CustomClaims { + #[serde(flatten)] + other: HashMap, +} + +impl AdditionalClaims for CustomClaims {} #[derive(Serialize, Deserialize)] pub struct CallbackArgs {