feat(backend/oauth): allow CORS for token endpoint (#12814)
* feat(backend/oauth): allow CORS for token endpoint * no need to explicitly set origin to `*` * Update CHANGELOG.md
This commit is contained in:
parent
82822e29d9
commit
544b8106b2
10 changed files with 238 additions and 9 deletions
|
|
@ -31,6 +31,22 @@ export class OAuth2ProviderService {
|
|||
private config: Config,
|
||||
) { }
|
||||
|
||||
// https://datatracker.ietf.org/doc/html/rfc8414.html
|
||||
// https://indieauth.spec.indieweb.org/#indieauth-server-metadata
|
||||
public generateRFC8414() {
|
||||
return {
|
||||
issuer: this.config.url,
|
||||
authorization_endpoint: new URL('/oauth/authorize', this.config.url),
|
||||
token_endpoint: new URL('/oauth/token', this.config.url),
|
||||
scopes_supported: kinds,
|
||||
response_types_supported: ['code'],
|
||||
grant_types_supported: ['authorization_code'],
|
||||
service_documentation: 'https://misskey-hub.net',
|
||||
code_challenge_methods_supported: ['S256'],
|
||||
authorization_response_iss_parameter_supported: true,
|
||||
};
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async createServer(fastify: FastifyInstance): Promise<void> {
|
||||
// https://datatracker.ietf.org/doc/html/rfc8414.html
|
||||
|
|
@ -151,4 +167,17 @@ export class OAuth2ProviderService {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async createTokenServer(fastify: FastifyInstance): Promise<void> {
|
||||
fastify.register(fastifyCors);
|
||||
fastify.post('', async () => { });
|
||||
|
||||
await fastify.register(fastifyExpress);
|
||||
// Clients may use JSON or urlencoded
|
||||
fastify.use('', bodyParser.urlencoded({ extended: false }));
|
||||
fastify.use('', bodyParser.json({ strict: true }));
|
||||
fastify.use('', this.#server.token());
|
||||
fastify.use('', this.#server.errorHandler());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue