summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/oauth/OAuth2ProviderService.ts
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2025-12-01 18:36:55 +0900
committerGitHub <noreply@github.com>2025-12-01 18:36:55 +0900
commitf222d7e24d3d134a078868c89363cacde906ccdc (patch)
tree987edf63823a078365a514b0c755258b196a5d1b /packages/backend/src/server/oauth/OAuth2ProviderService.ts
parentfix(frontend): visibilityStateがhiddenな状態でstartViewTransitionしな... (diff)
downloadmisskey-f222d7e24d3d134a078868c89363cacde906ccdc.tar.gz
misskey-f222d7e24d3d134a078868c89363cacde906ccdc.tar.bz2
misskey-f222d7e24d3d134a078868c89363cacde906ccdc.zip
enhance(backend): pugをやめ、JSXベースのテンプレートに変更 (#16908)
* enhance(backend): pugをやめ、JSXベースのテンプレートに変更 (to misskey-dev dev branch) (#16889) * wip * wip * wip * wip * fix lint * attempt to fix test * fix * fix * fix: oauthページの描画がおかしい問題を修正 * typo [ci skip] * fix * fix * fix * fix * fix * refactor * fix * fix * fix broken lockfile * fix: expose supported languages as global variable * remove i18n package from root as it is no longer required [ci skip] * fix * fix: add i18n package.json to Docker target-builder stage for federation tests (#16909) * Initial plan * fix: add i18n package.json to Docker target-builder stage for federation tests Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> * fix: followup-test-federation for enh-remove-pug (#16910) * fix: followup-test-federation for enh-remove-pug * Revert "fix: add i18n package.json to Docker target-builder stage for federation tests (#16909)" This reverts commit 14313468d34f49c363eef4d0a932e9fc0d9a37fb. * fix: CSSが読み込まれない場合がある問題を修正 * fix [ci skip] * fix: propsのデフォルト値をnull合体演算子から論理和演算子に変更(空文字に対処するため) * remove @types/pug * enhance: bootloaderを埋め込むように * fix possible race condition * remove esbuild --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> Co-authored-by: おさむのひと <46447427+samunohito@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/server/oauth/OAuth2ProviderService.ts')
-rw-r--r--packages/backend/src/server/oauth/OAuth2ProviderService.ts23
1 files changed, 8 insertions, 15 deletions
diff --git a/packages/backend/src/server/oauth/OAuth2ProviderService.ts b/packages/backend/src/server/oauth/OAuth2ProviderService.ts
index 1c15f35399..d2391c43ab 100644
--- a/packages/backend/src/server/oauth/OAuth2ProviderService.ts
+++ b/packages/backend/src/server/oauth/OAuth2ProviderService.ts
@@ -12,8 +12,6 @@ import ipaddr from 'ipaddr.js';
import oauth2orize, { type OAuth2, AuthorizationError, ValidateFunctionArity2, OAuth2Req, MiddlewareRequest } from 'oauth2orize';
import oauth2Pkce from 'oauth2orize-pkce';
import fastifyCors from '@fastify/cors';
-import fastifyView from '@fastify/view';
-import pug from 'pug';
import bodyParser from 'body-parser';
import fastifyExpress from '@fastify/express';
import { verifyChallenge } from 'pkce-challenge';
@@ -31,6 +29,8 @@ import { MemoryKVCache } from '@/misc/cache.js';
import { LoggerService } from '@/core/LoggerService.js';
import Logger from '@/logger.js';
import { StatusError } from '@/misc/status-error.js';
+import { HtmlTemplateService } from '@/server/web/HtmlTemplateService.js';
+import { OAuthPage } from '@/server/web/views/oauth.js';
import type { ServerResponse } from 'node:http';
import type { FastifyInstance } from 'fastify';
@@ -273,6 +273,7 @@ export class OAuth2ProviderService {
private usersRepository: UsersRepository,
private cacheService: CacheService,
loggerService: LoggerService,
+ private htmlTemplateService: HtmlTemplateService,
) {
this.#logger = loggerService.getLogger('oauth');
@@ -406,24 +407,16 @@ export class OAuth2ProviderService {
this.#logger.info(`Rendering authorization page for "${oauth2.client.name}"`);
reply.header('Cache-Control', 'no-store');
- return await reply.view('oauth', {
+ return await HtmlTemplateService.replyHtml(reply, OAuthPage({
+ ...await this.htmlTemplateService.getCommonData(),
transactionId: oauth2.transactionID,
clientName: oauth2.client.name,
- clientLogo: oauth2.client.logo,
- scope: oauth2.req.scope.join(' '),
- });
+ clientLogo: oauth2.client.logo ?? undefined,
+ scope: oauth2.req.scope,
+ }));
});
fastify.post('/decision', async () => { });
- fastify.register(fastifyView, {
- root: fileURLToPath(new URL('../web/views', import.meta.url)),
- engine: { pug },
- defaultContext: {
- version: this.config.version,
- config: this.config,
- },
- });
-
await fastify.register(fastifyExpress);
fastify.use('/authorize', this.#server.authorize(((areq, done) => {
(async (): Promise<Parameters<typeof done>> => {