@@ -119,6 +119,17 @@ def __init__(
119
119
# map of client headers to their value/callable/coroutine
120
120
self .__client_headers = client_headers
121
121
122
+ # ID tokens contain sensitive user information (claims). Transmitting
123
+ # these over HTTP exposes the data to interception and unauthorized
124
+ # access. Always use HTTPS to ensure secure communication and protect
125
+ # user privacy.
126
+ if (
127
+ required_authn_params or required_authz_tokens or client_headers
128
+ ) and not self .__url .startswith ("https://" ):
129
+ warn (
130
+ "Sending ID token over HTTP. User data may be exposed. Use HTTPS for secure communication."
131
+ )
132
+
122
133
@property
123
134
def _name (self ) -> str :
124
135
return self .__name__
@@ -246,27 +257,18 @@ async def __call__(self, *args: Any, **kwargs: Any) -> str:
246
257
payload [param ] = await resolve_value (value )
247
258
248
259
# create headers for auth services
249
- auth_headers = {}
260
+ headers = {}
250
261
for auth_service , token_getter in self .__auth_service_token_getters .items ():
251
- auth_headers [self .__get_auth_header (auth_service )] = await resolve_value (
262
+ headers [self .__get_auth_header (auth_service )] = await resolve_value (
252
263
token_getter
253
264
)
254
265
for client_header_name , client_header_val in self .__client_headers .items ():
255
- auth_headers [client_header_name ] = await resolve_value (client_header_val )
256
-
257
- # ID tokens contain sensitive user information (claims). Transmitting
258
- # these over HTTP exposes the data to interception and unauthorized
259
- # access. Always use HTTPS to ensure secure communication and protect
260
- # user privacy.
261
- if auth_headers and not self .__url .startswith ("https://" ):
262
- warn (
263
- "Sending ID token over HTTP. User data may be exposed. Use HTTPS for secure communication."
264
- )
266
+ headers [client_header_name ] = await resolve_value (client_header_val )
265
267
266
268
async with self .__session .post (
267
269
self .__url ,
268
270
json = payload ,
269
- headers = auth_headers ,
271
+ headers = headers ,
270
272
) as resp :
271
273
body = await resp .json ()
272
274
if resp .status < 200 or resp .status >= 300 :
0 commit comments