From ca7c3c6063f2ee9ca1eb104ccfdf8c3ae6a8a3e5 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sat, 24 Jun 2023 03:45:15 +0200 Subject: [PATCH] remove redundant function calls --- .../backend/src/server/oauth/OAuth2ProviderService.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/oauth/OAuth2ProviderService.ts b/packages/backend/src/server/oauth/OAuth2ProviderService.ts index 787515e857..4a461949ad 100644 --- a/packages/backend/src/server/oauth/OAuth2ProviderService.ts +++ b/packages/backend/src/server/oauth/OAuth2ProviderService.ts @@ -327,12 +327,12 @@ export class OAuth2ProviderService { return [accessToken, undefined, { scope: granted.scopes.join(' ') }]; })().then(args => done(null, ...args ?? []), err => done(err)); })); - this.#server.serializeClient((client, done) => done(null, client)); - this.#server.deserializeClient((id, done) => done(null, id)); } @bindThis public async createServer(fastify: FastifyInstance): Promise { + // https://datatracker.ietf.org/doc/html/rfc8414.html + // https://indieauth.spec.indieweb.org/#indieauth-server-metadata fastify.get('/.well-known/oauth-authorization-server', async (_request, reply) => { reply.send({ issuer: this.config.url, @@ -347,8 +347,6 @@ export class OAuth2ProviderService { }); }); - // For now only allow the basic OAuth endpoints, to start small and evaluate - // this feature for some time, given that this is security related. fastify.get('/oauth/authorize', async (request, reply) => { const oauth2 = (request.raw as MiddlewareRequest).oauth2; if (!oauth2) { @@ -401,7 +399,7 @@ export class OAuth2ProviderService { // Find client information from the remote. const clientInfo = await discoverClientInformation(this.httpRequestService, clientUrl.href); - // Require an explicit list of redirect_uris per + // Require the redirect URI to be included in an explicit list, per // https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics#section-4.1.3 if (!clientInfo.redirectUris.includes(redirectURI)) { throw new AuthorizationError('Invalid redirect_uri', 'invalid_request');