From 0087bc3ace47a41c60ce825a8ca3b079d47f9b97 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Wed, 8 Nov 2023 22:45:40 +0100 Subject: [PATCH] test: oauth/authorize on api endpoint --- .../backend/src/server/oauth/OAuth2ProviderService.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/backend/src/server/oauth/OAuth2ProviderService.ts b/packages/backend/src/server/oauth/OAuth2ProviderService.ts index 8cd49d3487..2b0db7855a 100644 --- a/packages/backend/src/server/oauth/OAuth2ProviderService.ts +++ b/packages/backend/src/server/oauth/OAuth2ProviderService.ts @@ -67,6 +67,17 @@ export class OAuth2ProviderService { payload.on('error', done); }); + fastify.get('/oauth/authorize', async (request, reply) => { + const query: any = request.query; + let param = "mastodon=true"; + if (query.state) param += `&state=${query.state}`; + if (query.redirect_uri) param += `&redirect_uri=${query.redirect_uri}`; + const client = query.client_id ? query.client_id : ""; + reply.redirect( + `${Buffer.from(client.toString(), 'base64').toString()}?${param}`, + ); + }); + fastify.post('/oauth/token', async (request, reply) => { const body: any = request.body || request.query; if (body.grant_type === "client_credentials") {