mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Rewrite request with a root path to OIDC Provider
* fix(oidc): rewrite requests with rootpath * fix: respect query parameters
This commit is contained in:
@@ -18,6 +18,13 @@ export class OidcHttpHandler extends HttpHandler {
|
||||
|
||||
public async handle({ request, response }: HttpHandlerInput): Promise<void> {
|
||||
const provider = await this.providerFactory.getProvider();
|
||||
|
||||
// Rewrite requests to allow hosting on root paths
|
||||
const path = new URL(provider.issuer).pathname;
|
||||
if (path.length > 1 && request.url!.startsWith(`${path}.well-known/openid-configuration`)) {
|
||||
request.url = request.url!.replace(path, '/');
|
||||
}
|
||||
|
||||
this.logger.debug(`Sending request to oidc-provider: ${request.url}`);
|
||||
// Even though the typings do not indicate this, this is a Promise that needs to be awaited.
|
||||
// Otherwise, the `BaseHttpServerFactory` will write a 404 before the OIDC library could handle the response.
|
||||
|
||||
Reference in New Issue
Block a user