1
+ import posixpath
2
+
1
3
from collections .abc import Awaitable , Callable
2
4
from typing import Any
3
5
@@ -166,11 +168,14 @@ def build_metadata(
166
168
client_registration_options : ClientRegistrationOptions ,
167
169
revocation_options : RevocationOptions ,
168
170
) -> OAuthMetadata :
171
+ def append_path (base : str , suffix : str ) -> str :
172
+ return posixpath .join (base .rstrip ("/" ), suffix .lstrip ("/" ))
173
+
169
174
authorization_url = modify_url_path (
170
- issuer_url , lambda path : path . rstrip ( "/" ) + AUTHORIZATION_PATH . lstrip ( "/" )
175
+ issuer_url , lambda path : append_path ( path , AUTHORIZATION_PATH )
171
176
)
172
177
token_url = modify_url_path (
173
- issuer_url , lambda path : path . rstrip ( "/" ) + TOKEN_PATH . lstrip ( "/" )
178
+ issuer_url , lambda path : append_path ( path , TOKEN_PATH )
174
179
)
175
180
# Create metadata
176
181
metadata = OAuthMetadata (
@@ -194,13 +199,13 @@ def build_metadata(
194
199
# Add registration endpoint if supported
195
200
if client_registration_options .enabled :
196
201
metadata .registration_endpoint = modify_url_path (
197
- issuer_url , lambda path : path . rstrip ( "/" ) + REGISTRATION_PATH . lstrip ( "/" )
202
+ issuer_url , lambda path : append_path ( path , REGISTRATION_PATH )
198
203
)
199
204
200
205
# Add revocation endpoint if supported
201
206
if revocation_options .enabled :
202
207
metadata .revocation_endpoint = modify_url_path (
203
- issuer_url , lambda path : path . rstrip ( "/" ) + REVOCATION_PATH . lstrip ( "/" )
208
+ issuer_url , lambda path : append_path ( path , REVOCATION_PATH )
204
209
)
205
210
metadata .revocation_endpoint_auth_methods_supported = ["client_secret_post" ]
206
211
0 commit comments