test: oauth/authorize on api endpoint
This commit is contained in:
parent
c5008452c1
commit
0087bc3ace
1 changed files with 11 additions and 0 deletions
|
@ -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") {
|
||||||
|
|
Loading…
Reference in a new issue