test: oauth/authorize on api endpoint

This commit is contained in:
Mar0xy 2023-11-08 22:45:40 +01:00
parent c5008452c1
commit 0087bc3ace
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828

View file

@ -67,6 +67,17 @@ export class OAuth2ProviderService {
payload.on('error', done); 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) => { fastify.post('/oauth/token', async (request, reply) => {
const body: any = request.body || request.query; const body: any = request.body || request.query;
if (body.grant_type === "client_credentials") { if (body.grant_type === "client_credentials") {