merge wildcard binder to createServer
This commit is contained in:
parent
95dd66a0ba
commit
aa87fb2f50
2 changed files with 14 additions and 21 deletions
|
@ -92,7 +92,6 @@ export class ServerService implements OnApplicationShutdown {
|
||||||
fastify.register(this.activityPubServerService.createServer);
|
fastify.register(this.activityPubServerService.createServer);
|
||||||
fastify.register(this.nodeinfoServerService.createServer);
|
fastify.register(this.nodeinfoServerService.createServer);
|
||||||
fastify.register(this.wellKnownServerService.createServer);
|
fastify.register(this.wellKnownServerService.createServer);
|
||||||
fastify.register(this.oauth2ProviderService.createServerWildcard);
|
|
||||||
fastify.register(this.oauth2ProviderService.createServer);
|
fastify.register(this.oauth2ProviderService.createServer);
|
||||||
|
|
||||||
fastify.get<{ Params: { path: string }; Querystring: { static?: any; badge?: any; }; }>('/emoji/:path(.*)', async (request, reply) => {
|
fastify.get<{ Params: { path: string }; Querystring: { static?: any; badge?: any; }; }>('/emoji/:path(.*)', async (request, reply) => {
|
||||||
|
|
|
@ -254,26 +254,6 @@ export class OAuth2ProviderService {
|
||||||
this.#server.deserializeClient((id, done) => done(null, id));
|
this.#server.deserializeClient((id, done) => done(null, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return 404 for any unknown paths under /oauth so that clients can know
|
|
||||||
// whether a certain endpoint is supported or not.
|
|
||||||
// Registering separately because otherwise fastify.use() will match the
|
|
||||||
// wildcard too.
|
|
||||||
// TODO: is this separation still needed?
|
|
||||||
@bindThis
|
|
||||||
public async createServerWildcard(fastify: FastifyInstance): Promise<void> {
|
|
||||||
fastify.all('/oauth/*', async (_request, reply) => {
|
|
||||||
reply.code(404);
|
|
||||||
reply.send({
|
|
||||||
error: {
|
|
||||||
message: 'Unknown OAuth endpoint.',
|
|
||||||
code: 'UNKNOWN_OAUTH_ENDPOINT',
|
|
||||||
id: 'aa49e620-26cb-4e28-aad6-8cbcb58db147',
|
|
||||||
kind: 'client',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async createServer(fastify: FastifyInstance): Promise<void> {
|
public async createServer(fastify: FastifyInstance): Promise<void> {
|
||||||
fastify.get('/.well-known/oauth-authorization-server', async (_request, reply) => {
|
fastify.get('/.well-known/oauth-authorization-server', async (_request, reply) => {
|
||||||
|
@ -382,5 +362,19 @@ export class OAuth2ProviderService {
|
||||||
fastify.use('/oauth/token', bodyParser.json({ strict: true }));
|
fastify.use('/oauth/token', bodyParser.json({ strict: true }));
|
||||||
fastify.use('/oauth/token', this.#server.token());
|
fastify.use('/oauth/token', this.#server.token());
|
||||||
fastify.use('/oauth/token', this.#server.errorHandler());
|
fastify.use('/oauth/token', this.#server.errorHandler());
|
||||||
|
|
||||||
|
// Return 404 for any unknown paths under /oauth so that clients can know
|
||||||
|
// whether a certain endpoint is supported or not.
|
||||||
|
fastify.all('/oauth/*', async (_request, reply) => {
|
||||||
|
reply.code(404);
|
||||||
|
reply.send({
|
||||||
|
error: {
|
||||||
|
message: 'Unknown OAuth endpoint.',
|
||||||
|
code: 'UNKNOWN_OAUTH_ENDPOINT',
|
||||||
|
id: 'aa49e620-26cb-4e28-aad6-8cbcb58db147',
|
||||||
|
kind: 'client',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue