@@ -698,6 +698,32 @@ apr_byte_t oidc_session_pass_tokens(request_rec *r, oidc_cfg_t *cfg, oidc_sessio
698698 return TRUE;
699699}
700700
701+ static void oidc_idtoken_pass_as (request_rec * r , oidc_cfg_t * cfg , oidc_session_t * session ,
702+ oidc_appinfo_pass_in_t pass_in , oidc_appinfo_encoding_t encoding ) {
703+
704+ if ((oidc_cfg_dir_pass_idtoken_as_get (r ) & OIDC_PASS_IDTOKEN_OFF ))
705+ return ;
706+
707+ if ((oidc_cfg_dir_pass_idtoken_as_get (r ) & OIDC_PASS_IDTOKEN_AS_CLAIMS )) {
708+ /* set the id_token in the app headers */
709+ oidc_set_app_claims (r , cfg , oidc_session_get_idtoken_claims (r , session ));
710+ }
711+
712+ if ((oidc_cfg_dir_pass_idtoken_as_get (r ) & OIDC_PASS_IDTOKEN_AS_PAYLOAD )) {
713+ /* pass the id_token JSON object to the app in a header or environment variable */
714+ oidc_util_appinfo_set (r , OIDC_APP_INFO_ID_TOKEN_PAYLOAD ,
715+ oidc_util_json_encode (r -> pool , oidc_session_get_idtoken_claims (r , session ),
716+ JSON_PRESERVE_ORDER | JSON_COMPACT ),
717+ OIDC_DEFAULT_HEADER_PREFIX , pass_in , encoding );
718+ }
719+
720+ if ((oidc_cfg_dir_pass_idtoken_as_get (r ) & OIDC_PASS_IDTOKEN_AS_SERIALIZED )) {
721+ /* pass the compact serialized JWT to the app in a header or environment variable */
722+ oidc_util_appinfo_set (r , OIDC_APP_INFO_ID_TOKEN , oidc_session_get_idtoken (r , session ),
723+ OIDC_DEFAULT_HEADER_PREFIX , pass_in , encoding );
724+ }
725+ }
726+
701727/*
702728 * handle the case where we have identified an existing authentication session for a user
703729 */
@@ -788,30 +814,13 @@ static int oidc_handle_existing_session(request_rec *r, oidc_cfg_t *cfg, oidc_se
788814 /* copy id_token and claims from session to request state and obtain their values */
789815 oidc_copy_tokens_to_request_state (r , session );
790816
791- if ((oidc_cfg_dir_pass_idtoken_as_get (r ) & OIDC_PASS_IDTOKEN_AS_CLAIMS )) {
792- /* set the id_token in the app headers */
793- if (oidc_set_app_claims (r , cfg , oidc_session_get_idtoken_claims (r , session )) == FALSE)
794- return HTTP_INTERNAL_SERVER_ERROR ;
795- }
796-
797- if ((oidc_cfg_dir_pass_idtoken_as_get (r ) & OIDC_PASS_IDTOKEN_AS_PAYLOAD )) {
798- /* pass the id_token JSON object to the app in a header or environment variable */
799- oidc_util_appinfo_set (r , OIDC_APP_INFO_ID_TOKEN_PAYLOAD ,
800- oidc_util_json_encode (r -> pool , oidc_session_get_idtoken_claims (r , session ),
801- JSON_PRESERVE_ORDER | JSON_COMPACT ),
802- OIDC_DEFAULT_HEADER_PREFIX , pass_in , encoding );
803- }
804-
805- if ((oidc_cfg_dir_pass_idtoken_as_get (r ) & OIDC_PASS_IDTOKEN_AS_SERIALIZED )) {
806- /* pass the compact serialized JWT to the app in a header or environment variable */
807- oidc_util_appinfo_set (r , OIDC_APP_INFO_ID_TOKEN , oidc_session_get_idtoken (r , session ),
808- OIDC_DEFAULT_HEADER_PREFIX , pass_in , encoding );
809- }
810-
811817 /* pass the at, rt and at expiry to the application, possibly update the session expiry */
812818 if (oidc_session_pass_tokens (r , cfg , session , extend_session , needs_save ) == FALSE)
813819 return HTTP_INTERNAL_SERVER_ERROR ;
814820
821+ /* pass ID token and claims */
822+ oidc_idtoken_pass_as (r , cfg , session , pass_in , encoding );
823+ /* pass userinfo claims */
815824 oidc_userinfo_pass_as (r , cfg , session , pass_in , encoding );
816825
817826 /* return "user authenticated" status */
0 commit comments