@@ -235,20 +235,27 @@ def __init__(
235
235
self .cert = cert
236
236
237
237
def _get_endpoint_url (
238
- self , openid_configuration : Dict [str , Any ], field : str
238
+ self ,
239
+ openid_configuration : Dict [str , Any ],
240
+ field : str ,
241
+ * ,
242
+ absolute : bool = False ,
239
243
) -> str :
240
244
"""
241
245
Return the specified endpoint from OpenID configuration.
242
246
243
- We only retain the path here, as the host might not be relevant in our context.
247
+ If `absolute` is `False`, we only retain the path,
248
+ as the host might is not always relevant in our context.
244
249
245
250
Typically, we might be in a Docker environment where the client app has to make
246
251
request to the Fief server through Docker networking. Therefore, we do not
247
252
want the client to use the absolute URL generated by OpenID Configuration, but
248
253
rather stick to the host specified on the client configuration.
249
254
"""
250
- splitted_url = urlsplit (openid_configuration [field ])
251
- return splitted_url .path
255
+ if not absolute :
256
+ splitted_url = urlsplit (openid_configuration [field ])
257
+ return splitted_url .path
258
+ return openid_configuration [field ]
252
259
253
260
def _auth_url (
254
261
self ,
@@ -285,7 +292,7 @@ def _auth_url(
285
292
params = {** params , ** extras_params }
286
293
287
294
authorization_endpoint = self ._get_endpoint_url (
288
- openid_configuration , "authorization_endpoint"
295
+ openid_configuration , "authorization_endpoint" , absolute = True
289
296
)
290
297
return f"{ authorization_endpoint } ?{ urlencode (params )} "
291
298
0 commit comments